コード例 #1
0
ファイル: BinaryBranchHandler.cs プロジェクト: lanicon/Echo
        /// <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,
            });
コード例 #2
0
ファイル: BinaryNumericOperator.cs プロジェクト: lanicon/Echo
        /// <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(),
            };
コード例 #3
0
        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]));
        }
コード例 #4
0
        /// <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,
            });
コード例 #5
0
        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));
        }
コード例 #6
0
        public static Money <T> operator >>(Money <T> money, int operand)
        {
            var newAmount = BinaryOperationHelper.RightShift(money.Amount, operand);

            return(new Money <T>(newAmount, money.Currency));
        }