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
- MarshalDirectiveException.cs
- PermissionSetEnumerator.cs
- RegexCompiler.cs
- X509Logo.cs
- GridViewRowCollection.cs
- AppLevelCompilationSectionCache.cs
- EndpointReference.cs
- XmlDictionaryReaderQuotas.cs
- ConfigXmlDocument.cs
- SafeLibraryHandle.cs
- BindingExpressionBase.cs
- QuaternionConverter.cs
- ToolStripPanelRow.cs
- TextDpi.cs
- LocalizableResourceBuilder.cs
- StyleXamlParser.cs
- EndPoint.cs
- UserUseLicenseDictionaryLoader.cs
- ClientFormsAuthenticationCredentials.cs
- ZipIORawDataFileBlock.cs
- TextRunCacheImp.cs
- QilParameter.cs
- UpdateCommand.cs
- GCHandleCookieTable.cs
- ISessionStateStore.cs
- ToolboxComponentsCreatingEventArgs.cs
- DBSchemaTable.cs
- EdmToObjectNamespaceMap.cs
- TableParaClient.cs
- CodeChecksumPragma.cs
- AlternateViewCollection.cs
- ToolStripGrip.cs
- TextPointerBase.cs
- GrammarBuilderBase.cs
- HtmlElementEventArgs.cs
- CanonicalFontFamilyReference.cs
- PolyLineSegment.cs
- LinqDataSourceSelectEventArgs.cs
- CodeDefaultValueExpression.cs
- CacheMemory.cs
- AsyncPostBackErrorEventArgs.cs
- ScaleTransform.cs
- RunWorkerCompletedEventArgs.cs
- TypeUtil.cs
- SapiRecoContext.cs
- EntityDataSourceDesigner.cs
- XmlUtilWriter.cs
- EpmContentDeSerializer.cs
- SqlCacheDependency.cs
- __Filters.cs
- WorkflowQueue.cs
- MouseButtonEventArgs.cs
- __FastResourceComparer.cs
- MessageSecurityProtocolFactory.cs
- UInt32.cs
- SqlClientFactory.cs
- PermissionSet.cs
- CellIdBoolean.cs
- TypeForwardedToAttribute.cs
- ClientType.cs
- BuildProvidersCompiler.cs
- FormatException.cs
- MatrixUtil.cs
- Run.cs
- RegistryKey.cs
- Matrix3D.cs
- VisualStyleElement.cs
- PaginationProgressEventArgs.cs
- SmtpTransport.cs
- WebHttpBehavior.cs
- DataObjectSettingDataEventArgs.cs
- CompilerTypeWithParams.cs
- ExtractedStateEntry.cs
- AssemblySettingAttributes.cs
- SqlBulkCopyColumnMappingCollection.cs
- StringAnimationBase.cs
- DesignerProperties.cs
- FrameworkElementFactory.cs
- Latin1Encoding.cs
- DataServiceProcessingPipeline.cs
- ParsedAttributeCollection.cs
- Label.cs
- Int64KeyFrameCollection.cs
- XmlSerializationGeneratedCode.cs
- StrokeFIndices.cs
- ContextMenuAutomationPeer.cs
- MultiBinding.cs
- FullTextLine.cs
- Accessible.cs
- BaseCAMarshaler.cs
- DesigntimeLicenseContextSerializer.cs
- RelationshipManager.cs
- RequestResizeEvent.cs
- XPathDocumentIterator.cs
- BitmapEffectGroup.cs
- TemplateBuilder.cs
- XamlSerializerUtil.cs
- FileNotFoundException.cs
- MediaCommands.cs
- BufferedWebEventProvider.cs