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
- XPathNavigatorReader.cs
- DataGridRowClipboardEventArgs.cs
- HtmlElement.cs
- NonDualMessageSecurityOverHttpElement.cs
- Comparer.cs
- XsltContext.cs
- TableLayoutStyleCollection.cs
- LinkAreaEditor.cs
- SlipBehavior.cs
- XmlConvert.cs
- DataObjectEventArgs.cs
- IsolatedStorageFileStream.cs
- XmlChoiceIdentifierAttribute.cs
- KeyValuePair.cs
- EventPropertyMap.cs
- DetectEofStream.cs
- SoundPlayerAction.cs
- ImageAttributes.cs
- DbConnectionPool.cs
- returneventsaver.cs
- AmbientLight.cs
- FrameworkContentElement.cs
- SignedXmlDebugLog.cs
- ObjectItemLoadingSessionData.cs
- DataServiceQueryOfT.cs
- TypeInitializationException.cs
- StrongNameHelpers.cs
- XmlWriterSettings.cs
- OraclePermissionAttribute.cs
- SpecialFolderEnumConverter.cs
- DataGridViewImageCell.cs
- WebPartCloseVerb.cs
- HttpConfigurationContext.cs
- Selection.cs
- SqlInternalConnection.cs
- DataBindEngine.cs
- XmlSchemaNotation.cs
- SaveFileDialog.cs
- TimersDescriptionAttribute.cs
- ResourceFallbackManager.cs
- ServiceObjectContainer.cs
- DbModificationCommandTree.cs
- HttpApplicationStateBase.cs
- Pkcs7Signer.cs
- XmlLinkedNode.cs
- basevalidator.cs
- UnknownBitmapDecoder.cs
- Camera.cs
- WebPartAddingEventArgs.cs
- ToolBar.cs
- DbBuffer.cs
- QualificationDataAttribute.cs
- ListCollectionView.cs
- ProvidersHelper.cs
- TextServicesCompartmentContext.cs
- OleDbConnectionInternal.cs
- ResXFileRef.cs
- CodeGroup.cs
- ManagedWndProcTracker.cs
- safelink.cs
- ResponseBodyWriter.cs
- WinEventWrap.cs
- DataBindingHandlerAttribute.cs
- XamlContextStack.cs
- XmlBinaryWriterSession.cs
- XmlSignificantWhitespace.cs
- BrowserCapabilitiesCodeGenerator.cs
- SizeValueSerializer.cs
- NamespaceList.cs
- PrintDocument.cs
- DataServiceQueryException.cs
- CustomLineCap.cs
- DataObjectFieldAttribute.cs
- _UriTypeConverter.cs
- OleDbWrapper.cs
- VisualTarget.cs
- CompilerHelpers.cs
- ValidationPropertyAttribute.cs
- ClientRuntimeConfig.cs
- BitmapImage.cs
- SqlClientMetaDataCollectionNames.cs
- XmlIlVisitor.cs
- TrackingMemoryStream.cs
- HtmlTextArea.cs
- ProviderBase.cs
- XmlElementCollection.cs
- SizeChangedInfo.cs
- LocalFileSettingsProvider.cs
- AttachedAnnotationChangedEventArgs.cs
- WorkItem.cs
- ServicePointManager.cs
- DataGridHelper.cs
- PerformanceCounterCategory.cs
- ToolStripContextMenu.cs
- TabControl.cs
- HttpServerVarsCollection.cs
- FileRecordSequenceCompletedAsyncResult.cs
- HtmlShimManager.cs
- Lazy.cs
- PropertyMapper.cs