Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------- // 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
- AutomationPropertyInfo.cs
- ReflectTypeDescriptionProvider.cs
- ScriptModule.cs
- ResolveResponseInfo.cs
- ReferencedCategoriesDocument.cs
- MatrixTransform3D.cs
- ImageAttributes.cs
- DbParameterHelper.cs
- EventPrivateKey.cs
- MdiWindowListItemConverter.cs
- XmlCountingReader.cs
- TypeForwardedToAttribute.cs
- DataControlFieldTypeEditor.cs
- CodeIterationStatement.cs
- DebugInfoExpression.cs
- ImageConverter.cs
- WindowsProgressbar.cs
- SafeFileMappingHandle.cs
- TargetConverter.cs
- SoapIgnoreAttribute.cs
- GridViewColumn.cs
- TextRangeProviderWrapper.cs
- GuidelineSet.cs
- MessageHeader.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- TcpConnectionPoolSettingsElement.cs
- QueryOperationResponseOfT.cs
- CallbackException.cs
- log.cs
- TypeInfo.cs
- Descriptor.cs
- ParseElement.cs
- BuildProvider.cs
- StsCommunicationException.cs
- SqlProfileProvider.cs
- ObjectDataSourceDisposingEventArgs.cs
- SQLMembershipProvider.cs
- odbcmetadatacolumnnames.cs
- SubstitutionList.cs
- Automation.cs
- AstNode.cs
- ExpressionConverter.cs
- ElementProxy.cs
- TransactionsSectionGroup.cs
- ContractMapping.cs
- ImageMapEventArgs.cs
- PasswordTextContainer.cs
- HttpAsyncResult.cs
- DBConnection.cs
- SetStoryboardSpeedRatio.cs
- dbdatarecord.cs
- SerialPinChanges.cs
- FlowNode.cs
- ToolStripDropDown.cs
- TranslateTransform3D.cs
- AppDomainGrammarProxy.cs
- FormattedTextSymbols.cs
- EntityContainerRelationshipSetEnd.cs
- CompositionTarget.cs
- XmlILModule.cs
- LambdaCompiler.Statements.cs
- PolyBezierSegment.cs
- StylusPointProperty.cs
- MembershipValidatePasswordEventArgs.cs
- TextChange.cs
- ServiceHostFactory.cs
- KeyValueConfigurationElement.cs
- DllNotFoundException.cs
- DesignerDataRelationship.cs
- DelimitedListTraceListener.cs
- ServiceOperationUIEditor.cs
- ClickablePoint.cs
- updatecommandorderer.cs
- CodeExporter.cs
- EntityCommandCompilationException.cs
- SafePointer.cs
- XmlNamespaceMappingCollection.cs
- MethodExpression.cs
- compensatingcollection.cs
- ProxyWebPartConnectionCollection.cs
- AlgoModule.cs
- DbModificationCommandTree.cs
- StrongNameSignatureInformation.cs
- SrgsElementList.cs
- SymDocumentType.cs
- ConditionCollection.cs
- DynamicMetaObject.cs
- TimeSpanMinutesConverter.cs
- OrCondition.cs
- CalendarData.cs
- nulltextnavigator.cs
- WebBaseEventKeyComparer.cs
- SHA384Managed.cs
- FormViewUpdatedEventArgs.cs
- Typeface.cs
- DataGridRelationshipRow.cs
- VerificationAttribute.cs
- ValueTypeFixupInfo.cs
- MulticastIPAddressInformationCollection.cs
- XmlDataSourceView.cs