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
- ClientOptions.cs
- BoundField.cs
- ElementFactory.cs
- WebServiceHost.cs
- MultiSelectRootGridEntry.cs
- FaultReason.cs
- WebPartZoneDesigner.cs
- RequestStatusBarUpdateEventArgs.cs
- StyleSheetComponentEditor.cs
- AccessText.cs
- ErrorProvider.cs
- While.cs
- Mappings.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ProvideValueServiceProvider.cs
- LineServicesRun.cs
- SqlDataSourceQuery.cs
- XmlHierarchicalEnumerable.cs
- HttpWriter.cs
- PackWebRequestFactory.cs
- ToolStripDropDown.cs
- ClosableStream.cs
- CodeRemoveEventStatement.cs
- DataContext.cs
- CustomTypeDescriptor.cs
- smtpconnection.cs
- DataGridViewRowsRemovedEventArgs.cs
- XmlExtensionFunction.cs
- HostingPreferredMapPath.cs
- RadioButtonList.cs
- HostingEnvironmentSection.cs
- CharUnicodeInfo.cs
- BamlWriter.cs
- CaseDesigner.xaml.cs
- TransactionManager.cs
- XmlUtf8RawTextWriter.cs
- DataGridViewComboBoxColumnDesigner.cs
- ApplicationId.cs
- DynamicRenderer.cs
- ConnectionManagementElementCollection.cs
- MeasureItemEvent.cs
- RtfFormatStack.cs
- UnsafeNativeMethods.cs
- PageSettings.cs
- Marshal.cs
- AttributeAction.cs
- SwitchCase.cs
- UnionCodeGroup.cs
- URLMembershipCondition.cs
- Translator.cs
- _CommandStream.cs
- HashMembershipCondition.cs
- RegexRunner.cs
- PointCollection.cs
- DeviceContext2.cs
- UnsafeNativeMethods.cs
- Rfc2898DeriveBytes.cs
- Vector3D.cs
- QueryUtil.cs
- Utility.cs
- ProfileProvider.cs
- WindowsFormsHost.cs
- EntityDesignerUtils.cs
- EmptyStringExpandableObjectConverter.cs
- BaseValidator.cs
- PackUriHelper.cs
- PermissionSetTriple.cs
- ForEachDesigner.xaml.cs
- Stroke2.cs
- StandardCommands.cs
- CalendarDesigner.cs
- WsatTransactionInfo.cs
- MgmtConfigurationRecord.cs
- FaultReasonText.cs
- StringTraceRecord.cs
- ClientBuildManager.cs
- ScriptMethodAttribute.cs
- XmlSyndicationContent.cs
- ConfigurationPermission.cs
- BooleanProjectedSlot.cs
- ByteStreamGeometryContext.cs
- CodeRemoveEventStatement.cs
- ResourceContainer.cs
- ItemAutomationPeer.cs
- ResolvedKeyFrameEntry.cs
- StrongNameIdentityPermission.cs
- TextureBrush.cs
- TreeView.cs
- RecognizedWordUnit.cs
- WindowsTreeView.cs
- DataBoundControlAdapter.cs
- TypeBuilderInstantiation.cs
- CodeIdentifier.cs
- ObfuscateAssemblyAttribute.cs
- ZipIOModeEnforcingStream.cs
- TextSchema.cs
- AttachedAnnotationChangedEventArgs.cs
- WebRequestModulesSection.cs
- PostBackOptions.cs