コード例 #1
0
 public void ReplaceApproachWithLambda(Dictionary <string, object> dict, string formula)
 {
     foreach (var item in dict)
     {
         formula = formula.Replace("[" + item.Key + "]", item.Value.ToString());
     }
     var expression = new NCalc.Expression(formula);
     var lambda     = expression.ToLambda <int>();
     var output     = lambda();
 }
コード例 #2
0
        public int ParameterAccess2(string formula)
        {
            var expression = new NCalc.Expression(formula);
            var lambda     = expression.ToLambda <Context, int>();
            var context    = new Context {
                Variable1 = 4, Variable2 = 9
            };
            var output = lambda(context);

            return(output);
        }
コード例 #3
0
        public int NCalcLamdaMethod(string inputString)
        {
            var e       = new NCalc.Expression(inputString);
            var context = new Context {
                Variable1 = 2, Variable2 = 3
            };
            var lambda = e.ToLambda <Context, int>();
            var output = lambda(context);

            return(output);
        }