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
- ServiceTimeoutsElement.cs
- DoubleCollection.cs
- HuffCodec.cs
- VectorValueSerializer.cs
- BindingCompleteEventArgs.cs
- OrderPreservingMergeHelper.cs
- ProtectedConfigurationProviderCollection.cs
- UnauthorizedAccessException.cs
- ProxyWebPartManager.cs
- FormsAuthenticationTicket.cs
- DataGridViewTopRowAccessibleObject.cs
- HttpCachePolicy.cs
- TrackBarRenderer.cs
- PrintDialog.cs
- UxThemeWrapper.cs
- StorageMappingItemCollection.cs
- DWriteFactory.cs
- EditingCoordinator.cs
- SqlInternalConnectionSmi.cs
- StrongNamePublicKeyBlob.cs
- TextAdaptor.cs
- SimpleNameService.cs
- MetadataLocation.cs
- ValidationRuleCollection.cs
- Point3DCollectionConverter.cs
- TextBlockAutomationPeer.cs
- WorkflowMarkupSerializerMapping.cs
- _CommandStream.cs
- Int32CAMarshaler.cs
- WebPartEventArgs.cs
- SafeArrayRankMismatchException.cs
- OdbcConnectionStringbuilder.cs
- ConfigUtil.cs
- OperatingSystem.cs
- ClassImporter.cs
- QueueProcessor.cs
- _FtpDataStream.cs
- MessageBox.cs
- ReflectionPermission.cs
- ObjectToIdCache.cs
- NavigateEvent.cs
- XmlFormatWriterGenerator.cs
- AutoResizedEvent.cs
- WebHttpBindingElement.cs
- HtmlForm.cs
- Drawing.cs
- Trace.cs
- ApplicationException.cs
- ListItemParagraph.cs
- Wizard.cs
- Drawing.cs
- Constants.cs
- UmAlQuraCalendar.cs
- OdbcConnectionStringbuilder.cs
- XmlMembersMapping.cs
- followingsibling.cs
- CalendarDay.cs
- AuthorizationRuleCollection.cs
- ellipse.cs
- TreeNodeConverter.cs
- PrePrepareMethodAttribute.cs
- CompilationUnit.cs
- Run.cs
- UnsafeNativeMethods.cs
- CompiledQuery.cs
- DataGridViewCellValueEventArgs.cs
- ReferenceEqualityComparer.cs
- _OverlappedAsyncResult.cs
- PostBackOptions.cs
- DesignerForm.cs
- CryptoConfig.cs
- DefaultMemberAttribute.cs
- NativeObjectSecurity.cs
- Model3DGroup.cs
- CodeConstructor.cs
- Encoding.cs
- JsonServiceDocumentSerializer.cs
- StringPropertyBuilder.cs
- RangeEnumerable.cs
- XmlNodeChangedEventArgs.cs
- CroppedBitmap.cs
- RenderData.cs
- Metafile.cs
- LayoutSettings.cs
- SpeakInfo.cs
- Int16AnimationBase.cs
- HttpRuntimeSection.cs
- PolicyLevel.cs
- MapPathBasedVirtualPathProvider.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- WebServiceReceiveDesigner.cs
- RightsManagementErrorHandler.cs
- Task.cs
- Console.cs
- BamlLocalizableResource.cs
- XmlNamespaceDeclarationsAttribute.cs
- XmlNamespaceMapping.cs
- TagPrefixCollection.cs
- EntityCodeGenerator.cs
- EncodedStreamFactory.cs