Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- WorkerRequest.cs
- PermissionSetTriple.cs
- ObsoleteAttribute.cs
- SystemIPAddressInformation.cs
- TableAdapterManagerHelper.cs
- SqlBuffer.cs
- ProcessProtocolHandler.cs
- QueryCacheEntry.cs
- XmlQueryOutput.cs
- Error.cs
- WindowsToolbar.cs
- HtmlButton.cs
- EDesignUtil.cs
- Group.cs
- ExecutedRoutedEventArgs.cs
- ConfigXmlAttribute.cs
- ConfigPathUtility.cs
- XPathDocumentBuilder.cs
- NotConverter.cs
- SmtpAuthenticationManager.cs
- WebSysDefaultValueAttribute.cs
- DataTableReader.cs
- NativeCompoundFileAPIs.cs
- QualifiedCellIdBoolean.cs
- XmlException.cs
- FormsAuthenticationModule.cs
- Types.cs
- ControlUtil.cs
- LinkClickEvent.cs
- PropertyGroupDescription.cs
- COM2ExtendedTypeConverter.cs
- UpdateCommand.cs
- hresults.cs
- StylusPointPropertyUnit.cs
- DataGridPagerStyle.cs
- PackageFilter.cs
- CallbackValidatorAttribute.cs
- Rijndael.cs
- EventLogTraceListener.cs
- VirtualizedItemPattern.cs
- WebHttpElement.cs
- TypedRowHandler.cs
- SQLResource.cs
- StylusCollection.cs
- ListView.cs
- DataGridState.cs
- ElementMarkupObject.cs
- BinaryReader.cs
- WorkflowIdleBehavior.cs
- RuntimeConfig.cs
- ResourceDefaultValueAttribute.cs
- ItemCheckedEvent.cs
- LabelAutomationPeer.cs
- SqlNamer.cs
- ObjectDataSourceChooseTypePanel.cs
- TextBlockAutomationPeer.cs
- HwndKeyboardInputProvider.cs
- ContainerActivationHelper.cs
- DataSourceComponent.cs
- ImmutableCollection.cs
- IRCollection.cs
- COM2TypeInfoProcessor.cs
- HttpHandlersSection.cs
- MarginCollapsingState.cs
- HtmlHistory.cs
- Graph.cs
- ListItemParagraph.cs
- BrowserDefinition.cs
- UrlPath.cs
- ImageSource.cs
- DomainConstraint.cs
- OlePropertyStructs.cs
- ArrayHelper.cs
- ClientBase.cs
- filewebresponse.cs
- OutputWindow.cs
- LineSegment.cs
- PersonalizableAttribute.cs
- CfgParser.cs
- ArraySortHelper.cs
- ExceptionValidationRule.cs
- DynamicMetaObjectBinder.cs
- ValuePattern.cs
- KeyGestureValueSerializer.cs
- ComponentSerializationService.cs
- StylusEditingBehavior.cs
- DataKeyPropertyAttribute.cs
- PartManifestEntry.cs
- DictionaryEntry.cs
- DBNull.cs
- Binding.cs
- _Win32.cs
- QilNode.cs
- Currency.cs
- BitStack.cs
- TypeInfo.cs
- assemblycache.cs
- ArrayList.cs
- KeyInterop.cs
- MsmqOutputChannel.cs