Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / ObjectModel / ReadOnlyCollection.cs / 1305376 / ReadOnlyCollection.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //[....] // namespace System.Collections.ObjectModel { using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Runtime; [Serializable] [System.Runtime.InteropServices.ComVisible(false)] [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] public class ReadOnlyCollection: IList , IList { IList list; [NonSerialized] private Object _syncRoot; public ReadOnlyCollection(IList list) { if (list == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list); } this.list = list; } public int Count { #if !FEATURE_CORECLR [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] #endif get { return list.Count; } } public T this[int index] { #if !FEATURE_CORECLR [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] #endif get { return list[index]; } } #if !FEATURE_CORECLR [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] #endif public bool Contains(T value) { return list.Contains(value); } public void CopyTo(T[] array, int index) { list.CopyTo(array, index); } #if !FEATURE_CORECLR [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] #endif public IEnumerator GetEnumerator() { return list.GetEnumerator(); } public int IndexOf(T value) { return list.IndexOf(value); } protected IList Items { get { return list; } } bool ICollection .IsReadOnly { get { return true; } } T IList .this[int index] { get { return list[index]; } set { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } } void ICollection .Add(T value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } void ICollection .Clear() { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } void IList .Insert(int index, T value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } bool ICollection .Remove(T value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); return false; } void IList .RemoveAt(int index) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)list).GetEnumerator(); } bool ICollection.IsSynchronized { get { return false; } } object ICollection.SyncRoot { get { if( _syncRoot == null) { ICollection c = list as ICollection; if( c != null) { _syncRoot = c.SyncRoot; } else { System.Threading.Interlocked.CompareExchange
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BamlLocalizerErrorNotifyEventArgs.cs
- IgnoreFileBuildProvider.cs
- OdbcCommand.cs
- GridViewUpdatedEventArgs.cs
- MembershipValidatePasswordEventArgs.cs
- SHA384Managed.cs
- TextDecorationCollectionConverter.cs
- VirtualDirectoryMappingCollection.cs
- DispatcherExceptionEventArgs.cs
- Pkcs7Recipient.cs
- BasicExpressionVisitor.cs
- QueryContinueDragEvent.cs
- SamlDoNotCacheCondition.cs
- Image.cs
- TimelineGroup.cs
- PropertyMetadata.cs
- DesignerActionGlyph.cs
- OperationContextScope.cs
- RegistrationServices.cs
- ObjectDataSource.cs
- LinkConverter.cs
- ConfigXmlCDataSection.cs
- DecimalAnimation.cs
- DisplayInformation.cs
- pingexception.cs
- CollectionDataContractAttribute.cs
- TableProviderWrapper.cs
- AnnotationResourceChangedEventArgs.cs
- XsdValidatingReader.cs
- UInt64Converter.cs
- AutomationPeer.cs
- RewritingProcessor.cs
- AccessDataSource.cs
- UndirectedGraph.cs
- ExtensionWindowResizeGrip.cs
- InkCanvasAutomationPeer.cs
- ClickablePoint.cs
- ProviderIncompatibleException.cs
- WorkflowQueuingService.cs
- CodeVariableReferenceExpression.cs
- ErrorFormatterPage.cs
- VBIdentifierDesigner.xaml.cs
- Condition.cs
- X509Certificate2.cs
- XmlNodeComparer.cs
- EncoderParameters.cs
- DateTimeFormatInfoScanner.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- SessionViewState.cs
- TableCell.cs
- BinHexEncoding.cs
- HtmlSelect.cs
- Decoder.cs
- EditorBrowsableAttribute.cs
- COM2TypeInfoProcessor.cs
- MaskedTextBoxDesignerActionList.cs
- X500Name.cs
- WindowsSolidBrush.cs
- SourceItem.cs
- XmlSchemaGroup.cs
- Closure.cs
- SoapFormatExtensions.cs
- SystemIPGlobalStatistics.cs
- RuntimeHelpers.cs
- EncodingStreamWrapper.cs
- Win32.cs
- DispatcherHookEventArgs.cs
- UpDownBase.cs
- SQLGuid.cs
- SafeLocalAllocation.cs
- TimestampInformation.cs
- RowType.cs
- NumericUpDown.cs
- AnimatedTypeHelpers.cs
- StsCommunicationException.cs
- Win32.cs
- AxParameterData.cs
- SqlNodeTypeOperators.cs
- DateTimeConstantAttribute.cs
- Point3DConverter.cs
- RegexStringValidatorAttribute.cs
- XPathMessageFilterElementComparer.cs
- InfiniteTimeSpanConverter.cs
- SolidBrush.cs
- RijndaelManaged.cs
- BitmapFrameEncode.cs
- DynamicMethod.cs
- PerfProviderCollection.cs
- DataGridViewDataConnection.cs
- COM2PictureConverter.cs
- ScrollEventArgs.cs
- XXXOnTypeBuilderInstantiation.cs
- HtmlElementEventArgs.cs
- RoutedPropertyChangedEventArgs.cs
- XpsDocument.cs
- ProcessHostConfigUtils.cs
- CssClassPropertyAttribute.cs
- PackageStore.cs
- MSAANativeProvider.cs
- BooleanToVisibilityConverter.cs