Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------- // 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
- InputMethod.cs
- PageParser.cs
- EventToken.cs
- EventMappingSettingsCollection.cs
- DesignerForm.cs
- PropertyGridEditorPart.cs
- PropertyGridEditorPart.cs
- AccessDataSource.cs
- ParallelSeparator.xaml.cs
- NegotiateStream.cs
- Italic.cs
- LineProperties.cs
- CodeBlockBuilder.cs
- Point3DKeyFrameCollection.cs
- RadioButtonBaseAdapter.cs
- RegistryKey.cs
- ClickablePoint.cs
- UInt32Converter.cs
- SelectionPattern.cs
- GridViewRowCollection.cs
- DesignSurface.cs
- PopupRootAutomationPeer.cs
- DoubleCollectionConverter.cs
- LinkGrep.cs
- WeakReferenceKey.cs
- DocumentSchemaValidator.cs
- UserControlParser.cs
- BulletChrome.cs
- ObjectListCommandEventArgs.cs
- DependencyObjectType.cs
- MultiSelector.cs
- RegexGroup.cs
- Source.cs
- Util.cs
- BrowsableAttribute.cs
- StandardToolWindows.cs
- FixedPageAutomationPeer.cs
- DefaultPropertyAttribute.cs
- XmlCompatibilityReader.cs
- CallbackException.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- StylusDevice.cs
- CollectionType.cs
- CompiledAction.cs
- BaseProcessProtocolHandler.cs
- BamlTreeNode.cs
- KeyInstance.cs
- RecordBuilder.cs
- View.cs
- XPathBuilder.cs
- UIntPtr.cs
- Command.cs
- CubicEase.cs
- CalloutQueueItem.cs
- _LocalDataStore.cs
- CacheChildrenQuery.cs
- DataSourceSelectArguments.cs
- EntityContainerEntitySetDefiningQuery.cs
- SourceFileInfo.cs
- Matrix3D.cs
- ImmutablePropertyDescriptorGridEntry.cs
- Literal.cs
- TextProperties.cs
- HMACRIPEMD160.cs
- WebPartZoneBase.cs
- MemberAssignment.cs
- Logging.cs
- Bitmap.cs
- LocalizationParserHooks.cs
- KeyEventArgs.cs
- CollaborationHelperFunctions.cs
- ScriptControlManager.cs
- XmlSecureResolver.cs
- StylusPointPropertyInfoDefaults.cs
- ResourceCodeDomSerializer.cs
- Site.cs
- ValidationEventArgs.cs
- Adorner.cs
- AsyncOperation.cs
- ForwardPositionQuery.cs
- EffectiveValueEntry.cs
- TerminatorSinks.cs
- QueryCacheEntry.cs
- GradientSpreadMethodValidation.cs
- ErrorProvider.cs
- LabelTarget.cs
- CodeAccessPermission.cs
- TableDetailsCollection.cs
- LogicalExpressionTypeConverter.cs
- RegexFCD.cs
- SmiRequestExecutor.cs
- ListViewDataItem.cs
- QilTernary.cs
- XmlMtomReader.cs
- Point3DKeyFrameCollection.cs
- CustomError.cs
- TypeExtension.cs
- Rfc2898DeriveBytes.cs
- ActivityMarkupSerializationProvider.cs
- BaseCollection.cs