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
- ToolStripMenuItem.cs
- DataRecordInfo.cs
- SystemSounds.cs
- EntityDataSourceWrapperCollection.cs
- StructuralCache.cs
- CallbackValidatorAttribute.cs
- Normalization.cs
- CodeAccessPermission.cs
- AnimatedTypeHelpers.cs
- TypeForwardedToAttribute.cs
- FormatPage.cs
- BatchStream.cs
- SqlDataSourceCommandEventArgs.cs
- PublisherIdentityPermission.cs
- ImplicitInputBrush.cs
- ProfileParameter.cs
- ITextView.cs
- FixedElement.cs
- Pointer.cs
- HandlerBase.cs
- SQLInt64.cs
- StrokeNodeEnumerator.cs
- ColumnPropertiesGroup.cs
- CatalogPartCollection.cs
- HealthMonitoringSection.cs
- WorkflowServiceNamespace.cs
- QilBinary.cs
- ReceiveCompletedEventArgs.cs
- StatusBarDrawItemEvent.cs
- ExpressionReplacer.cs
- CompiledELinqQueryState.cs
- ObjectDisposedException.cs
- BatchParser.cs
- SqlUdtInfo.cs
- MessageBodyDescription.cs
- OdbcErrorCollection.cs
- AsyncDataRequest.cs
- PropertyBuilder.cs
- errorpatternmatcher.cs
- PointLightBase.cs
- ServiceHttpModule.cs
- BitmapCache.cs
- GetWinFXPath.cs
- SessionStateItemCollection.cs
- VisualStyleTypesAndProperties.cs
- DateTimeConverter2.cs
- SystemIPv4InterfaceProperties.cs
- StylusButtonCollection.cs
- SocketCache.cs
- WindowShowOrOpenTracker.cs
- ImmutableCollection.cs
- HelpFileFileNameEditor.cs
- MetaTable.cs
- StorageMappingFragment.cs
- CodeDirectoryCompiler.cs
- PolyQuadraticBezierSegment.cs
- ContentControl.cs
- SerializationSectionGroup.cs
- CommandBinding.cs
- RecordConverter.cs
- BinaryParser.cs
- RequiredFieldValidator.cs
- ScriptingJsonSerializationSection.cs
- MediaElement.cs
- UriExt.cs
- RijndaelManagedTransform.cs
- HyperLinkStyle.cs
- SqlServer2KCompatibilityCheck.cs
- AppendHelper.cs
- BidPrivateBase.cs
- XmlSchemaValidationException.cs
- DelayedRegex.cs
- WindowsTreeView.cs
- OperationContextScope.cs
- ReflectEventDescriptor.cs
- LocalizeDesigner.cs
- StringFreezingAttribute.cs
- EdmProviderManifest.cs
- ContextProperty.cs
- Size.cs
- ThreadPoolTaskScheduler.cs
- StrongNameUtility.cs
- DataKeyArray.cs
- Cloud.cs
- Column.cs
- EmptyQuery.cs
- PaperSize.cs
- RuntimeResourceSet.cs
- FolderBrowserDialog.cs
- MatrixTransform.cs
- Transform3D.cs
- ReflectTypeDescriptionProvider.cs
- EpmContentSerializerBase.cs
- shaper.cs
- NavigateEvent.cs
- SByteConverter.cs
- Mapping.cs
- ToolboxItemImageConverter.cs
- SimplePropertyEntry.cs
- DataColumnMappingCollection.cs