Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ // // 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
- _AutoWebProxyScriptHelper.cs
- EntityContainer.cs
- Win32Native.cs
- OleDbDataAdapter.cs
- HostingEnvironmentSection.cs
- ComponentDispatcher.cs
- FlowDocumentScrollViewer.cs
- ToolStripSplitStackLayout.cs
- FlowPosition.cs
- ToolStripOverflowButton.cs
- DBSqlParserTable.cs
- DataGridViewRowsAddedEventArgs.cs
- Cell.cs
- RegexGroup.cs
- AuthenticationServiceManager.cs
- IsolatedStorageException.cs
- XsdValidatingReader.cs
- WindowsPrincipal.cs
- DbFunctionCommandTree.cs
- GPStream.cs
- DependencyPropertyKey.cs
- BeginEvent.cs
- EventNotify.cs
- ContainerParaClient.cs
- MessageDispatch.cs
- CheckBoxField.cs
- ThrowHelper.cs
- StateDesigner.LayoutSelectionGlyph.cs
- UdpMessageProperty.cs
- SmtpMail.cs
- WebPartConnectionsCloseVerb.cs
- DbResourceAllocator.cs
- RawContentTypeMapper.cs
- EmbeddedMailObjectsCollection.cs
- StylusPlugin.cs
- ClientUriBehavior.cs
- PolygonHotSpot.cs
- SessionStateSection.cs
- JavaScriptSerializer.cs
- IISMapPath.cs
- srgsitem.cs
- StreamSecurityUpgradeAcceptor.cs
- OdbcDataAdapter.cs
- ScrollData.cs
- ArrayConverter.cs
- AssociationTypeEmitter.cs
- ToolStripContentPanel.cs
- DbException.cs
- SplayTreeNode.cs
- Bidi.cs
- CommandTreeTypeHelper.cs
- PrimitiveType.cs
- JsonDeserializer.cs
- TextOptions.cs
- XmlTypeMapping.cs
- ChtmlSelectionListAdapter.cs
- DiagnosticsConfiguration.cs
- WebReferenceCollection.cs
- TrackingProfileSerializer.cs
- ParallelTimeline.cs
- MenuEventArgs.cs
- WebPartActionVerb.cs
- SafeReadContext.cs
- NullableIntSumAggregationOperator.cs
- Point4DConverter.cs
- PointAnimationBase.cs
- DataGridViewColumnConverter.cs
- BufferedOutputStream.cs
- CheckableControlBaseAdapter.cs
- DurableEnlistmentState.cs
- XmlWriter.cs
- PkcsMisc.cs
- CqlIdentifiers.cs
- DataGridViewDataConnection.cs
- XmlSchemaObject.cs
- ViewKeyConstraint.cs
- CommentAction.cs
- Query.cs
- ByteAnimationBase.cs
- VersionPair.cs
- ArgumentNullException.cs
- Setter.cs
- CharacterBuffer.cs
- MembershipValidatePasswordEventArgs.cs
- TreeNodeEventArgs.cs
- Span.cs
- BitStack.cs
- ToolStripDropDownMenu.cs
- TripleDES.cs
- FixedDocumentPaginator.cs
- SignedPkcs7.cs
- FormViewRow.cs
- XmlResolver.cs
- HttpCapabilitiesEvaluator.cs
- HttpContextBase.cs
- FieldDescriptor.cs
- MimePart.cs
- TransactionalPackage.cs
- SamlNameIdentifierClaimResource.cs
- PatternMatcher.cs