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
- RemoveStoryboard.cs
- StatusBarPanel.cs
- NativeMethods.cs
- DataGridViewColumnCollection.cs
- StructuredTypeEmitter.cs
- TextTreeTextBlock.cs
- JsonMessageEncoderFactory.cs
- ImageCodecInfoPrivate.cs
- PagesSection.cs
- CounterCreationData.cs
- ProxyElement.cs
- FileDialog_Vista_Interop.cs
- columnmapkeybuilder.cs
- XmlWriterTraceListener.cs
- StringExpressionSet.cs
- ShapeTypeface.cs
- IndexingContentUnit.cs
- GlyphElement.cs
- MethodImplAttribute.cs
- Thickness.cs
- GridItem.cs
- SchemaObjectWriter.cs
- HostedImpersonationContext.cs
- FormatConvertedBitmap.cs
- ISAPIRuntime.cs
- SQLByteStorage.cs
- AsmxEndpointPickerExtension.cs
- WebServiceClientProxyGenerator.cs
- EventRoute.cs
- NGCSerializationManagerAsync.cs
- OleDbConnectionFactory.cs
- AutomationFocusChangedEventArgs.cs
- MouseOverProperty.cs
- HandlerFactoryWrapper.cs
- Variable.cs
- ObjectResult.cs
- AsnEncodedData.cs
- log.cs
- DateTimeFormatInfoScanner.cs
- ConfigXmlComment.cs
- Privilege.cs
- ResXResourceWriter.cs
- UInt64Storage.cs
- XsdDuration.cs
- IISMapPath.cs
- ProcessHostMapPath.cs
- SplitterCancelEvent.cs
- QueuePathDialog.cs
- CompressStream.cs
- URLString.cs
- BitmapInitialize.cs
- DifferencingCollection.cs
- TaiwanCalendar.cs
- URL.cs
- VScrollBar.cs
- UDPClient.cs
- GeometryCombineModeValidation.cs
- PrintPageEvent.cs
- MobileControlPersister.cs
- FormsIdentity.cs
- LinearGradientBrush.cs
- XmlNodeChangedEventManager.cs
- DataGridViewCellParsingEventArgs.cs
- Membership.cs
- SingleStorage.cs
- CharacterHit.cs
- HMACSHA1.cs
- Effect.cs
- MemberPath.cs
- Marshal.cs
- WorkflowDebuggerSteppingAttribute.cs
- CodeDomDecompiler.cs
- ObjectDataSourceView.cs
- GlyphingCache.cs
- LocalizabilityAttribute.cs
- WebBrowser.cs
- _FtpDataStream.cs
- DeferredSelectedIndexReference.cs
- RegexCompilationInfo.cs
- LinkLabel.cs
- HtmlWindowCollection.cs
- GetPageCompletedEventArgs.cs
- __Error.cs
- SqlConnectionFactory.cs
- MessagePartDescription.cs
- ProcessHost.cs
- BrowserCapabilitiesFactory.cs
- Material.cs
- FixedDocumentSequencePaginator.cs
- ThreadAbortException.cs
- DBConnectionString.cs
- SevenBitStream.cs
- ConfigurationPermission.cs
- XmlMemberMapping.cs
- WindowsListView.cs
- UpdateRecord.cs
- GenericWebPart.cs
- BamlRecordReader.cs
- ApplicationInfo.cs
- Int32Converter.cs