Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / Generic / ICollection.cs / 1305376 / ICollection.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Interface: ICollection ** **[....] ** ** ** Purpose: Base interface for all generic collections. ** ** ===========================================================*/ namespace System.Collections.Generic { using System; using System.Runtime.CompilerServices; using System.Diagnostics.Contracts; // Base interface for all collections, defining enumerators, size, and // synchronization methods. // Note that T[] : IList, and we want to ensure that if you use // IList , we ensure a YourValueType[] can be used // without jitting. Hence the TypeDependencyAttribute on SZArrayHelper. // This is a special hack internally though - see VM\compile.cpp. // The same attribute is on IEnumerable and ICollection . [ContractClass(typeof(ICollectionContract<>))] [TypeDependencyAttribute("System.SZArrayHelper")] public interface ICollection : IEnumerable { // Number of items in the collections. int Count { get; } bool IsReadOnly { get; } void Add(T item); void Clear(); bool Contains(T item); // CopyTo copies a collection into an Array, starting at a particular // index into the array. // void CopyTo(T[] array, int arrayIndex); //void CopyTo(int sourceIndex, T[] destinationArray, int destinationIndex, int count); bool Remove(T item); } [ContractClassFor(typeof(ICollection<>))] internal class ICollectionContract : ICollection { int ICollection .Count { get { Contract.Ensures(Contract.Result () >= 0); return default(int); } } bool ICollection .IsReadOnly { get { return default(bool); } } void ICollection .Add(T item) { //Contract.Ensures(((ICollection )this).Count == Contract.OldValue(((ICollection )this).Count) + 1); // not threadsafe } void ICollection .Clear() { } bool ICollection .Contains(T item) { return default(bool); } void ICollection .CopyTo(T[] array, int arrayIndex) { } bool ICollection .Remove(T item) { return default(bool); } IEnumerator IEnumerable .GetEnumerator() { Contract.Ensures(Contract.Result >() != null); return default(IEnumerator ); } IEnumerator IEnumerable.GetEnumerator() { Contract.Ensures(Contract.Result () != null); return default(IEnumerator); } } } // 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
- IsolatedStorageFileStream.cs
- categoryentry.cs
- StaticFileHandler.cs
- CompilerCollection.cs
- ListSourceHelper.cs
- FilteredAttributeCollection.cs
- DataAdapter.cs
- CodeVariableReferenceExpression.cs
- SqlConnection.cs
- ProgressBar.cs
- ReachPrintTicketSerializerAsync.cs
- RegexGroupCollection.cs
- ScalarConstant.cs
- CryptoApi.cs
- _Events.cs
- XmlPreloadedResolver.cs
- ObjectDataSourceSelectingEventArgs.cs
- SymmetricAlgorithm.cs
- TagMapInfo.cs
- ModifiableIteratorCollection.cs
- XComponentModel.cs
- LiteralControl.cs
- ObjectDataSourceFilteringEventArgs.cs
- TypefaceMap.cs
- odbcmetadatacolumnnames.cs
- ApplicationDirectory.cs
- CriticalFinalizerObject.cs
- HelpKeywordAttribute.cs
- SQLDateTimeStorage.cs
- DCSafeHandle.cs
- SubclassTypeValidator.cs
- compensatingcollection.cs
- TransformerInfoCollection.cs
- LiteralLink.cs
- List.cs
- InternalConfigEventArgs.cs
- TextViewSelectionProcessor.cs
- MemberCollection.cs
- Material.cs
- CodeDelegateInvokeExpression.cs
- IisTraceListener.cs
- ClientSettingsStore.cs
- DebugHandleTracker.cs
- ISCIIEncoding.cs
- _LocalDataStore.cs
- TextTreeInsertElementUndoUnit.cs
- SignatureDescription.cs
- XmlSchemaObjectTable.cs
- ScrollViewerAutomationPeer.cs
- PTConverter.cs
- Columns.cs
- Message.cs
- Effect.cs
- BorderSidesEditor.cs
- TemplateControlBuildProvider.cs
- FolderNameEditor.cs
- DocumentPaginator.cs
- AutomationPropertyInfo.cs
- TableStyle.cs
- Logging.cs
- XmlComment.cs
- XmlCountingReader.cs
- AnnotationStore.cs
- LinkDescriptor.cs
- CodeDomSerializationProvider.cs
- OdbcHandle.cs
- XmlSchemaAnyAttribute.cs
- StringSource.cs
- hebrewshape.cs
- GenericTextProperties.cs
- ObservableCollection.cs
- URL.cs
- WSSecureConversationFeb2005.cs
- xmlglyphRunInfo.cs
- SafeNativeMethods.cs
- InternalTypeHelper.cs
- OracleBoolean.cs
- InteropTrackingRecord.cs
- SchemaSetCompiler.cs
- bidPrivateBase.cs
- WebMessageEncoderFactory.cs
- FontInfo.cs
- AttachedPropertyBrowsableAttribute.cs
- CorrelationHandle.cs
- SequentialUshortCollection.cs
- CommunicationObjectFaultedException.cs
- EarlyBoundInfo.cs
- ExpandCollapsePattern.cs
- SuppressIldasmAttribute.cs
- BindingContext.cs
- TreeNodeCollectionEditor.cs
- UrlUtility.cs
- ContractNamespaceAttribute.cs
- cache.cs
- BooleanStorage.cs
- SqlExpander.cs
- GenericUriParser.cs
- BehaviorEditorPart.cs
- EntityDataSourceContextCreatingEventArgs.cs
- SystemWebCachingSectionGroup.cs