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
- ResourcePermissionBase.cs
- Native.cs
- ProvidersHelper.cs
- MediaContextNotificationWindow.cs
- HttpVersion.cs
- __FastResourceComparer.cs
- HealthMonitoringSection.cs
- TransportReplyChannelAcceptor.cs
- AxHost.cs
- TypeExtension.cs
- IteratorFilter.cs
- safelink.cs
- OneOfConst.cs
- DrawingContextDrawingContextWalker.cs
- ControlEvent.cs
- NativeRecognizer.cs
- DocumentAutomationPeer.cs
- ClientRoleProvider.cs
- CompensatableTransactionScopeActivity.cs
- Timer.cs
- SystemResourceKey.cs
- SafeProcessHandle.cs
- BaseParaClient.cs
- FormViewAutoFormat.cs
- ServiceKnownTypeAttribute.cs
- FieldAccessException.cs
- ScrollEventArgs.cs
- PartialCachingControl.cs
- Rect3DConverter.cs
- XmlSchemaSimpleContentRestriction.cs
- ComponentDispatcher.cs
- SocketStream.cs
- OleDbWrapper.cs
- UseLicense.cs
- ReadOnlyCollection.cs
- ConfigurationFileMap.cs
- DocumentProperties.cs
- XmlReader.cs
- WebServiceData.cs
- BindingMAnagerBase.cs
- RequestTimeoutManager.cs
- XmlElementAttributes.cs
- ComPlusInstanceProvider.cs
- ResourceReferenceExpressionConverter.cs
- SchemaImporterExtensionElement.cs
- MultiDataTrigger.cs
- RepeatInfo.cs
- DataGridViewCellStyle.cs
- Rijndael.cs
- securestring.cs
- SmtpReplyReader.cs
- Triangle.cs
- ToolStripRendererSwitcher.cs
- SqlMethodTransformer.cs
- TextTreeRootNode.cs
- ListChangedEventArgs.cs
- SqlCommandSet.cs
- ReverseInheritProperty.cs
- CellQuery.cs
- MappedMetaModel.cs
- HotSpotCollection.cs
- UniformGrid.cs
- PenThread.cs
- ListViewDataItem.cs
- Random.cs
- SortQuery.cs
- DragDropManager.cs
- BaseTemplateBuildProvider.cs
- DurableEnlistmentState.cs
- ADRoleFactoryConfiguration.cs
- Camera.cs
- TrackingStringDictionary.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- ResourceKey.cs
- CompilationLock.cs
- GraphicsPathIterator.cs
- BCLDebug.cs
- HttpRawResponse.cs
- WindowsListViewScroll.cs
- GradientBrush.cs
- UIElement.cs
- XXXInfos.cs
- FragmentQueryProcessor.cs
- DataGridColumnCollectionEditor.cs
- SortQueryOperator.cs
- RangeBase.cs
- DependencyPropertyKind.cs
- Mutex.cs
- ObjectQueryProvider.cs
- TransformValueSerializer.cs
- ContentHostHelper.cs
- QuotedPrintableStream.cs
- DiscoveryReference.cs
- XmlUrlEditor.cs
- FillRuleValidation.cs
- MenuEventArgs.cs
- WindowsStatic.cs
- SerializationFieldInfo.cs
- TemplatePropertyEntry.cs
- SqlPersonalizationProvider.cs