Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
Last active July 28, 2021 23:50
Show Gist options
  • Save jeremybeavon/fdb603ba4dfb19a1b40c to your computer and use it in GitHub Desktop.
Save jeremybeavon/fdb603ba4dfb19a1b40c to your computer and use it in GitHub Desktop.
Powershell LINQ Support
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
public static class PowershellLinqSupport
{
/// <example>[PowershellLinqSupport]::Range(1, 4)</example>
public static PowershellLinqSupport<int> Range(int start, int count)
{
return new PowershellLinqSupport<int>(Enumerable.Range(start, count));
}
}
public static class PowershellLinqAggregateSupport<TSource, TAccumulate>
{
public static TAccumulate Aggregate(IEnumerable<TSource> enumerable, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
return enumerable.Aggregate(seed, func);
}
public static TAccumulate Aggregate(object[] enumerable, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
return Aggregate(enumerable.Cast<TSource>(), seed, func);
}
}
public static class PowershellLinqAggregateSupport<TSource, TAccumulate, TResult>
{
public static TResult Aggregate(IEnumerable<TSource> enumerable, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
{
return enumerable.Aggregate(seed, func, resultSelector);
}
public static TResult Aggregate(object[] enumerable, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
{
return Aggregate(enumerable.Cast<TSource>(), seed, func, resultSelector);
}
}
public static class PowershellLinqGroupBySupport<TSource, TKey>
{
public static PowershellLinqSupport<IGrouping<TKey, TSource>> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return new PowershellLinqSupport<IGrouping<TKey, TSource>>(enumerable.GroupBy(keySelector));
}
public static PowershellLinqSupport<IGrouping<TKey, TSource>> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector);
}
public static PowershellLinqSupport<IGrouping<TKey, TSource>> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<IGrouping<TKey, TSource>>(enumerable.GroupBy(keySelector, comparer));
}
public static PowershellLinqSupport<IGrouping<TKey, TSource>> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, comparer);
}
}
public static class PowershellLinqGroupBySupport<TSource, TKey, TResultOrElement>
{
public static PowershellLinqSupport<TResultOrElement> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector)
{
return new PowershellLinqSupport<TResultOrElement>(enumerable.GroupBy(keySelector, resultSelector));
}
public static PowershellLinqSupport<TResultOrElement> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, resultSelector);
}
public static PowershellLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector)
{
return new PowershellLinqSupport<IGrouping<TKey, TResultOrElement>>(enumerable.GroupBy(keySelector, elementSelector));
}
public static PowershellLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, elementSelector);
}
public static PowershellLinqSupport<TResultOrElement> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<TResultOrElement>(enumerable.GroupBy(keySelector, resultSelector, comparer));
}
public static PowershellLinqSupport<TResultOrElement> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, resultSelector, comparer);
}
public static PowershellLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<IGrouping<TKey, TResultOrElement>>(enumerable.GroupBy(keySelector, elementSelector, comparer));
}
public static PowershellLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, elementSelector, comparer);
}
}
public static class PowershellLinqGroupBySupport<TSource, TKey, TElement, TResult>
{
public static PowershellLinqSupport<TResult> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(enumerable.GroupBy(keySelector, elementSelector, resultSelector));
}
public static PowershellLinqSupport<TResult> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, elementSelector, resultSelector);
}
public static PowershellLinqSupport<TResult> GroupBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<TResult>(enumerable.GroupBy(keySelector, elementSelector, resultSelector, comparer));
}
public static PowershellLinqSupport<TResult> GroupBy(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(enumerable.Cast<TSource>(), keySelector, elementSelector, resultSelector, comparer);
}
}
public static class PowershellLinqGroupJoinSupport<TOuter, TInner, TKey, TResult>
{
public static PowershellLinqSupport<TResult> GroupJoin(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector));
}
public static PowershellLinqSupport<TResult> GroupJoin(object[] outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer.Cast<TOuter>(), inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> GroupJoin(IEnumerable<TOuter> outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer, inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> GroupJoin(object[] outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer.Cast<TOuter>(), inner, outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> GroupJoin(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<TResult>(outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, comparer));
}
public static PowershellLinqSupport<TResult> GroupJoin(object[] outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer.Cast<TOuter>(), inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellLinqSupport<TResult> GroupJoin(IEnumerable<TOuter> outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer, inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellLinqSupport<TResult> GroupJoin(object[] outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer.Cast<TOuter>(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
}
}
public static class PowershellLinqJoinSupport<TOuter, TInner, TKey, TResult>
{
public static PowershellLinqSupport<TResult> Join(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector));
}
public static PowershellLinqSupport<TResult> Join(object[] outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer.Cast<TOuter>(), inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> Join(IEnumerable<TOuter> outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer, inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> Join(object[] outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer.Cast<TOuter>(), inner, outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellLinqSupport<TResult> Join(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellLinqSupport<TResult>(outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, comparer));
}
public static PowershellLinqSupport<TResult> Join(object[] outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer.Cast<TOuter>(), inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellLinqSupport<TResult> Join(IEnumerable<TOuter> outer, object[] inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer, inner.Cast<TInner>(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellLinqSupport<TResult> Join(object[] outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer.Cast<TOuter>(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
}
}
public static class PowershellLinqJoinSupport<TSource, TKey>
{
public static PowershellOrderedLinqSupport<TSource> OrderBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.OrderBy(keySelector));
}
public static PowershellOrderedLinqSupport<TSource> OrderBy(object[] enumerable, Func<TSource, TKey> keySelector)
{
return OrderBy(enumerable.Cast<TSource>(), keySelector);
}
public static PowershellOrderedLinqSupport<TSource> OrderBy(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.OrderBy(keySelector, comparer));
}
public static PowershellOrderedLinqSupport<TSource> OrderBy(object[] enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return OrderBy(enumerable.Cast<TSource>(), keySelector, comparer);
}
public static PowershellOrderedLinqSupport<TSource> OrderByDescending(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.OrderByDescending(keySelector));
}
public static PowershellOrderedLinqSupport<TSource> OrderByDescending(object[] enumerable, Func<TSource, TKey> keySelector)
{
return OrderByDescending(enumerable.Cast<TSource>(), keySelector);
}
public static PowershellOrderedLinqSupport<TSource> OrderByDescending(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.OrderByDescending(keySelector, comparer));
}
public static PowershellOrderedLinqSupport<TSource> OrderByDescending(object[] enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return OrderByDescending(enumerable.Cast<TSource>(), keySelector, comparer);
}
}
public static class PowershellLinqSelectSupport<TSource, TResult>
{
public static PowershellLinqSupport<TResult> Select(IEnumerable<TSource> enumerable, Func<TSource, int, TResult> selector)
{
return new PowershellLinqSupport<TResult>(enumerable.Select(selector));
}
public static PowershellLinqSupport<TResult> Select(object[] enumerable, Func<TSource, int, TResult> selector)
{
return Select(enumerable.Cast<TSource>(), selector);
}
public static PowershellLinqSupport<TResult> Select(IEnumerable<TSource> enumerable, Func<TSource, TResult> selector)
{
return new PowershellLinqSupport<TResult>(enumerable.Select(selector));
}
public static PowershellLinqSupport<TResult> Select(object[] enumerable, Func<TSource, TResult> selector)
{
return Select(enumerable.Cast<TSource>(), selector);
}
}
public static class PowershellLinqSelectManySupport<TSource, TResult>
{
public static PowershellLinqSupport<TResult> SelectMany(IEnumerable<TSource> enumerable, Func<TSource, IEnumerable<TResult>> selector)
{
return new PowershellLinqSupport<TResult>(enumerable.SelectMany(selector));
}
public static PowershellLinqSupport<TResult> SelectMany(object[] enumerable, Func<TSource, IEnumerable<TResult>> selector)
{
return SelectMany(enumerable.Cast<TSource>(), selector);
}
public static PowershellLinqSupport<TResult> SelectMany(IEnumerable<TSource> enumerable, Func<TSource, int, IEnumerable<TResult>> selector)
{
return new PowershellLinqSupport<TResult>(enumerable.SelectMany(selector));
}
public static PowershellLinqSupport<TResult> SelectMany(object[] enumerable, Func<TSource, int, IEnumerable<TResult>> selector)
{
return SelectMany(enumerable.Cast<TSource>(), selector);
}
}
public static class PowershellLinqSelectManySupport<TSource, TCollection, TResult>
{
public static PowershellLinqSupport<TResult> SelectMany(IEnumerable<TSource> enumerable, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(enumerable.SelectMany(collectionSelector, resultSelector));
}
public static PowershellLinqSupport<TResult> SelectMany(object[] enumerable, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return SelectMany(enumerable.Cast<TSource>(), collectionSelector, resultSelector);
}
public static PowershellLinqSupport<TResult> SelectMany(IEnumerable<TSource> enumerable, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(enumerable.SelectMany(collectionSelector, resultSelector));
}
public static PowershellLinqSupport<TResult> SelectMany(object[] enumerable, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return SelectMany(enumerable.Cast<TSource>(), collectionSelector, resultSelector);
}
}
public static class PowershellLinqThenBySupport<TSource, TKey>
{
public static PowershellOrderedLinqSupport<TSource> ThenBy(IOrderedEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.ThenBy(keySelector));
}
public static PowershellOrderedLinqSupport<TSource> ThenBy(IOrderedEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.ThenBy(keySelector, comparer));
}
public static PowershellOrderedLinqSupport<TSource> ThenByDescending(IOrderedEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.ThenByDescending(keySelector));
}
public static PowershellOrderedLinqSupport<TSource> ThenByDescending(IOrderedEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellOrderedLinqSupport<TSource>(enumerable.ThenByDescending(keySelector, comparer));
}
}
public static class PowershellLinqToDictionarySupport<TSource, TKey>
{
public static Dictionary<TKey, TSource> ToDictionary(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return enumerable.ToDictionary(keySelector);
}
public static Dictionary<TKey, TSource> ToDictionary(object[] enumerable, Func<TSource, TKey> keySelector)
{
return ToDictionary(enumerable.Cast<TSource>(), keySelector);
}
public static Dictionary<TKey, TSource> ToDictionary(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return enumerable.ToDictionary(keySelector, comparer);
}
public static Dictionary<TKey, TSource> ToDictionary(object[] enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return ToDictionary(enumerable.Cast<TSource>(), keySelector, comparer);
}
}
public static class PowershellLinqToDictionarySupport<TSource, TKey, TElement>
{
public static Dictionary<TKey, TElement> ToDictionary(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return enumerable.ToDictionary(keySelector, elementSelector);
}
public static Dictionary<TKey, TElement> ToDictionary(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return ToDictionary(enumerable.Cast<TSource>(), keySelector, elementSelector);
}
public static Dictionary<TKey, TElement> ToDictionary(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return enumerable.ToDictionary(keySelector, elementSelector, comparer);
}
public static Dictionary<TKey, TElement> ToDictionary(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return ToDictionary(enumerable.Cast<TSource>(), keySelector, elementSelector, comparer);
}
}
public static class PowershellLinqToLookupSupport<TSource, TKey>
{
public static ILookup<TKey, TSource> ToLookup(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector)
{
return enumerable.ToLookup(keySelector);
}
public static ILookup<TKey, TSource> ToLookup(object[] enumerable, Func<TSource, TKey> keySelector)
{
return ToLookup(enumerable.Cast<TSource>(), keySelector);
}
public static ILookup<TKey, TSource> ToLookup(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return enumerable.ToLookup(keySelector, comparer);
}
public static ILookup<TKey, TSource> ToLookup(object[] enumerable, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return ToLookup(enumerable.Cast<TSource>(), keySelector, comparer);
}
}
public static class PowershellLinqToLookupSupport<TSource, TKey, TElement>
{
public static ILookup<TKey, TElement> ToLookup(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return enumerable.ToLookup(keySelector, elementSelector);
}
public static ILookup<TKey, TElement> ToLookup(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return ToLookup(enumerable.Cast<TSource>(), keySelector, elementSelector);
}
public static ILookup<TKey, TElement> ToLookup(IEnumerable<TSource> enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return enumerable.ToLookup(keySelector, elementSelector, comparer);
}
public static ILookup<TKey, TElement> ToLookup(object[] enumerable, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return ToLookup(enumerable.Cast<TSource>(), keySelector, elementSelector, comparer);
}
}
public static class PowershellLinqZipSupport<TFirst, TSecond, TResult>
{
public static PowershellLinqSupport<TResult> Zip(IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return new PowershellLinqSupport<TResult>(first.Zip(second, resultSelector));
}
public static PowershellLinqSupport<TResult> Zip(object[] first, object[] second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first.Cast<TFirst>(), second.Cast<TSecond>(), resultSelector);
}
public static PowershellLinqSupport<TResult> Zip(IEnumerable<TFirst> first, object[] second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first, second.Cast<TSecond>(), resultSelector);
}
public static PowershellLinqSupport<TResult> Zip(object[] first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first.Cast<TFirst>(), second, resultSelector);
}
}
public class PowershellLinqSupport<TSource> : IEnumerable<TSource>
{
private readonly IEnumerable<TSource> enumerable;
public PowershellLinqSupport(IEnumerable<TSource> enumerable)
{
this.enumerable = enumerable;
}
public PowershellLinqSupport(params object[] array)
: this(array.Cast<TSource>())
{
}
public TSource Aggregate(Func<TSource, TSource, TSource> func)
{
return enumerable.Aggregate(func);
}
public bool All(Func<TSource, bool> predicate)
{
return enumerable.All(predicate);
}
public bool Any()
{
return enumerable.Any();
}
public bool Any(Func<TSource, bool> predicate)
{
return enumerable.Any(predicate);
}
public PowershellParallelLinqSupport<TSource> AsParallel()
{
return new PowershellParallelLinqSupport<TSource>(enumerable.AsParallel());
}
public decimal? Average(Func<TSource, decimal?> selector)
{
return enumerable.Average(selector);
}
public decimal Average(Func<TSource, decimal> selector)
{
return enumerable.Average(selector);
}
public double? Average(Func<TSource, double?> selector)
{
return enumerable.Average(selector);
}
public double Average(Func<TSource, double> selector)
{
return enumerable.Average(selector);
}
public float? Average(Func<TSource, float?> selector)
{
return enumerable.Average(selector);
}
public float Average(Func<TSource, float> selector)
{
return enumerable.Average(selector);
}
public double? Average(Func<TSource, int?> selector)
{
return enumerable.Average(selector);
}
public double Average(Func<TSource, int> selector)
{
return enumerable.Average(selector);
}
public double? Average(Func<TSource, long?> selector)
{
return enumerable.Average(selector);
}
public double Average(Func<TSource, long> selector)
{
return enumerable.Average(selector);
}
public static PowershellLinqSupport<TSource> Cast(IEnumerable enumerable)
{
return new PowershellLinqSupport<TSource>(enumerable.Cast<TSource>());
}
public PowershellLinqSupport<TSource> Concat(IEnumerable<TSource> second)
{
return new PowershellLinqSupport<TSource>(enumerable.Concat(second));
}
public PowershellLinqSupport<TSource> Concat(params object[] second)
{
return Concat(second.Cast<TSource>());
}
public bool Contains(TSource value)
{
return enumerable.Contains(value);
}
public bool Contains(TSource value, IEqualityComparer<TSource> comparer)
{
return enumerable.Contains(value, comparer);
}
public int Count()
{
return enumerable.Count();
}
public int Count(Func<TSource, bool> predicate)
{
return enumerable.Count(predicate);
}
public PowershellLinqSupport<TSource> DefaultIfEmpty()
{
return new PowershellLinqSupport<TSource>(enumerable.DefaultIfEmpty());
}
public PowershellLinqSupport<TSource> DefaultIfEmpty(TSource defaultValue)
{
return new PowershellLinqSupport<TSource>(enumerable.DefaultIfEmpty(defaultValue));
}
public PowershellLinqSupport<TSource> Distinct()
{
return new PowershellLinqSupport<TSource>(enumerable.Distinct());
}
public PowershellLinqSupport<TSource> Distinct(IEqualityComparer<TSource> comparer)
{
return new PowershellLinqSupport<TSource>(enumerable.Distinct(comparer));
}
public TSource ElementAt(int index)
{
return enumerable.ElementAt(index);
}
public TSource ElementAtOrDefault(int index)
{
return enumerable.ElementAtOrDefault(index);
}
public PowershellLinqSupport<TSource> Except(IEnumerable<TSource> second)
{
return new PowershellLinqSupport<TSource>(enumerable.Except(second));
}
public PowershellLinqSupport<TSource> Except(params object[] second)
{
return Except(second.Cast<TSource>());
}
public PowershellLinqSupport<TSource> Except(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellLinqSupport<TSource>(enumerable.Except(second, comparer));
}
public PowershellLinqSupport<TSource> Except(object[] second, IEqualityComparer<TSource> comparer)
{
return Except(second.Cast<TSource>(), comparer);
}
public TSource First()
{
return enumerable.First();
}
public TSource First(Func<TSource, bool> predicate)
{
return enumerable.First(predicate);
}
public TSource FirstOrDefault()
{
return enumerable.FirstOrDefault();
}
public TSource FirstOrDefault(Func<TSource, bool> predicate)
{
return enumerable.FirstOrDefault(predicate);
}
public PowershellLinqSupport<TSource> Intersect(IEnumerable<TSource> second)
{
return new PowershellLinqSupport<TSource>(enumerable.Intersect(second));
}
public PowershellLinqSupport<TSource> Intersect(params object[] second)
{
return Intersect(second.Cast<TSource>());
}
public PowershellLinqSupport<TSource> Intersect(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellLinqSupport<TSource>(enumerable.Intersect(second, comparer));
}
public PowershellLinqSupport<TSource> Intersect(object[] second, IEqualityComparer<TSource> comparer)
{
return Intersect(second.Cast<TSource>(), comparer);
}
public TSource Last()
{
return enumerable.Last();
}
public TSource Last(Func<TSource, bool> predicate)
{
return enumerable.Last(predicate);
}
public TSource LastOrDefault()
{
return enumerable.LastOrDefault();
}
public TSource LastOrDefault(Func<TSource, bool> predicate)
{
return enumerable.LastOrDefault(predicate);
}
public long LongCount()
{
return enumerable.LongCount();
}
public long LongCount(Func<TSource, bool> predicate)
{
return enumerable.LongCount(predicate);
}
public TSource Max()
{
return enumerable.Max();
}
public decimal? Max(Func<TSource, decimal?> selector)
{
return enumerable.Max(selector);
}
public decimal Max(Func<TSource, decimal> selector)
{
return enumerable.Max(selector);
}
public double? Max(Func<TSource, double?> selector)
{
return enumerable.Max(selector);
}
public double Max(Func<TSource, double> selector)
{
return enumerable.Max(selector);
}
public float? Max(Func<TSource, float?> selector)
{
return enumerable.Max(selector);
}
public float Max(Func<TSource, float> selector)
{
return enumerable.Max(selector);
}
public int? Max(Func<TSource, int?> selector)
{
return enumerable.Max(selector);
}
public int Max(Func<TSource, int> selector)
{
return enumerable.Max(selector);
}
public long? Max(Func<TSource, long?> selector)
{
return enumerable.Max(selector);
}
public long Max(Func<TSource, long> selector)
{
return enumerable.Max(selector);
}
public TResult Max<TResult>(Func<TSource, TResult> selector)
{
return enumerable.Max(selector);
}
public TSource Min()
{
return enumerable.Min();
}
public decimal? Min(Func<TSource, decimal?> selector)
{
return enumerable.Min(selector);
}
public decimal Min(Func<TSource, decimal> selector)
{
return enumerable.Min(selector);
}
public double? Min(Func<TSource, double?> selector)
{
return enumerable.Min(selector);
}
public double Min(Func<TSource, double> selector)
{
return enumerable.Min(selector);
}
public float? Min(Func<TSource, float?> selector)
{
return enumerable.Min(selector);
}
public float Min(Func<TSource, float> selector)
{
return enumerable.Min(selector);
}
public int? Min(Func<TSource, int?> selector)
{
return enumerable.Min(selector);
}
public int Min(Func<TSource, int> selector)
{
return enumerable.Min(selector);
}
public long? Min(Func<TSource, long?> selector)
{
return enumerable.Min(selector);
}
public long Min(Func<TSource, long> selector)
{
return enumerable.Min(selector);
}
public TResult Min<TResult>(Func<TSource, TResult> selector)
{
return enumerable.Min(selector);
}
public static PowershellLinqSupport<TSource> OfType(IEnumerable enumerable)
{
return new PowershellLinqSupport<TSource>(enumerable.OfType<TSource>());
}
public static PowershellLinqSupport<TSource> Repeat(TSource element, int count)
{
return new PowershellLinqSupport<TSource>(Enumerable.Repeat(element, count));
}
public PowershellLinqSupport<TSource> Reverse()
{
return new PowershellLinqSupport<TSource>(enumerable.Reverse());
}
public bool SequenceEqual(IEnumerable<TSource> second)
{
return enumerable.SequenceEqual(second);
}
public bool SequenceEqual(params object[] second)
{
return SequenceEqual(second.Cast<TSource>());
}
public bool SequenceEqual(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
{
return enumerable.SequenceEqual(second, comparer);
}
public bool SequenceEqual(object[] second, IEqualityComparer<TSource> comparer)
{
return SequenceEqual(second.Cast<TSource>(), comparer);
}
public TSource Single()
{
return enumerable.Single();
}
public TSource Single(Func<TSource, bool> predicate)
{
return enumerable.Single(predicate);
}
public TSource SingleOrDefault()
{
return enumerable.SingleOrDefault();
}
public TSource SingleOrDefault(Func<TSource, bool> predicate)
{
return enumerable.SingleOrDefault(predicate);
}
public PowershellLinqSupport<TSource> Skip(int count)
{
return new PowershellLinqSupport<TSource>(enumerable.Skip(count));
}
public PowershellLinqSupport<TSource> SkipWhile(Func<TSource, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.SkipWhile(predicate));
}
public PowershellLinqSupport<TSource> SkipWhile(Func<TSource, int, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.SkipWhile(predicate));
}
public decimal? Sum(Func<TSource, decimal?> selector)
{
return enumerable.Sum(selector);
}
public decimal Sum(Func<TSource, decimal> selector)
{
return enumerable.Sum(selector);
}
public double? Sum(Func<TSource, double?> selector)
{
return enumerable.Sum(selector);
}
public double Sum(Func<TSource, double> selector)
{
return enumerable.Sum(selector);
}
public float? Sum(Func<TSource, float?> selector)
{
return enumerable.Sum(selector);
}
public float Sum(Func<TSource, float> selector)
{
return enumerable.Sum(selector);
}
public int? Sum(Func<TSource, int?> selector)
{
return enumerable.Sum(selector);
}
public int Sum(Func<TSource, int> selector)
{
return enumerable.Sum(selector);
}
public long? Sum(Func<TSource, long?> selector)
{
return enumerable.Sum(selector);
}
public long Sum(Func<TSource, long> selector)
{
return enumerable.Sum(selector);
}
public PowershellLinqSupport<TSource> Take(int count)
{
return new PowershellLinqSupport<TSource>(enumerable.Take(count));
}
public PowershellLinqSupport<TSource> TakeWhile(Func<TSource, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.TakeWhile(predicate));
}
public PowershellLinqSupport<TSource> TakeWhile(Func<TSource, int, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.TakeWhile(predicate));
}
public TSource[] ToArray()
{
return enumerable.ToArray();
}
public List<TSource> ToList()
{
return enumerable.ToList();
}
public PowershellLinqSupport<TSource> ToPowershellLinq()
{
return new PowershellLinqSupport<TSource>(ToArray());
}
public PowershellLinqSupport<TSource> Union(IEnumerable<TSource> second)
{
return new PowershellLinqSupport<TSource>(enumerable.Union(second));
}
public PowershellLinqSupport<TSource> Union(params object[] second)
{
return Union(second.Cast<TSource>());
}
public PowershellLinqSupport<TSource> Union(IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellLinqSupport<TSource>(enumerable.Union(second, comparer));
}
public PowershellLinqSupport<TSource> Union(object[] second, IEqualityComparer<TSource> comparer)
{
return Union(second.Cast<TSource>(), comparer);
}
public PowershellLinqSupport<TSource> Where(Func<TSource, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.Where(predicate));
}
public PowershellLinqSupport<TSource> Where(Func<TSource, int, bool> predicate)
{
return new PowershellLinqSupport<TSource>(enumerable.Where(predicate));
}
public IEnumerator<TSource> GetEnumerator()
{
return enumerable.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public class PowershellOrderedLinqSupport<TSource> : PowershellLinqSupport<TSource>, IOrderedEnumerable<TSource>
{
private readonly IOrderedEnumerable<TSource> enumerable;
public PowershellOrderedLinqSupport(IOrderedEnumerable<TSource> enumerable)
: base(enumerable)
{
this.enumerable = enumerable;
}
public IOrderedEnumerable<TSource> CreateOrderedEnumerable<TKey>(Func<TSource, TKey> keySelector, IComparer<TKey> comparer, bool descending)
{
return enumerable.CreateOrderedEnumerable(keySelector, comparer, descending);
}
}
public static class PowershellParallelLinqAggregateSupport<TSource, TAccumulate>
{
public static TAccumulate Aggregate(ParallelQuery<TSource> query, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
return query.Aggregate(seed, func);
}
public static TAccumulate Aggregate(PowershellParallelLinqSupport<TSource> query, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
return Aggregate(query.AsParallelQuery(), seed, func);
}
}
public static class PowershellParallelLinqAggregateSupport<TSource, TAccumulate, TResult>
{
public static TResult Aggregate(ParallelQuery<TSource> query, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
{
return query.Aggregate(seed, func, resultSelector);
}
public static TResult Aggregate(PowershellParallelLinqSupport<TSource> query, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
{
return Aggregate(query.AsParallelQuery(), seed, func, resultSelector);
}
}
public static class PowershellParallelLinqGroupBySupport<TSource, TKey>
{
public static PowershellParallelLinqSupport<IGrouping<TKey, TSource>> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return new PowershellParallelLinqSupport<IGrouping<TKey, TSource>>(query.GroupBy(keySelector));
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TSource>> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return GroupBy(query.AsParallelQuery(), keySelector);
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TSource>> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<IGrouping<TKey, TSource>>(query.GroupBy(keySelector, comparer));
}
}
public static class PowershellParallelLinqGroupBySupport<TSource, TKey, TResultOrElement>
{
public static PowershellParallelLinqSupport<TResultOrElement> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector)
{
return new PowershellParallelLinqSupport<TResultOrElement>(query.GroupBy(keySelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResultOrElement> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector)
{
return GroupBy(query.AsParallelQuery(), keySelector, resultSelector);
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector)
{
return new PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>>(query.GroupBy(keySelector, elementSelector));
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector)
{
return GroupBy(query.AsParallelQuery(), keySelector, elementSelector);
}
public static PowershellParallelLinqSupport<TResultOrElement> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<TResultOrElement>(query.GroupBy(keySelector, resultSelector, comparer));
}
public static PowershellParallelLinqSupport<TResultOrElement> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResultOrElement> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(query.AsParallelQuery(), keySelector, resultSelector, comparer);
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>>(query.GroupBy(keySelector, elementSelector, comparer));
}
public static PowershellParallelLinqSupport<IGrouping<TKey, TResultOrElement>> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TResultOrElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(query.AsParallelQuery(), keySelector, elementSelector, comparer);
}
}
public static class PowershellParallelLinqGroupBySupport<TSource, TKey, TElement, TResult>
{
public static PowershellParallelLinqSupport<TResult> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(query.GroupBy(keySelector, elementSelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
{
return GroupBy(query.AsParallelQuery(), keySelector, elementSelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> GroupBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<TResult>(query.GroupBy(keySelector, elementSelector, resultSelector, comparer));
}
public static PowershellParallelLinqSupport<TResult> GroupBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupBy(query.AsParallelQuery(), keySelector, elementSelector, resultSelector, comparer);
}
}
public static class PowershellParallelLinqGroupJoinSupport<TOuter, TInner, TKey, TResult>
{
public static PowershellParallelLinqSupport<TResult> GroupJoin(ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(PowershellParallelLinqSupport<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer.AsParallelQuery(), inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(ParallelQuery<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer, inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(PowershellParallelLinqSupport<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
{
return GroupJoin(outer.AsParallelQuery(), inner, outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<TResult>(outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, comparer));
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(PowershellParallelLinqSupport<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer.AsParallelQuery(), inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(ParallelQuery<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer, inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellParallelLinqSupport<TResult> GroupJoin(PowershellParallelLinqSupport<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return GroupJoin(outer.AsParallelQuery(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
}
}
public static class PowershellParallelLinqJoinSupport<TOuter, TInner, TKey, TResult>
{
public static PowershellParallelLinqSupport<TResult> Join(ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> Join(PowershellParallelLinqSupport<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer.AsParallelQuery(), inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> Join(ParallelQuery<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer, inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> Join(PowershellParallelLinqSupport<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
{
return Join(outer.AsParallelQuery(), inner, outerKeySelector, innerKeySelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> Join(ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return new PowershellParallelLinqSupport<TResult>(outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, comparer));
}
public static PowershellParallelLinqSupport<TResult> Join(PowershellParallelLinqSupport<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer.AsParallelQuery(), inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellParallelLinqSupport<TResult> Join(ParallelQuery<TOuter> outer, PowershellParallelLinqSupport<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer, inner.AsParallelQuery(), outerKeySelector, innerKeySelector, resultSelector, comparer);
}
public static PowershellParallelLinqSupport<TResult> Join(PowershellParallelLinqSupport<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
return Join(outer.AsParallelQuery(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
}
}
public static class PowershellParallelLinqOrderBySupport<TSource, TKey>
{
public static PowershellParallelOrderedLinqSupport<TSource> OrderBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.OrderBy(keySelector));
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return OrderBy(query.AsParallelQuery(), keySelector);
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderBy(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.OrderBy(keySelector, comparer));
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderBy(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return OrderBy(query.AsParallelQuery(), keySelector, comparer);
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderByDescending(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.OrderByDescending(keySelector));
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderByDescending(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return OrderByDescending(query.AsParallelQuery(), keySelector);
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderByDescending(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.OrderByDescending(keySelector, comparer));
}
public static PowershellParallelOrderedLinqSupport<TSource> OrderByDescending(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return OrderByDescending(query.AsParallelQuery(), keySelector, comparer);
}
}
public static class PowershellParallelLinqSelectSupport<TSource, TResult>
{
public static PowershellParallelLinqSupport<TResult> Select(ParallelQuery<TSource> query, Func<TSource, int, TResult> selector)
{
return new PowershellParallelLinqSupport<TResult>(query.Select(selector));
}
public static PowershellParallelLinqSupport<TResult> Select(PowershellParallelLinqSupport<TSource> query, Func<TSource, int, TResult> selector)
{
return Select(query.AsParallelQuery(), selector);
}
public static PowershellParallelLinqSupport<TResult> Select(ParallelQuery<TSource> query, Func<TSource, TResult> selector)
{
return new PowershellParallelLinqSupport<TResult>(query.Select(selector));
}
public static PowershellParallelLinqSupport<TResult> Select(PowershellParallelLinqSupport<TSource> query, Func<TSource, TResult> selector)
{
return Select(query.AsParallelQuery(), selector);
}
}
public static class PowershellParallelLinqSelectManySupport<TSource, TResult>
{
public static PowershellParallelLinqSupport<TResult> SelectMany(ParallelQuery<TSource> query, Func<TSource, IEnumerable<TResult>> selector)
{
return new PowershellParallelLinqSupport<TResult>(query.SelectMany(selector));
}
public static PowershellParallelLinqSupport<TResult> SelectMany(PowershellParallelLinqSupport<TSource> query, Func<TSource, IEnumerable<TResult>> selector)
{
return SelectMany(query.AsParallelQuery(), selector);
}
public static PowershellParallelLinqSupport<TResult> SelectMany(ParallelQuery<TSource> query, Func<TSource, int, IEnumerable<TResult>> selector)
{
return new PowershellParallelLinqSupport<TResult>(query.SelectMany(selector));
}
public static PowershellParallelLinqSupport<TResult> SelectMany(PowershellParallelLinqSupport<TSource> query, Func<TSource, int, IEnumerable<TResult>> selector)
{
return SelectMany(query.AsParallelQuery(), selector);
}
}
public static class PowershellParallelLinqSelectManySupport<TSource, TCollection, TResult>
{
public static PowershellParallelLinqSupport<TResult> SelectMany(ParallelQuery<TSource> query, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(query.SelectMany(collectionSelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> SelectMany(PowershellParallelLinqSupport<TSource> query, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return SelectMany(query.AsParallelQuery(), collectionSelector, resultSelector);
}
public static PowershellParallelLinqSupport<TResult> SelectMany(ParallelQuery<TSource> query, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(query.SelectMany(collectionSelector, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> SelectMany(PowershellParallelLinqSupport<TSource> query, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
{
return SelectMany(query.AsParallelQuery(), collectionSelector, resultSelector);
}
}
public static class PowershellParallelLinqThenBySupport<TSource, TKey>
{
public static PowershellParallelOrderedLinqSupport<TSource> ThenBy(OrderedParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.ThenBy(keySelector));
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenBy(PowershellParallelOrderedLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return ThenBy(query.AsOrderedParallelQuery(), keySelector);
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenBy(OrderedParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.ThenBy(keySelector, comparer));
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenBy(PowershellParallelOrderedLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return ThenBy(query.AsOrderedParallelQuery(), keySelector, comparer);
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenByDescending(OrderedParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.ThenByDescending(keySelector));
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenByDescending(PowershellParallelOrderedLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return ThenByDescending(query.AsOrderedParallelQuery(), keySelector);
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenByDescending(OrderedParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new PowershellParallelOrderedLinqSupport<TSource>(query.ThenByDescending(keySelector, comparer));
}
public static PowershellParallelOrderedLinqSupport<TSource> ThenByDescending(PowershellParallelOrderedLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return ThenByDescending(query.AsOrderedParallelQuery(), keySelector, comparer);
}
}
public static class PowershellParallelLinqToDictionarySupport<TSource, TKey>
{
public static Dictionary<TKey, TSource> ToDictionary(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return query.ToDictionary(keySelector);
}
public static Dictionary<TKey, TSource> ToDictionary(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return ToDictionary(query.AsParallelQuery(), keySelector);
}
public static Dictionary<TKey, TSource> ToDictionary(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return query.ToDictionary(keySelector, comparer);
}
public static Dictionary<TKey, TSource> ToDictionary(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return ToDictionary(query.AsParallelQuery(), keySelector, comparer);
}
}
public static class PowershellParallelLinqToDictionarySupport<TSource, TKey, TElement>
{
public static Dictionary<TKey, TElement> ToDictionary(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return query.ToDictionary(keySelector, elementSelector);
}
public static Dictionary<TKey, TElement> ToDictionary(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return ToDictionary(query.AsParallelQuery(), keySelector, elementSelector);
}
public static Dictionary<TKey, TElement> ToDictionary(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return query.ToDictionary(keySelector, elementSelector, comparer);
}
public static Dictionary<TKey, TElement> ToDictionary(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return ToDictionary(query.AsParallelQuery(), keySelector, elementSelector, comparer);
}
}
public static class PowershellParallelLinqToLookupSupport<TSource, TKey>
{
public static ILookup<TKey, TSource> ToLookup(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector)
{
return query.ToLookup(keySelector);
}
public static ILookup<TKey, TSource> ToLookup(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector)
{
return ToLookup(query.AsParallelQuery(), keySelector);
}
public static ILookup<TKey, TSource> ToLookup(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return query.ToLookup(keySelector, comparer);
}
public static ILookup<TKey, TSource> ToLookup(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return ToLookup(query.AsParallelQuery(), keySelector, comparer);
}
}
public static class PowershellParallelLinqToLookupSupport<TSource, TKey, TElement>
{
public static ILookup<TKey, TElement> ToLookup(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return query.ToLookup(keySelector, elementSelector);
}
public static ILookup<TKey, TElement> ToLookup(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return ToLookup(query.AsParallelQuery(), keySelector, elementSelector);
}
public static ILookup<TKey, TElement> ToLookup(ParallelQuery<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return query.ToLookup(keySelector, elementSelector, comparer);
}
public static ILookup<TKey, TElement> ToLookup(PowershellParallelLinqSupport<TSource> query, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
return ToLookup(query.AsParallelQuery(), keySelector, elementSelector, comparer);
}
}
public static class PowershellParallelLinqZipSupport<TFirst, TSecond, TResult>
{
public static PowershellParallelLinqSupport<TResult> Zip(ParallelQuery<TFirst> first, ParallelQuery<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return new PowershellParallelLinqSupport<TResult>(first.Zip(second, resultSelector));
}
public static PowershellParallelLinqSupport<TResult> Zip(PowershellParallelLinqSupport<TFirst> first, PowershellParallelLinqSupport<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first.AsParallelQuery(), second.AsParallelQuery(), resultSelector);
}
public static PowershellParallelLinqSupport<TResult> Zip(ParallelQuery<TFirst> first, PowershellParallelLinqSupport<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first, second.AsParallelQuery(), resultSelector);
}
public static PowershellParallelLinqSupport<TResult> Zip(PowershellParallelLinqSupport<TFirst> first, ParallelQuery<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
return Zip(first.AsParallelQuery(), second, resultSelector);
}
}
public class PowershellParallelLinqSupport<TSource>
{
private readonly ParallelQuery<TSource> query;
public PowershellParallelLinqSupport(ParallelQuery<TSource> query)
{
this.query = query;
}
public TSource Aggregate(Func<TSource, TSource, TSource> func)
{
return query.Aggregate(func);
}
public ParallelQuery<TSource> AsParallelQuery()
{
return query;
}
public bool All(Func<TSource, bool> predicate)
{
return query.All(predicate);
}
public bool Any()
{
return query.Any();
}
public bool Any(Func<TSource, bool> predicate)
{
return query.Any(predicate);
}
public decimal? Average(Func<TSource, decimal?> selector)
{
return query.Average(selector);
}
public decimal Average(Func<TSource, decimal> selector)
{
return query.Average(selector);
}
public double? Average(Func<TSource, double?> selector)
{
return query.Average(selector);
}
public double Average(Func<TSource, double> selector)
{
return query.Average(selector);
}
public float? Average(Func<TSource, float?> selector)
{
return query.Average(selector);
}
public float Average(Func<TSource, float> selector)
{
return query.Average(selector);
}
public double? Average(Func<TSource, int?> selector)
{
return query.Average(selector);
}
public double Average(Func<TSource, int> selector)
{
return query.Average(selector);
}
public double? Average(Func<TSource, long?> selector)
{
return query.Average(selector);
}
public double Average(Func<TSource, long> selector)
{
return query.Average(selector);
}
public static PowershellParallelLinqSupport<TSource> Cast(ParallelQuery query)
{
return new PowershellParallelLinqSupport<TSource>(query.Cast<TSource>());
}
public PowershellParallelLinqSupport<TSource> Concat(ParallelQuery<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Concat(second));
}
public PowershellParallelLinqSupport<TSource> Concat(PowershellParallelLinqSupport<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Concat(second.query));
}
public bool Contains(TSource value)
{
return query.Contains(value);
}
public bool Contains(TSource value, IEqualityComparer<TSource> comparer)
{
return query.Contains(value, comparer);
}
public int Count()
{
return query.Count();
}
public int Count(Func<TSource, bool> predicate)
{
return query.Count(predicate);
}
public PowershellParallelLinqSupport<TSource> DefaultIfEmpty()
{
return new PowershellParallelLinqSupport<TSource>(query.DefaultIfEmpty());
}
public PowershellParallelLinqSupport<TSource> DefaultIfEmpty(TSource defaultValue)
{
return new PowershellParallelLinqSupport<TSource>(query.DefaultIfEmpty(defaultValue));
}
public PowershellParallelLinqSupport<TSource> Distinct()
{
return new PowershellParallelLinqSupport<TSource>(query.Distinct());
}
public PowershellParallelLinqSupport<TSource> Distinct(IEqualityComparer<TSource> comparer)
{
return new PowershellParallelLinqSupport<TSource>(query.Distinct(comparer));
}
public TSource ElementAt(int index)
{
return query.ElementAt(index);
}
public TSource ElementAtOrDefault(int index)
{
return query.ElementAtOrDefault(index);
}
public PowershellParallelLinqSupport<TSource> Except(ParallelQuery<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Except(second));
}
public PowershellParallelLinqSupport<TSource> Except(PowershellParallelLinqSupport<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Except(second.query));
}
public PowershellParallelLinqSupport<TSource> Except(ParallelQuery<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellParallelLinqSupport<TSource>(query.Except(second, comparer));
}
public PowershellParallelLinqSupport<TSource> Except(PowershellParallelLinqSupport<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellParallelLinqSupport<TSource>(query.Except(second.query, comparer));
}
public TSource First()
{
return query.First();
}
public TSource First(Func<TSource, bool> predicate)
{
return query.First(predicate);
}
public TSource FirstOrDefault()
{
return query.FirstOrDefault();
}
public TSource FirstOrDefault(Func<TSource, bool> predicate)
{
return query.FirstOrDefault(predicate);
}
public void ForAll(Action<TSource> action)
{
query.ForAll(action);
}
public PowershellParallelLinqSupport<TSource> Intersect(ParallelQuery<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Intersect(second));
}
public PowershellParallelLinqSupport<TSource> Intersect(PowershellParallelLinqSupport<TSource> second)
{
return Intersect(second.AsParallelQuery());
}
public PowershellParallelLinqSupport<TSource> Intersect(ParallelQuery<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellParallelLinqSupport<TSource>(query.Intersect(second, comparer));
}
public PowershellParallelLinqSupport<TSource> Intersect(PowershellParallelLinqSupport<TSource> second, IEqualityComparer<TSource> comparer)
{
return Intersect(second.AsParallelQuery(), comparer);
}
public TSource Last()
{
return query.Last();
}
public TSource Last(Func<TSource, bool> predicate)
{
return query.Last(predicate);
}
public TSource LastOrDefault()
{
return query.LastOrDefault();
}
public TSource LastOrDefault(Func<TSource, bool> predicate)
{
return query.LastOrDefault(predicate);
}
public long LongCount()
{
return query.LongCount();
}
public long LongCount(Func<TSource, bool> predicate)
{
return query.LongCount(predicate);
}
public TSource Max()
{
return query.Max();
}
public decimal? Max(Func<TSource, decimal?> selector)
{
return query.Max(selector);
}
public decimal Max(Func<TSource, decimal> selector)
{
return query.Max(selector);
}
public double? Max(Func<TSource, double?> selector)
{
return query.Max(selector);
}
public double Max(Func<TSource, double> selector)
{
return query.Max(selector);
}
public float? Max(Func<TSource, float?> selector)
{
return query.Max(selector);
}
public float Max(Func<TSource, float> selector)
{
return query.Max(selector);
}
public int? Max(Func<TSource, int?> selector)
{
return query.Max(selector);
}
public int Max(Func<TSource, int> selector)
{
return query.Max(selector);
}
public long? Max(Func<TSource, long?> selector)
{
return query.Max(selector);
}
public long Max(Func<TSource, long> selector)
{
return query.Max(selector);
}
public TResult Max<TResult>(Func<TSource, TResult> selector)
{
return query.Max(selector);
}
public TSource Min()
{
return query.Min();
}
public decimal? Min(Func<TSource, decimal?> selector)
{
return query.Min(selector);
}
public decimal Min(Func<TSource, decimal> selector)
{
return query.Min(selector);
}
public double? Min(Func<TSource, double?> selector)
{
return query.Min(selector);
}
public double Min(Func<TSource, double> selector)
{
return query.Min(selector);
}
public float? Min(Func<TSource, float?> selector)
{
return query.Min(selector);
}
public float Min(Func<TSource, float> selector)
{
return query.Min(selector);
}
public int? Min(Func<TSource, int?> selector)
{
return query.Min(selector);
}
public int Min(Func<TSource, int> selector)
{
return query.Min(selector);
}
public long? Min(Func<TSource, long?> selector)
{
return query.Min(selector);
}
public long Min(Func<TSource, long> selector)
{
return query.Min(selector);
}
public TResult Min<TResult>(Func<TSource, TResult> selector)
{
return query.Min(selector);
}
public static PowershellParallelLinqSupport<TSource> OfType(ParallelQuery query)
{
return new PowershellParallelLinqSupport<TSource>(query.OfType<TSource>());
}
public static PowershellParallelLinqSupport<TSource> Repeat(TSource element, int count)
{
return new PowershellParallelLinqSupport<TSource>(ParallelEnumerable.Repeat(element, count));
}
public PowershellParallelLinqSupport<TSource> Reverse()
{
return new PowershellParallelLinqSupport<TSource>(query.Reverse());
}
public bool SequenceEqual(ParallelQuery<TSource> second)
{
return query.SequenceEqual(second);
}
public bool SequenceEqual(PowershellParallelLinqSupport<TSource> second)
{
return SequenceEqual(second.AsParallelQuery());
}
public bool SequenceEqual(ParallelQuery<TSource> second, IEqualityComparer<TSource> comparer)
{
return query.SequenceEqual(second, comparer);
}
public bool SequenceEqual(PowershellParallelLinqSupport<TSource> second, IEqualityComparer<TSource> comparer)
{
return SequenceEqual(second.AsParallelQuery(), comparer);
}
public TSource Single()
{
return query.Single();
}
public TSource Single(Func<TSource, bool> predicate)
{
return query.Single(predicate);
}
public TSource SingleOrDefault()
{
return query.SingleOrDefault();
}
public TSource SingleOrDefault(Func<TSource, bool> predicate)
{
return query.SingleOrDefault(predicate);
}
public PowershellParallelLinqSupport<TSource> Skip(int count)
{
return new PowershellParallelLinqSupport<TSource>(query.Skip(count));
}
public PowershellParallelLinqSupport<TSource> SkipWhile(Func<TSource, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.SkipWhile(predicate));
}
public PowershellParallelLinqSupport<TSource> SkipWhile(Func<TSource, int, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.SkipWhile(predicate));
}
public decimal? Sum(Func<TSource, decimal?> selector)
{
return query.Sum(selector);
}
public decimal Sum(Func<TSource, decimal> selector)
{
return query.Sum(selector);
}
public double? Sum(Func<TSource, double?> selector)
{
return query.Sum(selector);
}
public double Sum(Func<TSource, double> selector)
{
return query.Sum(selector);
}
public float? Sum(Func<TSource, float?> selector)
{
return query.Sum(selector);
}
public float Sum(Func<TSource, float> selector)
{
return query.Sum(selector);
}
public int? Sum(Func<TSource, int?> selector)
{
return query.Sum(selector);
}
public int Sum(Func<TSource, int> selector)
{
return query.Sum(selector);
}
public long? Sum(Func<TSource, long?> selector)
{
return query.Sum(selector);
}
public long Sum(Func<TSource, long> selector)
{
return query.Sum(selector);
}
public PowershellParallelLinqSupport<TSource> Take(int count)
{
return new PowershellParallelLinqSupport<TSource>(query.Take(count));
}
public PowershellParallelLinqSupport<TSource> TakeWhile(Func<TSource, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.TakeWhile(predicate));
}
public PowershellParallelLinqSupport<TSource> TakeWhile(Func<TSource, int, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.TakeWhile(predicate));
}
public TSource[] ToArray()
{
return query.ToArray();
}
public List<TSource> ToList()
{
return query.ToList();
}
public PowershellParallelLinqSupport<TSource> Union(ParallelQuery<TSource> second)
{
return new PowershellParallelLinqSupport<TSource>(query.Union(second));
}
public PowershellParallelLinqSupport<TSource> Union(PowershellParallelLinqSupport<TSource> second)
{
return Union(second.AsParallelQuery());
}
public PowershellParallelLinqSupport<TSource> Union(ParallelQuery<TSource> second, IEqualityComparer<TSource> comparer)
{
return new PowershellParallelLinqSupport<TSource>(query.Union(second, comparer));
}
public PowershellParallelLinqSupport<TSource> Union(PowershellParallelLinqSupport<TSource> second, IEqualityComparer<TSource> comparer)
{
return Union(second.AsParallelQuery(), comparer);
}
public PowershellParallelLinqSupport<TSource> WithCancellation(CancellationToken cancellationToken)
{
return new PowershellParallelLinqSupport<TSource>(query.WithCancellation(cancellationToken));
}
public PowershellParallelLinqSupport<TSource> WithDegreeOfParallelism(int degreeOfParallelism)
{
return new PowershellParallelLinqSupport<TSource>(query.WithDegreeOfParallelism(degreeOfParallelism));
}
public PowershellParallelLinqSupport<TSource> WithExecutionMode(ParallelExecutionMode executionMode)
{
return new PowershellParallelLinqSupport<TSource>(query.WithExecutionMode(executionMode));
}
public PowershellParallelLinqSupport<TSource> WithMergeOptions(ParallelMergeOptions mergeOptions)
{
return new PowershellParallelLinqSupport<TSource>(query.WithMergeOptions(mergeOptions));
}
public PowershellParallelLinqSupport<TSource> Where(Func<TSource, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.Where(predicate));
}
public PowershellParallelLinqSupport<TSource> Where(Func<TSource, int, bool> predicate)
{
return new PowershellParallelLinqSupport<TSource>(query.Where(predicate));
}
}
public class PowershellParallelOrderedLinqSupport<TSource> : PowershellParallelLinqSupport<TSource>
{
private readonly OrderedParallelQuery<TSource> query;
public PowershellParallelOrderedLinqSupport(OrderedParallelQuery<TSource> query)
: base(query)
{
this.query = query;
}
public OrderedParallelQuery<TSource> AsOrderedParallelQuery()
{
return query;
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8083577B-4353-47C2-94E8-1F0E553B4930}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PowershellLinqSupport</RootNamespace>
<AssemblyName>PowershellLinqSupport</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="PowershellLinqSupport.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>PowershellLinqSupport</id>
<version>1.0.3</version>
<authors>Jeremy Beavon</authors>
<projectUrl>https://gist.github.com/jeremybeavon/fdb603ba4dfb19a1b40c</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Provides wrapper classes for LINQ methods.</description>
</metadata>
<files>
<file src="bin\Release\PowershellLinqSupport.dll" target="tools\PowershellLinqSupport.dll" />
</files>
</package>
@jeremybeavon
Copy link
Author

Usage

Add-Type -Path PowershellLinqSupport
$intList = New-Object -TypeName PowershellLinqSupport[int] -ArgumentList 1..5
$intList.Any({param($int) $int -le 4})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment