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
- ValidatorCollection.cs
- PaperSource.cs
- ContentFileHelper.cs
- DbConnectionClosed.cs
- Attributes.cs
- WSSecurityXXX2005.cs
- SQLBinaryStorage.cs
- Button.cs
- XmlSerializerOperationGenerator.cs
- BoolExpr.cs
- XamlSerializerUtil.cs
- SelectionItemPattern.cs
- NegationPusher.cs
- NonValidatingSecurityTokenAuthenticator.cs
- EncodingDataItem.cs
- ByteFacetDescriptionElement.cs
- DesignerVerbCollection.cs
- MsmqTransportSecurity.cs
- DesignTimeXamlWriter.cs
- WorkflowRuntimeServiceElementCollection.cs
- LocatorGroup.cs
- BinaryReader.cs
- HashAlgorithm.cs
- TextEffect.cs
- ProjectionCamera.cs
- ConfigurationSectionGroupCollection.cs
- UpdateManifestForBrowserApplication.cs
- Int16AnimationUsingKeyFrames.cs
- Activity.cs
- GeneralTransform3DGroup.cs
- WebServiceData.cs
- PropertyChangingEventArgs.cs
- NameGenerator.cs
- SourceFileBuildProvider.cs
- Queue.cs
- ObjectStateEntry.cs
- SqlTrackingWorkflowInstance.cs
- FileDetails.cs
- SystemNetworkInterface.cs
- SQLDecimalStorage.cs
- SqlRowUpdatedEvent.cs
- XmlTextReader.cs
- TextBlock.cs
- CompressEmulationStream.cs
- Math.cs
- TableLayoutPanelResizeGlyph.cs
- GatewayDefinition.cs
- ImageButton.cs
- DiscreteKeyFrames.cs
- StronglyTypedResourceBuilder.cs
- InternalControlCollection.cs
- EntityStoreSchemaGenerator.cs
- DbConnectionStringCommon.cs
- StatusBarItemAutomationPeer.cs
- DataTableReaderListener.cs
- DataGridViewDataConnection.cs
- SiteMapNode.cs
- RTLAwareMessageBox.cs
- LiteralControl.cs
- Stream.cs
- RequiredAttributeAttribute.cs
- HebrewCalendar.cs
- connectionpool.cs
- PrePostDescendentsWalker.cs
- SettingsProviderCollection.cs
- StringStorage.cs
- SafeRightsManagementQueryHandle.cs
- ChannelTerminatedException.cs
- LoginCancelEventArgs.cs
- AccessibleObject.cs
- TypeDefinition.cs
- DPCustomTypeDescriptor.cs
- ToolStripStatusLabel.cs
- LicenseException.cs
- TreeView.cs
- SessionStateItemCollection.cs
- PeerResolverBindingElement.cs
- EmptyTextWriter.cs
- SettingsPropertyValue.cs
- ISO2022Encoding.cs
- FacetEnabledSchemaElement.cs
- WebServiceErrorEvent.cs
- Utils.cs
- EmptyControlCollection.cs
- ListViewPagedDataSource.cs
- SqlDeflator.cs
- ToolBarButtonClickEvent.cs
- LocatorPart.cs
- CollectionBuilder.cs
- DelayLoadType.cs
- Timer.cs
- ProtocolsConfiguration.cs
- ChildTable.cs
- FlowDocumentPageViewerAutomationPeer.cs
- CompilerInfo.cs
- PointCollectionConverter.cs
- FakeModelPropertyImpl.cs
- AccessibilityHelperForVista.cs
- WebSysDisplayNameAttribute.cs
- Action.cs