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
- ResourceCategoryAttribute.cs
- DesignerHelpers.cs
- CodeAttributeArgument.cs
- DictationGrammar.cs
- Annotation.cs
- EmptyReadOnlyDictionaryInternal.cs
- TextEditorParagraphs.cs
- PLINQETWProvider.cs
- ValueTable.cs
- DoWorkEventArgs.cs
- HttpResponseWrapper.cs
- DataSourceSelectArguments.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- WebControlAdapter.cs
- ManagementQuery.cs
- CombinedHttpChannel.cs
- EmptyStringExpandableObjectConverter.cs
- DataGridTextBoxColumn.cs
- BitmapImage.cs
- SpeechRecognizer.cs
- XmlArrayItemAttributes.cs
- unsafenativemethodstextservices.cs
- StylusTip.cs
- DSACryptoServiceProvider.cs
- X500Name.cs
- ListViewHitTestInfo.cs
- DataGridViewColumnConverter.cs
- ChannelBinding.cs
- SyncMethodInvoker.cs
- CommandEventArgs.cs
- WmlValidationSummaryAdapter.cs
- TextRangeEdit.cs
- DbMetaDataCollectionNames.cs
- DbParameterCollectionHelper.cs
- DefaultAutoFieldGenerator.cs
- ADConnectionHelper.cs
- OleDbPermission.cs
- QueryContinueDragEventArgs.cs
- ListDictionaryInternal.cs
- PathFigure.cs
- ServiceObjectContainer.cs
- Double.cs
- TextEffectCollection.cs
- Compress.cs
- ConfigurationFileMap.cs
- ResourceSet.cs
- SqlCommandBuilder.cs
- UniformGrid.cs
- ResourceManager.cs
- HttpCacheVary.cs
- columnmapfactory.cs
- TemplatedAdorner.cs
- TreeView.cs
- SecurityElement.cs
- XmlDownloadManager.cs
- EmbeddedMailObject.cs
- EntityViewGenerationAttribute.cs
- ColumnMap.cs
- TextRange.cs
- Certificate.cs
- ContractValidationHelper.cs
- Set.cs
- StringToken.cs
- ValidationErrorEventArgs.cs
- DataGridViewColumn.cs
- InstanceOwnerQueryResult.cs
- SignedXml.cs
- ColorAnimationBase.cs
- _FtpDataStream.cs
- SignerInfo.cs
- Link.cs
- Vector3DAnimation.cs
- Stream.cs
- DataGridViewRowPostPaintEventArgs.cs
- CompiledIdentityConstraint.cs
- GiveFeedbackEventArgs.cs
- InvokeFunc.cs
- PropertyTabAttribute.cs
- DbProviderManifest.cs
- OutputScope.cs
- MsmqInputChannelListenerBase.cs
- PrintControllerWithStatusDialog.cs
- IPPacketInformation.cs
- NativeCompoundFileAPIs.cs
- HttpListenerException.cs
- CollectionBuilder.cs
- SqlDataReaderSmi.cs
- MetadataSource.cs
- NumericUpDownAccelerationCollection.cs
- LayoutDump.cs
- OutputCacheProfileCollection.cs
- AssemblyInfo.cs
- SqlDependencyUtils.cs
- ALinqExpressionVisitor.cs
- DataViewManager.cs
- SqlBuilder.cs
- IisTraceListener.cs
- SystemFonts.cs
- MailDefinition.cs
- PolyQuadraticBezierSegment.cs