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
- UTF32Encoding.cs
- DynamicRendererThreadManager.cs
- CodeCatchClause.cs
- EdmProperty.cs
- QueryCursorEventArgs.cs
- WebPartCancelEventArgs.cs
- GenericTransactionFlowAttribute.cs
- ListViewSelectEventArgs.cs
- SortableBindingList.cs
- ScriptMethodAttribute.cs
- ConfigXmlComment.cs
- CommandDevice.cs
- connectionpool.cs
- AuthenticationConfig.cs
- SocketElement.cs
- SqlBuilder.cs
- precedingsibling.cs
- GetFileNameResult.cs
- XPathQilFactory.cs
- WebPartEventArgs.cs
- ImageAttributes.cs
- NavigationWindowAutomationPeer.cs
- Lease.cs
- TypeConverter.cs
- DataPagerField.cs
- Thumb.cs
- XmlSchemaProviderAttribute.cs
- BufferedWebEventProvider.cs
- ImageUrlEditor.cs
- RolePrincipal.cs
- WebPartChrome.cs
- ObjectConverter.cs
- SettingsPropertyNotFoundException.cs
- AnimationException.cs
- MultipleViewPattern.cs
- XmlQualifiedNameTest.cs
- FormViewInsertedEventArgs.cs
- Effect.cs
- Matrix3D.cs
- HtmlDocument.cs
- Comparer.cs
- ArraySegment.cs
- VisualTreeUtils.cs
- SecurityTokenInclusionMode.cs
- ProtocolReflector.cs
- HttpListenerRequestUriBuilder.cs
- PropertyFilterAttribute.cs
- InheritanceUI.cs
- MultiTrigger.cs
- RouteValueDictionary.cs
- XmlImplementation.cs
- ReturnType.cs
- SQLMoneyStorage.cs
- OperatingSystemVersionCheck.cs
- VirtualDirectoryMapping.cs
- MachineKeyValidationConverter.cs
- AuthenticatedStream.cs
- PenThreadPool.cs
- httpserverutility.cs
- XmlReflectionImporter.cs
- PeerContact.cs
- PrintDocument.cs
- PixelFormats.cs
- PrintEvent.cs
- SafeMILHandleMemoryPressure.cs
- ToolStripManager.cs
- DateTimeFormatInfoScanner.cs
- OleTxTransaction.cs
- EdgeProfileValidation.cs
- XmlSerializationReader.cs
- EntityDataSourceStatementEditor.cs
- Converter.cs
- PreloadedPackages.cs
- httpserverutility.cs
- ListViewContainer.cs
- DataServiceException.cs
- UnaryNode.cs
- TextModifierScope.cs
- ConfigurationSectionHelper.cs
- EasingQuaternionKeyFrame.cs
- StrokeCollectionDefaultValueFactory.cs
- BufferedGraphics.cs
- XPathChildIterator.cs
- DataAdapter.cs
- NullableBoolConverter.cs
- DataServiceRequest.cs
- QueryInterceptorAttribute.cs
- EndPoint.cs
- FlowDocumentView.cs
- ChangePasswordDesigner.cs
- ExpressionParser.cs
- WebPartHeaderCloseVerb.cs
- LineMetrics.cs
- grammarelement.cs
- ClientRequest.cs
- EllipseGeometry.cs
- PersonalizableAttribute.cs
- ExceptionUtil.cs
- MarginCollapsingState.cs
- ThicknessAnimation.cs