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
- AsnEncodedData.cs
- CompressionTransform.cs
- WebPartTransformerAttribute.cs
- SemanticAnalyzer.cs
- CollectionChangedEventManager.cs
- ServiceBehaviorElement.cs
- TextLineBreak.cs
- DependencyPropertyKind.cs
- Converter.cs
- SchemaMerger.cs
- ReversePositionQuery.cs
- LinqDataSourceDeleteEventArgs.cs
- XmlSchemaAttribute.cs
- PageCodeDomTreeGenerator.cs
- NavigationFailedEventArgs.cs
- ValidationPropertyAttribute.cs
- EditingCoordinator.cs
- ImmutableObjectAttribute.cs
- ISAPIApplicationHost.cs
- DataControlField.cs
- PolicyValidationException.cs
- AppPool.cs
- Sql8ExpressionRewriter.cs
- XmlUtil.cs
- Parameter.cs
- UnsafeCollabNativeMethods.cs
- SmtpSection.cs
- InvariantComparer.cs
- FunctionImportElement.cs
- BrushValueSerializer.cs
- X509CertificateChain.cs
- Predicate.cs
- DesigntimeLicenseContext.cs
- SmtpMail.cs
- ParentUndoUnit.cs
- UnauthorizedWebPart.cs
- SqlComparer.cs
- ArgumentOutOfRangeException.cs
- RootProfilePropertySettingsCollection.cs
- OdbcParameterCollection.cs
- WebServiceClientProxyGenerator.cs
- SingleConverter.cs
- RealizationDrawingContextWalker.cs
- DbConnectionStringBuilder.cs
- Process.cs
- XamlClipboardData.cs
- ComplexPropertyEntry.cs
- ServiceBusyException.cs
- DeploymentSectionCache.cs
- PropertyChangedEventManager.cs
- HttpInputStream.cs
- DataSourceXmlSerializationAttribute.cs
- PointCollection.cs
- PathFigureCollection.cs
- EdmRelationshipRoleAttribute.cs
- CompareInfo.cs
- NamespaceEmitter.cs
- XmlMtomReader.cs
- ConstraintManager.cs
- DataGridSortCommandEventArgs.cs
- DataGridViewColumnHeaderCell.cs
- DecoderExceptionFallback.cs
- __Filters.cs
- XsltLoader.cs
- OperationResponse.cs
- DataGridViewTextBoxEditingControl.cs
- SystemBrushes.cs
- documentsequencetextview.cs
- CaretElement.cs
- ProviderCommandInfoUtils.cs
- SchemaEntity.cs
- TextContainerChangedEventArgs.cs
- CodeDirectiveCollection.cs
- SqlTypeConverter.cs
- FileCodeGroup.cs
- ElementHost.cs
- XamlTemplateSerializer.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- EpmContentDeSerializerBase.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- NetNamedPipeSecurityMode.cs
- LayoutInformation.cs
- DomainConstraint.cs
- MailSettingsSection.cs
- WebConfigurationFileMap.cs
- ExpandoClass.cs
- XPathNodeHelper.cs
- Bezier.cs
- Substitution.cs
- ForwardPositionQuery.cs
- SkinBuilder.cs
- __TransparentProxy.cs
- TextEditorTables.cs
- DataContract.cs
- TraceInternal.cs
- CustomLineCap.cs
- ResXBuildProvider.cs
- LinkClickEvent.cs
- MeasureItemEvent.cs
- FormsAuthenticationCredentials.cs