本文整理汇总了C#中Labeled.Item方法的典型用法代码示例。如果您正苦于以下问题:C# Labeled.Item方法的具体用法?C# Labeled.Item怎么用?C# Labeled.Item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Labeled
的用法示例。
在下文中一共展示了Labeled.Item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Aggregate_OperationCanceledException_PreCanceled
public static void Aggregate_OperationCanceledException_PreCanceled(Labeled<Func<ParallelQuery<int>, Action, ParallelQuery<int>>> operation)
{
AssertThrows.AlreadyCanceled(source => operation.Item(source, () => { }).Aggregate((x, y) => x));
AssertThrows.AlreadyCanceled(source => operation.Item(source, () => { }).Aggregate(0, (x, y) => x + y));
AssertThrows.AlreadyCanceled(source => operation.Item(source, () => { }).Aggregate(0, (x, y) => x + y, r => r));
AssertThrows.AlreadyCanceled(source => operation.Item(source, () => { }).Aggregate(0, (a, x) => a + x, (l, r) => l + r, r => r));
AssertThrows.AlreadyCanceled(source => operation.Item(source, () => { }).Aggregate(() => 0, (a, x) => a + x, (l, r) => l + r, r => r));
}
示例2: Aggregate_OperationCanceledException
public static void Aggregate_OperationCanceledException(Labeled<Func<ParallelQuery<int>, Action, ParallelQuery<int>>> operation)
{
AssertThrows.EventuallyCanceled((source, canceler) => operation.Item(source, canceler).Aggregate((i, j) => j));
AssertThrows.EventuallyCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j));
AssertThrows.EventuallyCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, i => i));
AssertThrows.EventuallyCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, (i, j) => i, i => i));
AssertThrows.EventuallyCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(() => 0, (i, j) => j, (i, j) => i, i => i));
}
示例3: Aggregate_AggregateException
public static void Aggregate_AggregateException(Labeled<Operation> source, Labeled<Operation> operation)
{
AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).Aggregate((x, y) => x));
AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).Aggregate(0, (x, y) => x + y));
AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).Aggregate(0, (x, y) => x + y, r => r));
AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).Aggregate(0, (a, x) => a + x, (l, r) => l + r, r => r));
AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).Aggregate(() => 0, (a, x) => a + x, (l, r) => l + r, r => r));
}
示例4: Concat_Unordered_NotPipelined
public static void Concat_Unordered_NotPipelined(Labeled<Operation> operation)
{
IntegerRangeSet seen = new IntegerRangeSet(DefaultStart, DefaultSize);
Assert.All(
operation.Item(DefaultStart, DefaultSize / 2, DefaultSource)
.Concat(operation.Item(DefaultStart + DefaultSize / 2, DefaultSize / 2, DefaultSource)).ToList(),
x => seen.Add(x)
);
seen.AssertComplete();
}
示例5: Concat_Unordered
public static void Concat_Unordered(Labeled<Operation> operation)
{
IntegerRangeSet seen = new IntegerRangeSet(DefaultStart, DefaultSize);
foreach (int i in operation.Item(DefaultStart, DefaultSize / 2, DefaultSource)
.Concat(operation.Item(DefaultStart + DefaultSize / 2, DefaultSize / 2, DefaultSource)))
{
seen.Add(i);
}
seen.AssertComplete();
}
示例6: Aggregate_AggregateException_Wraps_OperationCanceledException
public static void Aggregate_AggregateException_Wraps_OperationCanceledException(Labeled<Func<ParallelQuery<int>, Action, ParallelQuery<int>>> operation)
{
AssertThrows.OtherTokenCanceled((source, canceler) => operation.Item(source, canceler).Aggregate((i, j) => j));
AssertThrows.OtherTokenCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j));
AssertThrows.OtherTokenCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, i => i));
AssertThrows.OtherTokenCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, (i, j) => i, i => i));
AssertThrows.OtherTokenCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(() => 0, (i, j) => j, (i, j) => i, i => i));
AssertThrows.SameTokenNotCanceled((source, canceler) => operation.Item(source, canceler).Aggregate((i, j) => j));
AssertThrows.SameTokenNotCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j));
AssertThrows.SameTokenNotCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, i => i));
AssertThrows.SameTokenNotCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(0, (i, j) => j, (i, j) => i, i => i));
AssertThrows.SameTokenNotCanceled((source, canceler) => operation.Item(source, canceler).Aggregate(() => 0, (i, j) => j, (i, j) => i, i => i));
}
示例7: DefaultIfEmpty_Unordered
public static void DefaultIfEmpty_Unordered(Labeled<Operation> operation)
{
IntegerRangeSet seen = new IntegerRangeSet(DefaultStart, DefaultSize);
foreach (int i in operation.Item(DefaultStart, DefaultSize, DefaultSource).DefaultIfEmpty())
{
seen.Add(i);
}
seen.AssertComplete();
}
示例8: Cast_Unordered
public static void Cast_Unordered(Labeled<Operation> operation)
{
IntegerRangeSet seen = new IntegerRangeSet(DefaultStart, DefaultSize);
foreach (int? i in operation.Item(DefaultStart, DefaultSize, DefaultSource).Cast<int?>())
{
Assert.True(i.HasValue);
seen.Add(i.Value);
}
seen.AssertComplete();
}
示例9: SingleOrDefault
public static void SingleOrDefault(Labeled<Operation> operation)
{
Assert.Equal(DefaultStart, operation.Item(DefaultStart, 1, DefaultSource).SingleOrDefault());
Assert.Equal(DefaultStart + DefaultSize / 2, operation.Item(DefaultStart, DefaultSize, DefaultSource).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));
if (!operation.ToString().StartsWith("DefaultIfEmpty"))
{
Assert.Equal(default(int), operation.Item(DefaultStart, 0, DefaultSource).SingleOrDefault());
Assert.Equal(default(int), operation.Item(DefaultStart, 0, DefaultSource).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));
}
}
示例10: SequenceEqual_Self
public static void SequenceEqual_Self(Labeled<Operation> source, Labeled<Operation> operation)
{
Assert.True(operation.Item(DefaultStart, DefaultSize, source.Item).SequenceEqual(operation.Item(DefaultStart, DefaultSize, source.Item)));
}
示例11: SequenceEqual
public static void SequenceEqual(Labeled<Operation> source, Labeled<Operation> operation)
{
Assert.True(operation.Item(DefaultStart, DefaultSize, source.Item).SequenceEqual(ParallelEnumerable.Range(DefaultStart, DefaultSize).AsOrdered()));
Assert.True(ParallelEnumerable.Range(DefaultStart, DefaultSize).AsOrdered().SequenceEqual(operation.Item(DefaultStart, DefaultSize, source.Item)));
}
示例12: SelectMany_Indexed_ResultSelector
public static void SelectMany_Indexed_ResultSelector(Labeled<Operation> source, Labeled<Operation> operation)
{
int seen = -DefaultStart;
foreach (int i in operation.Item(0, DefaultSize, source.Item).SelectMany((x, index) => { Assert.Equal(index, x); return new[] { 0, -1 }; }, (x, y) => y + -DefaultStart - 2 * x))
{
Assert.Equal(seen--, i);
}
Assert.Equal(-DefaultStart - DefaultSize * 2, seen);
}
示例13: SelectMany_NotPipelined
public static void SelectMany_NotPipelined(Labeled<Operation> source, Labeled<Operation> operation)
{
int seen = -DefaultStart;
Assert.All(operation.Item(0, DefaultSize, source.Item).SelectMany(x => new[] { 0, -1 }.Select(y => y + -DefaultStart - 2 * x)).ToList(), x => Assert.Equal(seen--, x));
Assert.Equal(-DefaultStart - DefaultSize * 2, seen);
}
示例14: Select_Indexed_NotPipelined
public static void Select_Indexed_NotPipelined(Labeled<Operation> source, Labeled<Operation> operation)
{
int seen = -DefaultStart;
Assert.All(operation.Item(DefaultStart, DefaultSize, source.Item).Select((x, index) => { Assert.Equal(DefaultStart + index, x); return -x; }).ToList(), x => Assert.Equal(seen--, x));
Assert.Equal(-DefaultStart - DefaultSize, seen);
}
示例15: OfType_Other_NotPipelined
public static void OfType_Other_NotPipelined(Labeled<Operation> source, Labeled<Operation> operation)
{
Assert.Empty(operation.Item(DefaultStart, DefaultSize, source.Item).OfType<long>().ToList());
}