EnumerableEx.Using<TSource, TResource> Method |
Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage duration.
Namespace: System.LinqAssembly: System.Interactive (in System.Interactive.dll) Version: 1.2.0.0
Syntaxpublic static IEnumerable<TSource> Using<TSource, TResource>(
Func<TResource> resourceFactory,
Func<TResource, IEnumerable<TSource>> enumerableFactory
)
where TResource : IDisposable
Parameters
- resourceFactory
- Type: System.Func<TResource>
Resource factory function. - enumerableFactory
- Type: System.Func<TResource, IEnumerable<TSource>>
Enumerable factory function, having access to the obtained resource.
Type Parameters
- TSource
- Source element type.
- TResource
- Resource type.
Return Value
Type:
IEnumerable<TSource>Sequence whose use controls the lifetime of the associated obtained resource.
See Also