/// <summary> /// Serializable, shortcut method for [AssignValueConverter], which a specific item from an array from a variable and assign to another variable. /// </summary> /// <param name="arrayVariable"></param> /// <param name="id"></param> /// <param name="destinationVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand GetArrayItem(string arrayVariable = "{Array}", int id = 0, string destinationVariable = "{Destination}", IScriptCommand nextCommand = null) { string valueConverterVariable = ParameterDicUtils.CombineVariable(arrayVariable, "Converter"); return(AssignValueConverter(ValueConverterType.GetArrayItem, valueConverterVariable, ScriptCommands.Reassign(arrayVariable, valueConverterVariable, destinationVariable, nextCommand), id)); }
/// <summary> /// Set property of an object in ParameterDic to another object in ParameterDic. /// <example> /// ScriptCommands.SetProperty("{PSI}", "FileName", "{Value}") /// </example> /// </summary> /// <param name="sourceObjectVariable"></param> /// <param name="propertyName"></param> /// <param name="valueVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand SetProperty(string sourceObjectVariable = "{Source}", string propertyName = "Property", string valueVariable = "{Value}", IScriptCommand nextCommand = null) { string valueConverterVariable = ParameterDicUtils.CombineVariable(sourceObjectVariable, "Converter"); return(AssignValueConverter(ValueConverterType.SetProperty, valueConverterVariable, ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable, valueVariable, nextCommand), propertyName)); }
///// <summary> ///// Add variables (using Expression) to destination. ///// </summary> ///// <param name="sourceObjectVariable"></param> ///// <param name="addValues"></param> ///// <param name="destinationVariable"></param> ///// <param name="nextCommand"></param> ///// <returns></returns> //public static IScriptCommand Add(string sourceObjectVariable = "{Source}", // object[] addValues = null, // string destinationVariable = "{Destination}", IScriptCommand nextCommand = null) //{ // string valueConverterVariable = ParameterDicUtils.CombineVariable(sourceObjectVariable, "Converter"); // return AssignValueConverter(ValueConverterType.AddValue, valueConverterVariable, // ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable, // destinationVariable, false, nextCommand), addValues); //} /// <summary> /// Concat array to destination /// </summary> /// <param name="sourceObjectVariable"></param> /// <param name="addValues"></param> /// <param name="destinationVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand ConcatArray(string sourceObjectVariable = "{Source}", object[] addValues = null, string destinationVariable = "{Destination}", IScriptCommand nextCommand = null) { string valueConverterVariable = ParameterDicUtils.CombineVariable(sourceObjectVariable, "Converter"); return(AssignValueConverter(ValueConverterType.ConcatArray, valueConverterVariable, ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable, destinationVariable, nextCommand), addValues)); }
/// <summary> /// Serializable, Run IfValue comparsion based on the length of an array in ParameterDic. /// </summary> /// <param name="op"></param> /// <param name="arrayVariable"></param> /// <param name="valueVariable"></param> /// <param name="trueCommand"></param> /// <param name="otherwiseCommand"></param> /// <returns></returns> public static IScriptCommand IfArrayLength(ComparsionOperator op, string arrayVariable = "{array}", string valueVariable = "{value}", IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { return (ScriptCommands.IfAssigned(arrayVariable, ScriptCommands.AssignValueConverter(ValueConverterType.GetProperty, "{GetPropertyConverter}", ScriptCommands.Reassign(arrayVariable, "{GetPropertyConverter}", "{ArrayLength}", ScriptCommands.PrintLogger(LogLevel.Debug, "Length of array is {ArrayLength}", ScriptCommands.IfValue(op, "{ArrayLength}", valueVariable, trueCommand, otherwiseCommand))), "Length"), otherwiseCommand)); }
/// <summary> /// Serializable, shortcut method for [AssignValueConverter], which obtains method result of a property from a variable and assign to another variable. /// </summary> /// <param name="sourceObjectVariable"></param> /// <param name="methodName"></param> /// <param name="parameters"></param> /// <param name="destinationVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand ExecuteFunc(string sourceObjectVariable = "{Source}", string methodName = "Method", object[] parameters = null, string destinationVariable = "{Destination}", IScriptCommand nextCommand = null) { string valueConverterVariable = ParameterDicUtils.CombineVariable(sourceObjectVariable, "Converter"); List <object> methodParams = new List <object>(); methodParams.Add(methodName); if (parameters != null) { methodParams.AddRange(parameters); } return(AssignValueConverter(ValueConverterType.ExecuteMethod, valueConverterVariable, ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable, destinationVariable, nextCommand), methodParams.ToArray())); }