Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / Utils / DisposableCollectionWrapper.cs / 1305376 / DisposableCollectionWrapper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace System.Data.Common.Utils { internal class DisposableCollectionWrapper: IDisposable, IEnumerable where T : IDisposable { IEnumerable _enumerable; internal DisposableCollectionWrapper(IEnumerable enumerable) { Debug.Assert(enumerable != null, "don't pass in a null enumerable"); _enumerable = enumerable; } public void Dispose() { // Technically, calling GC.SuppressFinalize is not required because the class does not // have a finalizer, but it does no harm, protects against the case where a finalizer is added // in the future, and prevents an FxCop warning. GC.SuppressFinalize(this); if(_enumerable != null) { foreach(T item in _enumerable) { if(item != null) { item.Dispose(); } } } } public IEnumerator GetEnumerator() { return _enumerable.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return ((System.Collections.IEnumerable)_enumerable).GetEnumerator(); } } } // 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
- WebPartTransformerCollection.cs
- KnownTypesHelper.cs
- ExpressionNormalizer.cs
- IntegerValidatorAttribute.cs
- CodeBlockBuilder.cs
- MenuAutomationPeer.cs
- IDReferencePropertyAttribute.cs
- UserNamePasswordValidator.cs
- DataGridItemCollection.cs
- PrimitiveXmlSerializers.cs
- XmlReader.cs
- ServiceContractDetailViewControl.cs
- DataKeyCollection.cs
- BitConverter.cs
- ReservationNotFoundException.cs
- XdrBuilder.cs
- CaseInsensitiveHashCodeProvider.cs
- WorkflowLayouts.cs
- Utils.cs
- WebPartTransformerAttribute.cs
- WindowsScrollBarBits.cs
- coordinatorscratchpad.cs
- BufferedGraphicsManager.cs
- PixelFormat.cs
- PrtCap_Base.cs
- BlurBitmapEffect.cs
- VectorCollectionConverter.cs
- FilterableAttribute.cs
- DebugInfoGenerator.cs
- LayoutSettings.cs
- FixedSchema.cs
- XmlNode.cs
- EmissiveMaterial.cs
- OLEDB_Enum.cs
- LineGeometry.cs
- PassportAuthenticationModule.cs
- SpecialTypeDataContract.cs
- XmlNullResolver.cs
- TempFiles.cs
- SapiGrammar.cs
- RegionInfo.cs
- DataView.cs
- NotificationContext.cs
- DBPropSet.cs
- ControlBindingsCollection.cs
- ToolboxItemAttribute.cs
- FixedDocumentPaginator.cs
- StorageFunctionMapping.cs
- CapabilitiesPattern.cs
- EventDescriptor.cs
- ValidatingPropertiesEventArgs.cs
- NativeMethods.cs
- SchemaImporter.cs
- ResourceType.cs
- XmlNodeReader.cs
- ResourceType.cs
- TreeView.cs
- SamlDoNotCacheCondition.cs
- PersonalizationStateInfoCollection.cs
- SecurityElement.cs
- HostedHttpRequestAsyncResult.cs
- SkipQueryOptionExpression.cs
- StatementContext.cs
- XmlParserContext.cs
- ApplicationDirectory.cs
- HandlerBase.cs
- NamedPipeTransportSecurity.cs
- SiteMapPath.cs
- IndexerNameAttribute.cs
- Header.cs
- DataGridRow.cs
- Proxy.cs
- ISAPIRuntime.cs
- AttributeQuery.cs
- dbdatarecord.cs
- FontSourceCollection.cs
- StackSpiller.Temps.cs
- BamlMapTable.cs
- SHA512Managed.cs
- DirectoryObjectSecurity.cs
- ObjectRef.cs
- SecurityChannel.cs
- GetBrowserTokenRequest.cs
- QueryOpcode.cs
- ConstraintEnumerator.cs
- Animatable.cs
- TransformerTypeCollection.cs
- BaseUriHelper.cs
- MetadataWorkspace.cs
- RelativeSource.cs
- ListContractAdapter.cs
- DesignBindingPropertyDescriptor.cs
- PointIndependentAnimationStorage.cs
- RectangleHotSpot.cs
- MultiBinding.cs
- WebPartConnectionsDisconnectVerb.cs
- EngineSite.cs
- SoapMessage.cs
- IgnoreFileBuildProvider.cs
- MsmqVerifier.cs