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
- Blend.cs
- BamlResourceSerializer.cs
- CaseCqlBlock.cs
- BooleanConverter.cs
- StylusButtonEventArgs.cs
- TextTreeObjectNode.cs
- GridView.cs
- InkCanvas.cs
- DataColumnSelectionConverter.cs
- CaseStatement.cs
- MemoryStream.cs
- NamedServiceModelExtensionCollectionElement.cs
- SqlTypesSchemaImporter.cs
- OrderedDictionary.cs
- EnumValidator.cs
- SymbolEqualComparer.cs
- FileAuthorizationModule.cs
- Form.cs
- __Error.cs
- WorkflowMarkupSerializationManager.cs
- TraceSection.cs
- BitmapMetadata.cs
- ClientScriptManagerWrapper.cs
- StringOutput.cs
- EntityDescriptor.cs
- SuppressMessageAttribute.cs
- RepeatButtonAutomationPeer.cs
- QilReplaceVisitor.cs
- ConfigurationPropertyAttribute.cs
- FontEmbeddingManager.cs
- ObjectStorage.cs
- MethodExpression.cs
- ResourceAssociationSet.cs
- XmlSchemaSet.cs
- PointCollectionValueSerializer.cs
- SvcMapFile.cs
- WebContext.cs
- ColumnMapCopier.cs
- DataMemberConverter.cs
- CqlQuery.cs
- ReflectionUtil.cs
- StylesEditorDialog.cs
- MatrixAnimationUsingKeyFrames.cs
- Certificate.cs
- HandleCollector.cs
- TypeUtil.cs
- WsatServiceAddress.cs
- ImageBrush.cs
- ScrollBarAutomationPeer.cs
- OracleLob.cs
- Util.cs
- InstanceDataCollectionCollection.cs
- XmlQueryOutput.cs
- Selection.cs
- BooleanConverter.cs
- ValidationErrorInfo.cs
- EventProxy.cs
- ServiceMetadataContractBehavior.cs
- Peer.cs
- ConnectionPoint.cs
- XmlName.cs
- ConnectionStringsExpressionBuilder.cs
- CachedBitmap.cs
- RegexRunner.cs
- UIElementCollection.cs
- CustomAttributeFormatException.cs
- ParagraphVisual.cs
- QilInvokeEarlyBound.cs
- MemoryPressure.cs
- Bezier.cs
- WorkflowServiceHost.cs
- HtmlControl.cs
- PropertyKey.cs
- CodeBinaryOperatorExpression.cs
- TextMetrics.cs
- StateManagedCollection.cs
- PopupEventArgs.cs
- XmlNotation.cs
- ScriptDescriptor.cs
- StringInfo.cs
- RawMouseInputReport.cs
- ListenerElementsCollection.cs
- SessionEndedEventArgs.cs
- HtmlTableRowCollection.cs
- ToolStripOverflow.cs
- DesignerTextBoxAdapter.cs
- HttpVersion.cs
- ResourceSetExpression.cs
- RawKeyboardInputReport.cs
- QilGeneratorEnv.cs
- MinMaxParagraphWidth.cs
- BigInt.cs
- CommonObjectSecurity.cs
- Pair.cs
- HtmlHead.cs
- DynamicUpdateCommand.cs
- SemanticResultValue.cs
- NullableBoolConverter.cs
- PassportAuthentication.cs
- StateFinalizationActivity.cs