예제 #1
0
        public virtual CorrectionResult RunMethod(_Assembly assembly, Question question)
        {
            var        instance   = assembly.CreateInstance(question.ContractDefinition.ClassName);
            var        type       = instance.GetType();
            MethodInfo methodInfo = type.GetMethod(question.ContractDefinition.MethodName);

            return(new CorrectionResult {
                Result = methodInfo.Invoke(instance, null).ToString()
            });
        }
예제 #2
0
        public object Eval(string expression, IDictionary <object, object> args)
        {
            var       sources = _codeGenerator.GetSources(_code, expression, _namespaces, _definitions);
            _Assembly asm     = _compilerImpl.Compile(sources, _references);
            var       obj     = (IComparer <IDictionary <object, object> >)asm.CreateInstance("CoApp.Eval.GeneratedCode.Foo");
            var       result  = new Dictionary <object, object>();

            _permissions.PermitOnly();
            obj.Compare(args, result);
            return(result[String.Empty]);
        }