Ejemplo n.º 1
0
        public IDictionary <string, string> GetDecimalOperators()
        {
            var decimalOperators   = typeof(DecimalOperator).GetEnumValues().Cast <DecimalOperator>();
            var operatorDictionary = new Dictionary <string, string>();

            foreach (DecimalOperator dop in decimalOperators)
            {
                string name  = dop.ToString();
                string value = DecimalEngine.GetDecimalIndexFromDecimalOperatorEnum(dop).ToString();
                operatorDictionary.Add(name, value);
            }

            return(operatorDictionary);
        }
Ejemplo n.º 2
0
        private static DecimalEngine CreateEngineFromSession()
        {
            var decimalOperatorRange = (IEnumerable <DecimalOperator>)HttpContext.Current.Session[QuizDecimalOpertorRangeSessionKey];
            int floorOp;
            int ceilingOp;
            int firstOp = DecimalEngine.GetDecimalIndexFromDecimalOperatorEnum(decimalOperatorRange.First());
            int lastOp  = DecimalEngine.GetDecimalIndexFromDecimalOperatorEnum(decimalOperatorRange.Last());

            if (firstOp > lastOp)
            {
                floorOp   = lastOp;
                ceilingOp = firstOp;
            }
            else
            {
                floorOp   = firstOp;
                ceilingOp = lastOp;
            }

            return(new DecimalEngine(DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(floorOp), DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(ceilingOp)));
        }