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
- AttributeCollection.cs
- TextEditorContextMenu.cs
- ArrowControl.xaml.cs
- MenuItemStyleCollectionEditor.cs
- LicenseProviderAttribute.cs
- HttpHandlerAction.cs
- LoginCancelEventArgs.cs
- SweepDirectionValidation.cs
- SerialReceived.cs
- CustomExpressionEventArgs.cs
- UnderstoodHeaders.cs
- SiteMapPath.cs
- SmtpClient.cs
- GeneratedContractType.cs
- AsyncPostBackErrorEventArgs.cs
- TraceContextRecord.cs
- CategoryNameCollection.cs
- CodeSubDirectoriesCollection.cs
- FixedSOMLineCollection.cs
- ArgumentFixer.cs
- CommandHelper.cs
- FacetDescription.cs
- ProjectionCamera.cs
- ScriptingProfileServiceSection.cs
- DataContractSerializerOperationBehavior.cs
- UnsafeMethods.cs
- MenuItem.cs
- SqlUtil.cs
- TypeReference.cs
- NumberEdit.cs
- SerializationUtility.cs
- CollectionChangedEventManager.cs
- Guid.cs
- DataViewListener.cs
- MissingMemberException.cs
- TcpClientCredentialType.cs
- DiagnosticsConfiguration.cs
- SafeLibraryHandle.cs
- RequestQueue.cs
- ConfigDefinitionUpdates.cs
- DataGridItemCollection.cs
- MaskedTextBox.cs
- PageAsyncTask.cs
- AssemblyCollection.cs
- TaskFileService.cs
- StreamingContext.cs
- WrappedReader.cs
- ProviderConnectionPoint.cs
- HttpProfileGroupBase.cs
- XAMLParseException.cs
- ColumnHeaderConverter.cs
- ObjectTag.cs
- GPRECT.cs
- CookieParameter.cs
- DataSourceHelper.cs
- DataListItemCollection.cs
- CopyNodeSetAction.cs
- GPPOINT.cs
- IApplicationTrustManager.cs
- OpacityConverter.cs
- CommandLineParser.cs
- VisualTreeHelper.cs
- Nodes.cs
- Image.cs
- WeakReferenceEnumerator.cs
- COM2ColorConverter.cs
- CollectionBuilder.cs
- MetadataArtifactLoaderResource.cs
- GridViewSelectEventArgs.cs
- MimeMultiPart.cs
- ButtonAutomationPeer.cs
- TagPrefixInfo.cs
- ItemsPresenter.cs
- RuntimeHelpers.cs
- URLMembershipCondition.cs
- WorkerProcess.cs
- DataGridState.cs
- ToolStripDropDown.cs
- Calendar.cs
- Point3DAnimation.cs
- GlyphRun.cs
- RegexStringValidatorAttribute.cs
- ObjectDataSource.cs
- AuthenticationModuleElement.cs
- Vector3DAnimationUsingKeyFrames.cs
- DataGridTextBoxColumn.cs
- ScriptControlDescriptor.cs
- DateRangeEvent.cs
- URIFormatException.cs
- filewebresponse.cs
- ListViewTableCell.cs
- DbInsertCommandTree.cs
- GridViewColumnCollectionChangedEventArgs.cs
- RootBrowserWindow.cs
- SoapMessage.cs
- MultiSelectRootGridEntry.cs
- SemanticResultKey.cs
- WebResponse.cs
- VarRemapper.cs
- FocusWithinProperty.cs