Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Common / Utils / DisposableCollectionWrapper.cs / 1 / 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()
{
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()
{
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
- BigInt.cs
- ViewManager.cs
- SqlUnionizer.cs
- IpcClientChannel.cs
- RuntimeConfigLKG.cs
- _DisconnectOverlappedAsyncResult.cs
- LocatorPartList.cs
- InternalSafeNativeMethods.cs
- Bitmap.cs
- MediaCommands.cs
- KoreanLunisolarCalendar.cs
- TransactionTable.cs
- StrokeFIndices.cs
- DynamicMethod.cs
- GlyphRun.cs
- XmlNodeWriter.cs
- BinaryMessageFormatter.cs
- AlphabeticalEnumConverter.cs
- MultipartContentParser.cs
- UrlMappingCollection.cs
- AppDomainProtocolHandler.cs
- Type.cs
- SqlConnectionPoolGroupProviderInfo.cs
- XPathEmptyIterator.cs
- UInt16Converter.cs
- WhileDesigner.xaml.cs
- CompositeDataBoundControl.cs
- AnnouncementSendsAsyncResult.cs
- MgmtConfigurationRecord.cs
- ContextMenuAutomationPeer.cs
- PropertyEntry.cs
- ResourceExpression.cs
- ParallelTimeline.cs
- LocalTransaction.cs
- DbTransaction.cs
- DbDataRecord.cs
- DrawingBrush.cs
- ToolStripContainerDesigner.cs
- TabControlCancelEvent.cs
- CustomAttributeBuilder.cs
- RewritingSimplifier.cs
- Thread.cs
- SqlLiftWhereClauses.cs
- PublisherMembershipCondition.cs
- AuthenticateEventArgs.cs
- HttpChannelHelpers.cs
- EntityCommand.cs
- ImageMapEventArgs.cs
- MimeBasePart.cs
- DataGridCell.cs
- ComponentDispatcherThread.cs
- CompiledQueryCacheKey.cs
- NotImplementedException.cs
- ProxyAttribute.cs
- TransformConverter.cs
- UnicastIPAddressInformationCollection.cs
- MappingMetadataHelper.cs
- SafeNativeMethods.cs
- XsltSettings.cs
- PieceDirectory.cs
- BindingExpressionBase.cs
- BaseParser.cs
- TimelineCollection.cs
- CompilerLocalReference.cs
- SoapEnumAttribute.cs
- DesignerCapabilities.cs
- CriticalExceptions.cs
- HttpVersion.cs
- Size3D.cs
- RightsManagementEncryptedStream.cs
- DynamicFilter.cs
- PermissionSetTriple.cs
- Pair.cs
- Baml2006SchemaContext.cs
- FamilyTypefaceCollection.cs
- BinHexEncoding.cs
- _TLSstream.cs
- KeyedCollection.cs
- ToolStripSystemRenderer.cs
- PasswordDeriveBytes.cs
- WaitHandle.cs
- WebPartConnectionsCancelEventArgs.cs
- TabPageDesigner.cs
- NativeMethods.cs
- ProgressBarHighlightConverter.cs
- RenamedEventArgs.cs
- XmlWrappingReader.cs
- EntityParameterCollection.cs
- IResourceProvider.cs
- GroupBox.cs
- HtmlElementCollection.cs
- LicenseException.cs
- BuildManager.cs
- NullRuntimeConfig.cs
- IDispatchConstantAttribute.cs
- BevelBitmapEffect.cs
- AdornerPresentationContext.cs
- PropertyPathWorker.cs
- ServiceOperation.cs
- Border.cs