本文整理汇总了C#中IObservable.AsOperational方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.AsOperational方法的具体用法?C# IObservable.AsOperational怎么用?C# IObservable.AsOperational使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.AsOperational方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsOperationalInternal
private static OperationalObservable<short, int> AsOperationalInternal(
IObservable<short> source,
Func<IObservable<short>, IObservable<short>, Func<short, short, int>, IObservable<int>> binaryOperation = null,
Func<IObservable<int>, IObservable<int>, Func<int, int, int>, IObservable<int>> resultBinaryOperation = null,
Func<IObservable<short>, IObservable<int>, Func<short, int, int>, IObservable<int>> shiftOperation = null,
Func<IObservable<short>, IObservable<short>, Func<short, short, bool>, IObservable<bool>> comparisonOperation = null,
IComparer<short> comparer = null,
IEqualityComparer<short> equalityComparer = null)
{
Contract.Requires(source != null);
Contract.Ensures(!object.Equals(Contract.Result<OperationalObservable<short, int>>(), null));
return source.AsOperational(
result => AsOperationalInternal(result, resultBinaryOperation),
binaryOperation: binaryOperation,
comparisonOperation: comparisonOperation,
shiftOperation: shiftOperation,
add: (first, second) => first + second,
subtract: (first, second) => first - second,
multiply: (first, second) => first * second,
divide: (first, second) => first / second,
remainder: (first, second) => first % second,
leftShift: (first, second) => first << second,
rightShift: (first, second) => first >> second,
positive: value => +value,
negative: value => -value,
complement: value => ~value,
not: null,
equals: (first, second) => equalityComparer == null ? first == second : equalityComparer.Equals(first, second),
notEquals: (first, second) => equalityComparer == null ? first != second : !equalityComparer.Equals(first, second),
lessThan: (first, second) => comparer == null ? first < second : comparer.Compare(first, second) < 0,
lessThanOrEqual: (first, second) => comparer == null ? first <= second : comparer.Compare(first, second) <= 0,
greaterThan: (first, second) => comparer == null ? first > second : comparer.Compare(first, second) > 0,
greaterThanOrEqual: (first, second) => comparer == null ? first >= second : comparer.Compare(first, second) >= 0,
and: (first, second) => first & second,
or: (first, second) => first | second,
xor: (first, second) => first ^ second);
}