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
- DuplicateContext.cs
- DocumentSchemaValidator.cs
- ObjectSelectorEditor.cs
- TraceData.cs
- COM2PictureConverter.cs
- COM2PropertyPageUITypeConverter.cs
- SqlConnectionHelper.cs
- RelatedEnd.cs
- FormClosingEvent.cs
- XmlNamespaceManager.cs
- SapiRecoInterop.cs
- SessionPageStatePersister.cs
- TextTreeDeleteContentUndoUnit.cs
- ButtonField.cs
- UnitySerializationHolder.cs
- WebServiceEnumData.cs
- VarRefManager.cs
- GridViewSelectEventArgs.cs
- StaticExtension.cs
- ListItemParagraph.cs
- FormsAuthenticationEventArgs.cs
- LoadedOrUnloadedOperation.cs
- AutoGeneratedField.cs
- ZipIOModeEnforcingStream.cs
- ButtonColumn.cs
- FontFamilyIdentifier.cs
- CaseInsensitiveComparer.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- SupportsEventValidationAttribute.cs
- CustomCategoryAttribute.cs
- StateRuntime.cs
- SmtpAuthenticationManager.cs
- FixedStringLookup.cs
- ConfigurationSchemaErrors.cs
- DispatchChannelSink.cs
- ThreadStateException.cs
- ConstraintEnumerator.cs
- CodeTypeReferenceExpression.cs
- XmlLoader.cs
- cookiecollection.cs
- StylusPointPropertyInfoDefaults.cs
- BamlRecordHelper.cs
- ScriptingSectionGroup.cs
- PrintController.cs
- XmlWhitespace.cs
- SamlSerializer.cs
- Nullable.cs
- DebugController.cs
- PriorityQueue.cs
- DbDeleteCommandTree.cs
- SelectiveScrollingGrid.cs
- SafeLibraryHandle.cs
- HttpDateParse.cs
- SQLInt32.cs
- TranslateTransform3D.cs
- SafeFreeMibTable.cs
- RealizationDrawingContextWalker.cs
- RoleService.cs
- Ops.cs
- ForEachAction.cs
- Utils.cs
- Stack.cs
- HelpInfo.cs
- OdbcConnectionHandle.cs
- EarlyBoundInfo.cs
- GeneralTransform3DGroup.cs
- objectquery_tresulttype.cs
- ParameterCollectionEditor.cs
- DataViewListener.cs
- ValidatorCollection.cs
- CellParagraph.cs
- BoolLiteral.cs
- CharacterBufferReference.cs
- BufferAllocator.cs
- WebContext.cs
- unitconverter.cs
- Int64Converter.cs
- ToolStripPanelRenderEventArgs.cs
- EmptyWithCancelationCheckWorkItem.cs
- HtmlShim.cs
- PropVariant.cs
- RotateTransform3D.cs
- DelimitedListTraceListener.cs
- ResourceSet.cs
- TreeViewHitTestInfo.cs
- VariantWrapper.cs
- __Filters.cs
- Html32TextWriter.cs
- SQLInt16.cs
- CodeSnippetStatement.cs
- CodeSnippetTypeMember.cs
- CollaborationHelperFunctions.cs
- COM2IPerPropertyBrowsingHandler.cs
- WebControl.cs
- ExpressionBuilderCollection.cs
- CodeTypeDeclaration.cs
- InheritanceAttribute.cs
- AutomationEvent.cs
- QuerySettings.cs
- DispatcherExceptionEventArgs.cs