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
- WebServiceHandler.cs
- GatewayIPAddressInformationCollection.cs
- Point.cs
- FixedHighlight.cs
- XmlChoiceIdentifierAttribute.cs
- EmbeddedObject.cs
- InputLanguageCollection.cs
- RelationshipSet.cs
- NotImplementedException.cs
- AssemblyCache.cs
- COM2PictureConverter.cs
- TextDecoration.cs
- CellParagraph.cs
- AnnotationAdorner.cs
- RowToFieldTransformer.cs
- ClientUrlResolverWrapper.cs
- Predicate.cs
- TextServicesCompartmentContext.cs
- XmlSchemaComplexContent.cs
- ZipPackagePart.cs
- ValidatorCollection.cs
- InputMethodStateChangeEventArgs.cs
- PhysicalFontFamily.cs
- DataGridViewCellCancelEventArgs.cs
- SystemUnicastIPAddressInformation.cs
- BamlTreeUpdater.cs
- WmpBitmapEncoder.cs
- WebServiceHostFactory.cs
- EventManager.cs
- HtmlInputButton.cs
- IriParsingElement.cs
- PropertyGridCommands.cs
- METAHEADER.cs
- ConstructorExpr.cs
- TextServicesCompartment.cs
- DateTimeFormatInfoScanner.cs
- ContextMenuAutomationPeer.cs
- PointConverter.cs
- TargetParameterCountException.cs
- WindowsListViewItem.cs
- BlockCollection.cs
- Int32Converter.cs
- TextControl.cs
- RepeaterItemEventArgs.cs
- MetadataReference.cs
- UnsafeNativeMethods.cs
- LogStream.cs
- IntegerFacetDescriptionElement.cs
- XmlSignatureProperties.cs
- SevenBitStream.cs
- XPathScanner.cs
- NonClientArea.cs
- VectorAnimation.cs
- SqlUnionizer.cs
- WebPartMovingEventArgs.cs
- DesignerSerializationVisibilityAttribute.cs
- PrintSystemException.cs
- LinkGrep.cs
- XamlStyleSerializer.cs
- ConfigXmlCDataSection.cs
- EdmMember.cs
- PackagePartCollection.cs
- SamlAssertion.cs
- CodeIdentifiers.cs
- DBBindings.cs
- CorrelationManager.cs
- DataGridViewCellParsingEventArgs.cs
- ValueTable.cs
- CompositeTypefaceMetrics.cs
- SqlParameter.cs
- DataContractSet.cs
- NativeCppClassAttribute.cs
- formatter.cs
- shaperfactory.cs
- InstanceLockQueryResult.cs
- LogExtent.cs
- RuntimeEnvironment.cs
- _HTTPDateParse.cs
- CodeRegionDirective.cs
- GorillaCodec.cs
- FixedSOMLineRanges.cs
- PocoEntityKeyStrategy.cs
- PageThemeBuildProvider.cs
- ImageDrawing.cs
- PathFigureCollection.cs
- MatchingStyle.cs
- LayoutTableCell.cs
- SelectionPatternIdentifiers.cs
- MouseEventArgs.cs
- LocationUpdates.cs
- Encoding.cs
- RootBuilder.cs
- View.cs
- NullableFloatMinMaxAggregationOperator.cs
- XmlLanguage.cs
- SupportsEventValidationAttribute.cs
- RectangleGeometry.cs
- TextDpi.cs
- WebPartZone.cs
- AuthenticationSection.cs