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
- OleDbWrapper.cs
- DataQuery.cs
- RenamedEventArgs.cs
- ValidationEventArgs.cs
- SqlConnectionStringBuilder.cs
- RegexParser.cs
- ArraySortHelper.cs
- SHA256Managed.cs
- LinkedList.cs
- SessionSymmetricMessageSecurityProtocolFactory.cs
- PageContent.cs
- RoleServiceManager.cs
- RealizationContext.cs
- AxDesigner.cs
- PersonalizationAdministration.cs
- HtmlInputPassword.cs
- DelegatedStream.cs
- TreeChangeInfo.cs
- NetworkInterface.cs
- TemplateContent.cs
- Internal.cs
- ResourceExpression.cs
- ScrollBar.cs
- HttpStreamMessageEncoderFactory.cs
- EditingCommands.cs
- XPathQueryGenerator.cs
- ReachBasicContext.cs
- PolicyException.cs
- CommandValueSerializer.cs
- AutomationElementCollection.cs
- coordinator.cs
- WebPartDescription.cs
- ImpersonateTokenRef.cs
- PointAnimationClockResource.cs
- Hash.cs
- FileDataSource.cs
- OptionalRstParameters.cs
- TemplateBamlRecordReader.cs
- HostElement.cs
- DWriteFactory.cs
- NavigationEventArgs.cs
- StringFormat.cs
- PathGeometry.cs
- EntityDesignerUtils.cs
- ToolTipAutomationPeer.cs
- ToolStripItem.cs
- InheritanceContextChangedEventManager.cs
- ColorMap.cs
- TypeKeyValue.cs
- Stylesheet.cs
- ClassData.cs
- LabelInfo.cs
- ClientRuntimeConfig.cs
- TimelineGroup.cs
- CounterNameConverter.cs
- versioninfo.cs
- EraserBehavior.cs
- RegexInterpreter.cs
- AutoCompleteStringCollection.cs
- CellParagraph.cs
- WeakReferenceList.cs
- SimpleWebHandlerParser.cs
- BitmapEffectInputConnector.cs
- PageWrapper.cs
- CriticalHandle.cs
- ActivityWithResultConverter.cs
- UnsafeNativeMethodsCLR.cs
- CancellationTokenSource.cs
- AndMessageFilterTable.cs
- ParsedAttributeCollection.cs
- PageCodeDomTreeGenerator.cs
- ExpandedProjectionNode.cs
- Transform3DCollection.cs
- DataGridAutoGeneratingColumnEventArgs.cs
- TypeSystem.cs
- SimpleFileLog.cs
- UserNameSecurityToken.cs
- SmtpLoginAuthenticationModule.cs
- SchemaContext.cs
- AsyncCompletedEventArgs.cs
- IRCollection.cs
- TemplateXamlParser.cs
- LinearQuaternionKeyFrame.cs
- FormatterConverter.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- ApplicationManager.cs
- CommandManager.cs
- compensatingcollection.cs
- TextParentUndoUnit.cs
- ErrorWrapper.cs
- CompiledQueryCacheKey.cs
- StreamUpdate.cs
- BufferedGraphics.cs
- HtmlForm.cs
- WebPartZoneBaseDesigner.cs
- Section.cs
- OdbcTransaction.cs
- StorageBasedPackageProperties.cs
- Size.cs
- UserPersonalizationStateInfo.cs