Skip to content

Commit

Permalink
Normalize all the line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Aug 21, 2015
1 parent f71b8ef commit d69465d
Show file tree
Hide file tree
Showing 227 changed files with 12,799 additions and 12,782 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
190 changes: 95 additions & 95 deletions MoreLinq.sln
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{835F8FFA-471F-4322-B721-A897F27872FA}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
buildw.cmd = buildw.cmd
COPYING.txt = COPYING.txt
pkg\morelinq.nuspec = pkg\morelinq.nuspec
pack.cmd = pack.cmd
packw.cmd = packw.cmd
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq", "MoreLinq\MoreLinq.csproj", "{8642E81B-3414-4C13-914F-05A4E600FE49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Test", "MoreLinq.Test\MoreLinq.Test.csproj", "{D89B7AF5-7615-47B7-B894-A722E66DB3D8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuspecs", "Nuspecs", "{55D09D94-E557-4383-B5DB-9F15D43DAC72}"
ProjectSection(SolutionItems) = preProject
pkg\morelinq.nuspec = pkg\morelinq.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Acquire.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Acquire.nuspec
pkg\MoreLinq.Source.MoreEnumerable.AssertCount.nuspec = pkg\MoreLinq.Source.MoreEnumerable.AssertCount.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Batch.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Batch.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Concat.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Concat.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Consume.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Consume.nuspec
pkg\MoreLinq.Source.MoreEnumerable.DistinctBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.DistinctBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.EquiZip.nuspec = pkg\MoreLinq.Source.MoreEnumerable.EquiZip.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ExceptBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ExceptBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Fold.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Fold.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ForEach.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ForEach.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Generate.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Generate.nuspec
pkg\MoreLinq.Source.MoreEnumerable.GenerateByIndex.nuspec = pkg\MoreLinq.Source.MoreEnumerable.GenerateByIndex.nuspec
pkg\MoreLinq.Source.MoreEnumerable.GroupAdjacent.nuspec = pkg\MoreLinq.Source.MoreEnumerable.GroupAdjacent.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Index.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Index.nuspec
pkg\MoreLinq.Source.MoreEnumerable.MaxBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.MaxBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.MinBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.MinBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.nuspec = pkg\MoreLinq.Source.MoreEnumerable.nuspec
pkg\MoreLinq.Source.MoreEnumerable.OrderedMerge.nuspec = pkg\MoreLinq.Source.MoreEnumerable.OrderedMerge.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pad.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pad.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pairwise.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pairwise.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pipe.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pipe.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Prepend.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Prepend.nuspec
pkg\MoreLinq.Source.MoreEnumerable.PreScan.nuspec = pkg\MoreLinq.Source.MoreEnumerable.PreScan.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Scan.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Scan.nuspec
pkg\MoreLinq.Source.MoreEnumerable.SingleOrFallback.nuspec = pkg\MoreLinq.Source.MoreEnumerable.SingleOrFallback.nuspec
pkg\MoreLinq.Source.MoreEnumerable.SkipUntil.nuspec = pkg\MoreLinq.Source.MoreEnumerable.SkipUntil.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Split.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Split.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeEvery.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeEvery.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeLast.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeLast.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeUntil.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeUntil.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToDataTable.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToDataTable.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToDelimitedString.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToDelimitedString.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToHashSet.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToHashSet.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Trace.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Trace.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Zip.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Zip.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ZipLongest.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ZipLongest.nuspec
pkg\MoreLinq.Portable.nuspec = pkg\MoreLinq.Portable.nuspec
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Portable", "MoreLinq\MoreLinq.Portable.csproj", "{72C49B06-715D-4423-AD0A-78517F71D7B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Portable.Test", "MoreLinq.Test\MoreLinq.Portable.Test.csproj", "{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8642E81B-3414-4C13-914F-05A4E600FE49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Release|Any CPU.Build.0 = Release|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Release|Any CPU.Build.0 = Release|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
VisualSVNWorkingCopyRoot =
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{835F8FFA-471F-4322-B721-A897F27872FA}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
buildw.cmd = buildw.cmd
COPYING.txt = COPYING.txt
pkg\morelinq.nuspec = pkg\morelinq.nuspec
pack.cmd = pack.cmd
packw.cmd = packw.cmd
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq", "MoreLinq\MoreLinq.csproj", "{8642E81B-3414-4C13-914F-05A4E600FE49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Test", "MoreLinq.Test\MoreLinq.Test.csproj", "{D89B7AF5-7615-47B7-B894-A722E66DB3D8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuspecs", "Nuspecs", "{55D09D94-E557-4383-B5DB-9F15D43DAC72}"
ProjectSection(SolutionItems) = preProject
pkg\morelinq.nuspec = pkg\morelinq.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Acquire.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Acquire.nuspec
pkg\MoreLinq.Source.MoreEnumerable.AssertCount.nuspec = pkg\MoreLinq.Source.MoreEnumerable.AssertCount.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Batch.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Batch.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Concat.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Concat.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Consume.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Consume.nuspec
pkg\MoreLinq.Source.MoreEnumerable.DistinctBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.DistinctBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.EquiZip.nuspec = pkg\MoreLinq.Source.MoreEnumerable.EquiZip.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ExceptBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ExceptBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Fold.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Fold.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ForEach.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ForEach.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Generate.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Generate.nuspec
pkg\MoreLinq.Source.MoreEnumerable.GenerateByIndex.nuspec = pkg\MoreLinq.Source.MoreEnumerable.GenerateByIndex.nuspec
pkg\MoreLinq.Source.MoreEnumerable.GroupAdjacent.nuspec = pkg\MoreLinq.Source.MoreEnumerable.GroupAdjacent.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Index.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Index.nuspec
pkg\MoreLinq.Source.MoreEnumerable.MaxBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.MaxBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.MinBy.nuspec = pkg\MoreLinq.Source.MoreEnumerable.MinBy.nuspec
pkg\MoreLinq.Source.MoreEnumerable.nuspec = pkg\MoreLinq.Source.MoreEnumerable.nuspec
pkg\MoreLinq.Source.MoreEnumerable.OrderedMerge.nuspec = pkg\MoreLinq.Source.MoreEnumerable.OrderedMerge.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pad.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pad.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pairwise.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pairwise.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Pipe.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Pipe.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Prepend.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Prepend.nuspec
pkg\MoreLinq.Source.MoreEnumerable.PreScan.nuspec = pkg\MoreLinq.Source.MoreEnumerable.PreScan.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Scan.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Scan.nuspec
pkg\MoreLinq.Source.MoreEnumerable.SingleOrFallback.nuspec = pkg\MoreLinq.Source.MoreEnumerable.SingleOrFallback.nuspec
pkg\MoreLinq.Source.MoreEnumerable.SkipUntil.nuspec = pkg\MoreLinq.Source.MoreEnumerable.SkipUntil.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Split.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Split.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeEvery.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeEvery.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeLast.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeLast.nuspec
pkg\MoreLinq.Source.MoreEnumerable.TakeUntil.nuspec = pkg\MoreLinq.Source.MoreEnumerable.TakeUntil.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToDataTable.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToDataTable.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToDelimitedString.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToDelimitedString.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ToHashSet.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ToHashSet.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Trace.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Trace.nuspec
pkg\MoreLinq.Source.MoreEnumerable.Zip.nuspec = pkg\MoreLinq.Source.MoreEnumerable.Zip.nuspec
pkg\MoreLinq.Source.MoreEnumerable.ZipLongest.nuspec = pkg\MoreLinq.Source.MoreEnumerable.ZipLongest.nuspec
pkg\MoreLinq.Portable.nuspec = pkg\MoreLinq.Portable.nuspec
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Portable", "MoreLinq\MoreLinq.Portable.csproj", "{72C49B06-715D-4423-AD0A-78517F71D7B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreLinq.Portable.Test", "MoreLinq.Test\MoreLinq.Portable.Test.csproj", "{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8642E81B-3414-4C13-914F-05A4E600FE49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8642E81B-3414-4C13-914F-05A4E600FE49}.Release|Any CPU.Build.0 = Release|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D89B7AF5-7615-47B7-B894-A722E66DB3D8}.Release|Any CPU.Build.0 = Release|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72C49B06-715D-4423-AD0A-78517F71D7B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A47BCE6-B1A4-467A-BAF0-3021ED39FC7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
VisualSVNWorkingCopyRoot =
EndGlobalSection
EndGlobal
118 changes: 59 additions & 59 deletions MoreLinq/Acquire.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
#region License and Terms
// MoreLINQ - Extensions to LINQ to Objects
// Copyright (c) 2008 Jonathan Skeet. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

namespace MoreLinq
{
using System;
using System.Collections.Generic;

static partial class MoreEnumerable
{
/// <summary>
/// Ensures that a source sequence of <see cref="IDisposable"/>
/// objects are all acquired successfully. If the acquisition of any
/// one <see cref="IDisposable"/> fails then those successfully
/// acquired till that point are disposed.
/// </summary>
/// <typeparam name="TSource">Type of elements in <paramref name="source"/> sequence.</typeparam>
/// <param name="source">Source sequence of <see cref="IDisposable"/> objects.</param>
/// <returns>
/// Returns an array of all the acquired <see cref="IDisposable"/>
/// object and in source order.
/// </returns>
/// <remarks>
/// This operator executes immediately.
/// </remarks>

public static TSource[] Acquire<TSource>(this IEnumerable<TSource> source)
where TSource : IDisposable
{
if (source == null) throw new ArgumentNullException("source");

var disposables = new List<TSource>();
try
{
disposables.AddRange(source);
return disposables.ToArray();
}
catch
{
foreach (var disposable in disposables)
disposable.Dispose();
throw;
}
}
}
#region License and Terms
// MoreLINQ - Extensions to LINQ to Objects
// Copyright (c) 2008 Jonathan Skeet. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

namespace MoreLinq
{
using System;
using System.Collections.Generic;

static partial class MoreEnumerable
{
/// <summary>
/// Ensures that a source sequence of <see cref="IDisposable"/>
/// objects are all acquired successfully. If the acquisition of any
/// one <see cref="IDisposable"/> fails then those successfully
/// acquired till that point are disposed.
/// </summary>
/// <typeparam name="TSource">Type of elements in <paramref name="source"/> sequence.</typeparam>
/// <param name="source">Source sequence of <see cref="IDisposable"/> objects.</param>
/// <returns>
/// Returns an array of all the acquired <see cref="IDisposable"/>
/// object and in source order.
/// </returns>
/// <remarks>
/// This operator executes immediately.
/// </remarks>

public static TSource[] Acquire<TSource>(this IEnumerable<TSource> source)
where TSource : IDisposable
{
if (source == null) throw new ArgumentNullException("source");

var disposables = new List<TSource>();
try
{
disposables.AddRange(source);
return disposables.ToArray();
}
catch
{
foreach (var disposable in disposables)
disposable.Dispose();
throw;
}
}
}
}
Loading

0 comments on commit d69465d

Please sign in to comment.