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
- HashCodeCombiner.cs
- JsonDataContract.cs
- GlyphingCache.cs
- ErrorLog.cs
- ICspAsymmetricAlgorithm.cs
- httpapplicationstate.cs
- DoubleKeyFrameCollection.cs
- RegexReplacement.cs
- XmlSchemaInferenceException.cs
- FederatedMessageSecurityOverHttpElement.cs
- ResolveMatchesCD1.cs
- COM2ColorConverter.cs
- FileSystemEnumerable.cs
- AssemblyNameProxy.cs
- Int16Animation.cs
- cookieexception.cs
- TargetConverter.cs
- _SslStream.cs
- Keyboard.cs
- TrustManagerPromptUI.cs
- ResXResourceReader.cs
- FixedDocumentSequencePaginator.cs
- Html32TextWriter.cs
- JournalEntryStack.cs
- XmlILOptimizerVisitor.cs
- ProcessThread.cs
- Array.cs
- Win32Native.cs
- DoubleLinkListEnumerator.cs
- OdbcStatementHandle.cs
- ContextMenuStripGroupCollection.cs
- TheQuery.cs
- UnknownBitmapDecoder.cs
- CodeMemberEvent.cs
- SizeAnimation.cs
- FirstMatchCodeGroup.cs
- AutomationPeer.cs
- ValidationSummary.cs
- BindingExpressionBase.cs
- DefaultHttpHandler.cs
- Simplifier.cs
- UrlPath.cs
- SortFieldComparer.cs
- PreviewPrintController.cs
- VirtualizingPanel.cs
- TextFormatter.cs
- NativeMethods.cs
- ToolStripGripRenderEventArgs.cs
- MetabaseServerConfig.cs
- StylusPointPropertyInfoDefaults.cs
- ErrorFormatterPage.cs
- WebPartMovingEventArgs.cs
- ADRoleFactory.cs
- DateTimeEditor.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- TrackBarDesigner.cs
- HuffmanTree.cs
- DeviceSpecificChoice.cs
- CuspData.cs
- UInt32Storage.cs
- ClientSettingsSection.cs
- DropSourceBehavior.cs
- SqlClientFactory.cs
- DbMetaDataCollectionNames.cs
- CustomActivityDesigner.cs
- TextEffect.cs
- WriteTimeStream.cs
- DashStyle.cs
- CodeAttributeArgumentCollection.cs
- ColumnBinding.cs
- PersonalizationProviderHelper.cs
- CombinedGeometry.cs
- File.cs
- EmptyTextWriter.cs
- XmlnsCache.cs
- RemoteWebConfigurationHostStream.cs
- JsonXmlDataContract.cs
- DataRecordInfo.cs
- Animatable.cs
- XmlQueryCardinality.cs
- SafeCertificateStore.cs
- GeometryConverter.cs
- PopupEventArgs.cs
- InkPresenterAutomationPeer.cs
- MasterPageParser.cs
- SafeProcessHandle.cs
- FieldToken.cs
- UnsafeNativeMethods.cs
- AuthenticatingEventArgs.cs
- BaseDataList.cs
- MessageDecoder.cs
- CompilationRelaxations.cs
- RuleSettingsCollection.cs
- OverlappedAsyncResult.cs
- DataGridDetailsPresenterAutomationPeer.cs
- WindowsListView.cs
- XmlSignatureProperties.cs
- OdbcUtils.cs
- AttachmentCollection.cs
- PackageRelationship.cs