public void PerformCalculation()
        {
            object result;

            foreach (CalcRequest calcItem in calcStack)
            {
                if ((calcItem.Operands.Length == 3) && (calcItem.Operation == Operation.SUM.ToString())) //Todo check for all operations
                {
                    dynamic Message = _coreService.CreateMessage("Calculation");
                    Message.Operator = Operation.SUM;
                    Message.Operand  = calcItem.Operands;
                    result           = (calcItem.Operation == Operation.SUM.ToString()) ? calcItem.Operands[0] + calcItem.Operands[1] : 0;
                    Message.Result   = result;
                    _coreService.PostMessage(Message);
                }
                else if ((calcItem.Operands.Length == 3) && (calcItem.Operation == Operation.SUB.ToString())) //Todo check for all operations
                {
                    dynamic Message = _coreService.CreateMessage("Calculation");
                    Message.Operator = Operation.SUB;
                    Message.Operand  = calcItem.Operands;
                    result           = (calcItem.Operation == Operation.SUB.ToString()) ? calcItem.Operands[0] - calcItem.Operands[1] : 0;
                    Message.Result   = result;
                    _coreService.PostMessage(Message);
                }
                else if ((calcItem.Operands.Length == 3) && (calcItem.Operation == Operation.MUL.ToString())) //Todo check for all operations
                {
                    dynamic Message = _coreService.CreateMessage("Calculation");
                    Message.Operator = Operation.MUL;
                    Message.Operand  = calcItem.Operands;
                    result           = (calcItem.Operation == Operation.MUL.ToString()) ? calcItem.Operands[0] * calcItem.Operands[1] : 0;
                    Message.Result   = result;
                    _coreService.PostMessage(Message);
                }
                else if ((calcItem.Operands.Length == 3) && (calcItem.Operation == Operation.DIV.ToString())) //Todo check for all operations
                {
                    dynamic Message = _coreService.CreateMessage("Calculation");
                    Message.Operator = Operation.DIV;
                    Message.Operand  = calcItem.Operands;
                    result           = (calcItem.Operation == Operation.DIV.ToString()) ? calcItem.Operands[0] / calcItem.Operands[1] : 0;
                    Message.Result   = result;
                    _coreService.PostMessage(Message);
                }
            }

            //   return result;
        }
Пример #2
0
        private async void SetOperand()
        {
            dynamic Message = _coreService.CreateMessage("Operand");
            await Task.Delay(300);

            Operand1        = rnd.Next(1, 100);
            Message.Operand = Operand1;
            _coreService.PostMessage(Message);
        }