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
- AtomParser.cs
- CompleteWizardStep.cs
- Convert.cs
- PathSegment.cs
- BindingEntityInfo.cs
- CatalogPartDesigner.cs
- AdapterUtil.cs
- SplitterEvent.cs
- BooleanStorage.cs
- cookiecollection.cs
- QilGenerator.cs
- SimpleApplicationHost.cs
- AdapterUtil.cs
- TextElementEnumerator.cs
- LocalIdKeyIdentifierClause.cs
- XmlSerializer.cs
- CloudCollection.cs
- DomainConstraint.cs
- TextWriterTraceListener.cs
- DbBuffer.cs
- Typography.cs
- EntityDataSourceDataSelectionPanel.cs
- LinearGradientBrush.cs
- MergePropertyDescriptor.cs
- BaseValidator.cs
- CommandEventArgs.cs
- PageCache.cs
- NativeMethods.cs
- InvalidProgramException.cs
- ToolStripDropDownClosedEventArgs.cs
- HeaderPanel.cs
- KoreanCalendar.cs
- FilterQuery.cs
- EventOpcode.cs
- dataprotectionpermission.cs
- Int32CAMarshaler.cs
- EncryptedPackageFilter.cs
- ASCIIEncoding.cs
- TypeLibConverter.cs
- MsmqReceiveParameters.cs
- TargetControlTypeCache.cs
- ShaperBuffers.cs
- QueryActivatableWorkflowsCommand.cs
- PerformanceCounterPermissionEntryCollection.cs
- BindingMemberInfo.cs
- SessionStateUtil.cs
- DataGridViewCellValidatingEventArgs.cs
- BrowsableAttribute.cs
- AsyncPostBackErrorEventArgs.cs
- PropertyMetadata.cs
- ThreadPool.cs
- Boolean.cs
- MetafileHeader.cs
- ButtonBaseAutomationPeer.cs
- DataRecord.cs
- DiscoveryVersion.cs
- WmpBitmapEncoder.cs
- FilteredDataSetHelper.cs
- IgnoreFlushAndCloseStream.cs
- RoutedEvent.cs
- columnmapkeybuilder.cs
- BuilderElements.cs
- MatrixTransform3D.cs
- FormViewRow.cs
- XmlSecureResolver.cs
- MultiDataTrigger.cs
- UpDownEvent.cs
- DataBindingExpressionBuilder.cs
- HttpContext.cs
- smtpconnection.cs
- ErasingStroke.cs
- ComplexBindingPropertiesAttribute.cs
- HttpCookieCollection.cs
- IDispatchConstantAttribute.cs
- HttpPostedFileBase.cs
- MsmqSecureHashAlgorithm.cs
- SystemResourceHost.cs
- TextDecorationUnitValidation.cs
- EntityStoreSchemaFilterEntry.cs
- ClassGenerator.cs
- GroupItem.cs
- WebPartEditorApplyVerb.cs
- XPathSelectionIterator.cs
- ContextStack.cs
- objectresult_tresulttype.cs
- ObjectAnimationUsingKeyFrames.cs
- DocumentSchemaValidator.cs
- Rectangle.cs
- ListViewInsertEventArgs.cs
- XmlValidatingReader.cs
- CodeStatement.cs
- _NestedSingleAsyncResult.cs
- WsatServiceAddress.cs
- OneToOneMappingSerializer.cs
- NavigatorInput.cs
- RuntimeResourceSet.cs
- ProtocolsConfigurationHandler.cs
- SpeakInfo.cs
- DataGridColumnHeadersPresenter.cs
- SoapExtensionReflector.cs