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
- AffineTransform3D.cs
- MemberBinding.cs
- DrawingCollection.cs
- SrgsElementFactoryCompiler.cs
- PeerDuplexChannelListener.cs
- BufferedStream.cs
- Function.cs
- IERequestCache.cs
- Brush.cs
- XslNumber.cs
- PerfService.cs
- Char.cs
- ContextMenuService.cs
- LinqTreeNodeEvaluator.cs
- HttpContext.cs
- storepermissionattribute.cs
- CookieParameter.cs
- HMACSHA1.cs
- EncryptedReference.cs
- BitmapPalettes.cs
- AnimationClockResource.cs
- DefaultAssemblyResolver.cs
- MessageBuilder.cs
- TemplateKeyConverter.cs
- XmlSchemaSimpleContentExtension.cs
- BamlRecordHelper.cs
- AssemblyCollection.cs
- XmlArrayItemAttribute.cs
- EntityDataSourceSelectingEventArgs.cs
- EncoderNLS.cs
- _LazyAsyncResult.cs
- CultureInfo.cs
- LocatorPartList.cs
- DataServiceQuery.cs
- HttpGetProtocolImporter.cs
- MergePropertyDescriptor.cs
- VSWCFServiceContractGenerator.cs
- Point3DAnimationUsingKeyFrames.cs
- WebPartTransformer.cs
- DataGridGeneralPage.cs
- MultiAsyncResult.cs
- ADMembershipUser.cs
- RegexRunnerFactory.cs
- CollectionBase.cs
- MailMessage.cs
- SiteMapHierarchicalDataSourceView.cs
- WSHttpBindingBaseElement.cs
- CqlWriter.cs
- RecordManager.cs
- SafePEFileHandle.cs
- Registration.cs
- RotateTransform3D.cs
- ValidationResult.cs
- ClientSettingsSection.cs
- OdbcConnectionStringbuilder.cs
- DataRowView.cs
- StateFinalizationActivity.cs
- XmlSchemaExporter.cs
- XmlSchemaElement.cs
- ZipIOFileItemStream.cs
- Currency.cs
- WebBrowserNavigatingEventHandler.cs
- Empty.cs
- HyperLinkColumn.cs
- BindingsSection.cs
- SafeMILHandle.cs
- WindowsTitleBar.cs
- XmlSchemaSubstitutionGroup.cs
- PageRequestManager.cs
- ServiceContractGenerator.cs
- ToolStripContainer.cs
- HtmlHistory.cs
- SvcMapFile.cs
- EntityClassGenerator.cs
- Pen.cs
- XmlTextReaderImplHelpers.cs
- EditingMode.cs
- HuffCodec.cs
- SlipBehavior.cs
- XmlHierarchicalEnumerable.cs
- Timeline.cs
- DataListCommandEventArgs.cs
- TextEndOfSegment.cs
- MemoryMappedView.cs
- ViewStateException.cs
- HttpSysSettings.cs
- MatrixKeyFrameCollection.cs
- Rules.cs
- Debugger.cs
- ApplicationSecurityInfo.cs
- ReadOnlyDictionary.cs
- NativeStructs.cs
- ValueTable.cs
- PanelDesigner.cs
- PriorityBinding.cs
- DigitShape.cs
- Stacktrace.cs
- ObjectViewQueryResultData.cs
- XamlFilter.cs
- SqlTrackingWorkflowInstance.cs