Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / ImmutableCollection.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SupportsPreviewControlAttribute.cs
- CustomErrorCollection.cs
- DetailsViewDeletedEventArgs.cs
- DesignTimeXamlWriter.cs
- CustomPeerResolverService.cs
- ByteStack.cs
- SerialPinChanges.cs
- TypeDefinition.cs
- EdgeProfileValidation.cs
- PagesSection.cs
- HttpModulesSection.cs
- FontDialog.cs
- coordinator.cs
- ProfileEventArgs.cs
- ClearCollection.cs
- RelationalExpressions.cs
- BamlResourceSerializer.cs
- OdbcInfoMessageEvent.cs
- RSAOAEPKeyExchangeDeformatter.cs
- embossbitmapeffect.cs
- InternalConfirm.cs
- Vector3DIndependentAnimationStorage.cs
- ActionFrame.cs
- shaper.cs
- DataTable.cs
- Automation.cs
- FileVersionInfo.cs
- DataColumnSelectionConverter.cs
- StrokeSerializer.cs
- HighlightVisual.cs
- ByteArrayHelperWithString.cs
- SurrogateEncoder.cs
- XMLSyntaxException.cs
- LinearKeyFrames.cs
- TemplateManager.cs
- Int32RectValueSerializer.cs
- FixUpCollection.cs
- NetMsmqSecurityElement.cs
- SecurityToken.cs
- DataGridState.cs
- ScriptManager.cs
- NamespaceInfo.cs
- DiscoveryExceptionDictionary.cs
- VectorCollection.cs
- TraceProvider.cs
- TypeConstant.cs
- DeclarationUpdate.cs
- ReflectionServiceProvider.cs
- FactoryId.cs
- ValueQuery.cs
- Int32KeyFrameCollection.cs
- CollectionViewProxy.cs
- StorageComplexPropertyMapping.cs
- EncryptedPackageFilter.cs
- UrlMappingCollection.cs
- BindingsCollection.cs
- ImageAnimator.cs
- FileDialog_Vista.cs
- ObjectStateManager.cs
- WriteTimeStream.cs
- EventSourceCreationData.cs
- PeerTransportBindingElement.cs
- RtType.cs
- NavigationFailedEventArgs.cs
- Normalization.cs
- KerberosReceiverSecurityToken.cs
- Vector3DCollectionValueSerializer.cs
- UserPreferenceChangedEventArgs.cs
- ButtonStandardAdapter.cs
- KeyValuePair.cs
- FileLevelControlBuilderAttribute.cs
- CookieHandler.cs
- NavigationWindow.cs
- DirectoryNotFoundException.cs
- VersionedStreamOwner.cs
- Perspective.cs
- SymDocumentType.cs
- TraceSwitch.cs
- ArraySubsetEnumerator.cs
- GridEntry.cs
- SchemaInfo.cs
- ReadOnlyDictionary.cs
- ProviderBase.cs
- DefaultValueConverter.cs
- Storyboard.cs
- PromptStyle.cs
- NamespaceList.cs
- ParameterReplacerVisitor.cs
- ApplicationInterop.cs
- AttachedAnnotation.cs
- TimeZone.cs
- CompModSwitches.cs
- MetadataArtifactLoaderCompositeResource.cs
- ObjectAssociationEndMapping.cs
- SqlConnectionPoolGroupProviderInfo.cs
- LayoutInformation.cs
- ZoneIdentityPermission.cs
- ProfileSection.cs
- DisposableCollectionWrapper.cs
- XmlSchemaAnnotation.cs