/// <summary> /// creates a new <see cref="AssignStateNode"/> /// </summary> /// <param name="node">node of which to assign result</param> /// <param name="variableName">name of variable to assign result to</param> /// <param name="variableoperation">operation to use when assigning variable</param> /// <param name="compiler">compiler to use to compile variable operation</param> public AssignStateNode(IInstanceNode node, string variableName, VariableOperation variableoperation, IScriptCompiler compiler) { this.node = node; VariableName = variableName; if (variableoperation != VariableOperation.Assign) { operation = compiler.CompileCode($"$lhs{variableoperation.ToOperatorString()}$rhs", ScriptLanguage.NCScript); } }
/// <summary> /// builds argument scripts for workflow nodes /// </summary> /// <param name="arguments">arguments to use as code source</param> /// <param name="compiler">compiler used to compile scripts</param> /// <returns></returns> public static IDictionary <string, IScript> BuildArguments(this IDictionary <string, object> arguments, IScriptCompiler compiler, ScriptLanguage?language) { if (arguments == null) { return(null); } Dictionary <string, IScript> result = new Dictionary <string, IScript>(); foreach ((string key, object value) in arguments) { if (value is string code) { result[key] = compiler.CompileCode(code, language ?? ScriptLanguage.NCScript) ?? new ConstantValueScript(null); } else { result[key] = new ConstantValueScript(value); } } return(result); }