本文整理汇总了C#中LabeledOperation.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LabeledOperation.ToString方法的具体用法?C# LabeledOperation.ToString怎么用?C# LabeledOperation.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabeledOperation
的用法示例。
在下文中一共展示了LabeledOperation.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Append
public LabeledOperation Append(LabeledOperation next)
{
Operation op = Item;
Operation nxt = next.Item;
return Label(ToString() + "|" + next.ToString(), (start, count, source) => nxt(start, count, (s, c, ignore) => op(s, c, source)));
}
示例2: BinaryOperations
private static IEnumerable<LabeledOperation> BinaryOperations(LabeledOperation otherSource)
{
String label = otherSource.ToString();
Operation other = otherSource.Item;
yield return Label("Concat-Right:" + label, (start, count, source) => source(start, count / 2).Concat(other(start + count / 2, count / 2 + count % 2)));
yield return Label("Concat-Left:" + label, (start, count, source) => other(start, count / 2).Concat(source(start + count / 2, count / 2 + count % 2)));
// Comparator needs to cover _source_ size, as which of two "equal" items is returned is undefined for unordered collections.
yield return Label("Except-Right:" + label, (start, count, source) => source(start, count + count / 2).Except(other(start + count, count), new ModularCongruenceComparer(count * 2)));
yield return Label("Except-Left:" + label, (start, count, source) => other(start, count + count / 2).Except(source(start + count, count), new ModularCongruenceComparer(count * 2)));
yield return Label("GroupJoin-Right:" + label, (start, count, source) => source(start, count).GroupJoin(other(start, count * CountFactor), x => x, y => y % count, (x, g) => g.Min(), new ModularCongruenceComparer(count)));
yield return Label("GroupJoin-Left:" + label, (start, count, source) => other(start, count).GroupJoin(source(start, count * CountFactor), x => x, y => y % count, (x, g) => g.Min(), new ModularCongruenceComparer(count)));
// Comparator needs to cover _source_ size, as which of two "equal" items is returned is undefined.
yield return Label("Intersect-Right:" + label, (start, count, source) => source(start, count + count / 2).Intersect(other(start - count / 2, count + count / 2), new ModularCongruenceComparer(count * 2)));
yield return Label("Intersect-Left:" + label, (start, count, source) => other(start, count + count / 2).Intersect(source(start - count / 2, count + count / 2), new ModularCongruenceComparer(count * 2)));
yield return Label("Join-Right:" + label, (start, count, source) => source(0, count).Join(other(start, count), x => x, y => y - start, (x, y) => x + start, new ModularCongruenceComparer(count)));
yield return Label("Join-Left:" + label, (start, count, source) => other(0, count).Join(source(start, count), x => x, y => y - start, (x, y) => x + start, new ModularCongruenceComparer(count)));
yield return Label("Union-Right:" + label, (start, count, source) => source(start, count * 3 / 4).Union(other(start + count / 2, count / 2 + count % 2), new ModularCongruenceComparer(count)));
yield return Label("Union-Left:" + label, (start, count, source) => other(start, count * 3 / 4).Union(source(start + count / 2, count / 2 + count % 2), new ModularCongruenceComparer(count)));
// When both sources are unordered any element can be matched to any other, so a different check is required.
yield return Label("Zip-Unordered-Right:" + label, (start, count, source) => source(0, count).Zip(other(start * 2, count), (x, y) => x + start));
yield return Label("Zip-Unordered-Left:" + label, (start, count, source) => other(start * 2, count).Zip(source(0, count), (x, y) => y + start));
}
示例3: SingleOrDefault
public static void SingleOrDefault(LabeledOperation source, LabeledOperation operation)
{
Assert.Equal(DefaultStart, operation.Item(DefaultStart, 1, source.Item).SingleOrDefault());
Assert.Equal(DefaultStart + DefaultSize / 2, operation.Item(DefaultStart, DefaultSize, source.Item).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));
if (!operation.ToString().StartsWith("DefaultIfEmpty"))
{
Assert.Equal(default(int), operation.Item(DefaultStart, 0, source.Item).SingleOrDefault());
Assert.Equal(default(int), operation.Item(DefaultStart, 0, source.Item).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));
}
}
示例4: FirstOrDefault_AggregateException
public static void FirstOrDefault_AggregateException(LabeledOperation source, LabeledOperation operation)
{
// Concat seems able to return the first element when the left query does not fail ("first" query).
// This test might be flaky in the case that it decides to run the right query too...
if (operation.ToString().Contains("Concat-Left"))
{
Assert.InRange(operation.Item(DefaultStart, DefaultSize, source.Item).FirstOrDefault(), DefaultStart, DefaultStart + DefaultSize);
}
else
{
Functions.AssertThrowsWrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).FirstOrDefault());
}
Functions.AssertThrowsWrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).FirstOrDefault(x => false));
}
示例5: GetEnumerator_AggregateException
public static void GetEnumerator_AggregateException(LabeledOperation source, LabeledOperation operation)
{
IEnumerator<int> enumerator = operation.Item(DefaultStart, DefaultSize, source.Item).GetEnumerator();
// Spin until concat hits
// Union-Left needs to spin more than once rarely.
if (operation.ToString().StartsWith("Concat") || operation.ToString().StartsWith("Union-Left:ParallelEnumerable"))
{
Functions.AssertThrowsWrapped<DeliberateTestException>(() => { while (enumerator.MoveNext()) ; });
}
else
{
Functions.AssertThrowsWrapped<DeliberateTestException>(() => enumerator.MoveNext());
}
if (operation.ToString().StartsWith("OrderBy") || operation.ToString().StartsWith("ThenBy"))
{
Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext());
}
else
{
Assert.False(enumerator.MoveNext());
}
}