Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / ImmutableCollection.cs / 1 / ImmutableCollection.cs
//---------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel { using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; // // A collection that can be made immutable by calling the // MakeReadOnly method. Once the collection is made read-only // Add, Remove and Clear methods will throw an exception // failing to add a item to the collection. // internal sealed class ImmutableCollection: Collection , IList , IList { bool isReadOnly = false; public void MakeReadOnly() { this.isReadOnly = true; } public bool IsReadOnly { get { return this.isReadOnly; } } protected override void ClearItems() { if (this.isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); base.ClearItems(); } protected override void InsertItem(int index, T item) { if (this.isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); base.InsertItem(index, item); } protected override void RemoveItem(int index) { if (this.isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); base.RemoveItem(index); } protected override void SetItem(int index, T item) { if (this.isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); base.SetItem(index, item); } bool ICollection .IsReadOnly { get { return this.isReadOnly; } } bool IList.IsReadOnly { get { return this.isReadOnly; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CreateParams.cs
- XslCompiledTransform.cs
- PackageRelationship.cs
- MessageProtectionOrder.cs
- TypeUtil.cs
- TypeValidationEventArgs.cs
- CombinedHttpChannel.cs
- BitmapMetadataBlob.cs
- ChangePassword.cs
- DataBindingCollection.cs
- ConnectionsZone.cs
- RpcAsyncResult.cs
- UnmanagedBitmapWrapper.cs
- CodeConstructor.cs
- SHA512Managed.cs
- safex509handles.cs
- SQLMembershipProvider.cs
- MemberMemberBinding.cs
- WebEncodingValidatorAttribute.cs
- HebrewCalendar.cs
- AppDomainProtocolHandler.cs
- NetworkCredential.cs
- UserMapPath.cs
- TextEndOfParagraph.cs
- ChineseLunisolarCalendar.cs
- Parameter.cs
- MemoryStream.cs
- TypeDescriptionProvider.cs
- LocalFileSettingsProvider.cs
- InternalEnumValidator.cs
- PropertyGeneratedEventArgs.cs
- DigestComparer.cs
- KeyValuePairs.cs
- ParserHooks.cs
- ObjectResult.cs
- XmlMapping.cs
- CompositeTypefaceMetrics.cs
- Hex.cs
- BaseComponentEditor.cs
- AssemblyName.cs
- ClientFormsAuthenticationCredentials.cs
- AssemblyBuilderData.cs
- HyperlinkAutomationPeer.cs
- ControlParameter.cs
- Util.cs
- VisualStyleInformation.cs
- ListViewCommandEventArgs.cs
- Property.cs
- Subtree.cs
- WindowsListViewItemCheckBox.cs
- ResolveMatches11.cs
- SQLMoneyStorage.cs
- TypeDescriptionProvider.cs
- Interlocked.cs
- TaskHelper.cs
- HttpWebRequestElement.cs
- Propagator.JoinPropagator.cs
- ErrorRuntimeConfig.cs
- HtmlWindowCollection.cs
- XmlNodeList.cs
- Serializer.cs
- HtmlTableRow.cs
- Publisher.cs
- ToolboxDataAttribute.cs
- ChtmlFormAdapter.cs
- HtmlValidatorAdapter.cs
- DispatcherFrame.cs
- XsltContext.cs
- Frame.cs
- CodeStatementCollection.cs
- ListViewInsertEventArgs.cs
- _SpnDictionary.cs
- PreviewKeyDownEventArgs.cs
- Win32.cs
- ToolStripItemImageRenderEventArgs.cs
- Events.cs
- ComboBox.cs
- FileVersionInfo.cs
- ZipIOExtraFieldPaddingElement.cs
- MarginsConverter.cs
- TreeNode.cs
- TimeStampChecker.cs
- MultiTouchSystemGestureLogic.cs
- DesignerMetadata.cs
- Glyph.cs
- FreeFormDesigner.cs
- OutputCacheProfile.cs
- SqlInternalConnection.cs
- AccessText.cs
- DataObjectCopyingEventArgs.cs
- FileRecordSequenceHelper.cs
- BindingValueChangedEventArgs.cs
- HtmlShim.cs
- UniqueIdentifierService.cs
- BuildProviderAppliesToAttribute.cs
- ProcessHost.cs
- UnsafeMethods.cs
- TemplateBamlRecordReader.cs
- EntityDataSourceWrapperCollection.cs
- TargetConverter.cs