コード例 #1
0
        private void CompileCode(string code, object args)
        {
            Dictionary <string, Argument> dictionary = args as Dictionary <string, Argument>;

            if (code != null && dictionary != null)
            {
                string importsHeader = GetImportsHeader(base.Context, base.ModelItem);
                List <Tuple <string, Type, ArgumentDirection> > list = new List <Tuple <string, Type, ArgumentDirection> >(dictionary.Count);
                foreach (KeyValuePair <string, Argument> item in dictionary)
                {
                    list.Add(new Tuple <string, Type, ArgumentDirection>(item.Key, item.Value.ArgumentType, item.Value.Direction));
                }
                try
                {
                    InvokeCodeActivity.CreateCompilerRunner(code, importsHeader, list);
                    (base.ModelItem.GetCurrentValue() as InvokeCodeActivity).SetSuccessfulCompilation();
                    base.ModelItem.Properties["CompilationError"].ComputedValue = "";
                }
                catch (Exception ex)
                {
                    (base.ModelItem.GetCurrentValue() as InvokeCodeActivity).SetCompilationError(ex.Message);
                    base.ModelItem.Properties["CompilationError"].ComputedValue = ex.Message;
                }
            }
        }
コード例 #2
0
 private string GetImportsHeader(EditingContext context, ModelItem modelItem)
 {
     return(InvokeCodeActivity.GetImports(EnumerateImports(context, modelItem)));
 }