Most scriptCommands support one or multiple variable keys, that point to variables inside ParameterDic, ScriptCommand access these variables through ParameterDic.GetValue("{variableName}") method.

For examples,
IScriptCommand addCommand = ScriptCommands.Add("{Left}", "{Right}", "{Result}", 
  ScriptCommands.PrintDebug("{Result}"));


Add scriptcommand take three keys (value1, value2 and destination), the sum of first two variables is stored in destination variable when the script is run.

Noted that all variables are enclosed in a bracket {}.

Sub-Property

Similar to WPF, one can use dot (.) in variable to access it's sub-property, field or return value of parameterless method(). Subitem are obtained using reflection, and recursive is supported.

var setPropertyCommand =        
  ScriptCommands.SetProperty("{PSI}", "FileName", "{Value}", 
	ScriptCommands.PrintDebug("{PSI.FileName}", 
		ScriptCommands.SetPropertyValue("{PSI}", (ProcessStartInfo p) => p.FileName, "GHI.txt", 
			ScriptCommands.PrintDebug("{PSI.FileName}")
	))));  

await ScriptRunner.RunScriptAsync(new ParameterDic() { 
                { "PSI", new ProcessStartInfo() { FileName = "ABC.txt" } },
				{ "Value", "DEF.txt" }
            }, setPropertyCommand);


Sub-ParameterDic
One can assign a disk based or a global static ParameterDic as a variable in the running ParameterDic, see SubParameterDic.

Last edited Oct 18, 2014 at 9:56 AM by lycj, version 3

Comments

No comments yet.