public bool EvalExpressionNET(Parameter parameter)
        {
            StringBuilder statementBuilder = new StringBuilder()
                                             .AppendLine("new int[] {")
                                             .AppendJoin("," + Environment.NewLine, parameter.Statements)
                                             .AppendLine("}");

            using (EvalContext context = new EvalContext())
            {
                context.UseLocalCache = true;

                int[] results = context.Execute <int[]>(statementBuilder.ToString());

                return(Assert(results, parameter.Sum));
            }
        }
Пример #2
0
        public static Type gettype(string s)
        {
            try
            {
                if (evalContext == null)
                {
                    evalContext = new EvalContext();
                    evalContext.UseLocalCache = true;
                }

                //AppHelper.ShowInformation(typestring);
                var type = evalContext.Execute <Type>("typeof(" + s + ")");
                return(type);
            }
            catch (Exception e)
            {
                return(null);
            }
        }