/// <inheritdoc /> public override Trilean VerifyCondition(CilExecutionContext context, CilInstruction instruction) { var(left, right) = BinaryOperationHelper.PeekBinaryOperationArguments(context); return((left, right) switch { (IntegerValue a, IntegerValue b) => VerifyCondition(context, instruction, a, b), (FValue a, FValue b) => VerifyCondition(context, instruction, a, b), (OValue a, OValue b) => VerifyCondition(context, instruction, a, b), _ => Trilean.Unknown, });
/// <inheritdoc /> public DispatchResult Execute(CilExecutionContext context, CilInstruction instruction) { var(left, right) = BinaryOperationHelper.PopBinaryOperationArguments(context); var result = (left, right) switch { (IntegerValue a, IntegerValue b) => Execute(context, instruction, a, b), (FValue a, FValue b) => Execute(context, instruction, a, b), (OValue a, OValue b) => Execute(context, instruction, a, b), _ => DispatchResult.InvalidProgram(), };
public T Convert(T fromAmount, Currency fromCurrency, Currency toCurrency) { var key = GenerateKey(fromCurrency, toCurrency); if (!this.rateCache.ContainsKey(key)) { this.PopulateRate(fromCurrency, toCurrency); } return(BinaryOperationHelper.MultiplyChecked(fromAmount, this.rateCache[key])); }
/// <inheritdoc /> protected override Trilean VerifyCondition(ExecutionContext context, CilInstruction instruction) { var(left, right) = BinaryOperationHelper.PopBinaryOperationArguments(context); return((left, right) switch { (IntegerValue a, IntegerValue b) => VerifyCondition(context, instruction, a, b), (FValue a, FValue b) => VerifyCondition(context, instruction, a, b), (OValue a, OValue b) => VerifyCondition(context, instruction, a, b), _ => null, });
public static Money <T> operator ++(Money <T> me) { var val = BinaryOperationHelper.AddChecked(me.Amount, NumericTypeHelper.ConvertTo <T>(1)); return(new Money <T>(val, me.Currency)); }
public static Money <T> operator >>(Money <T> money, int operand) { var newAmount = BinaryOperationHelper.RightShift(money.Amount, operand); return(new Money <T>(newAmount, money.Currency)); }