public static IScriptCommand IfArrayLength(ComparsionOperator op = ComparsionOperator.GreaterThanOrEqual, string arrayVariable = "{array}", int value = 1, IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { return (ScriptCommands.Assign("{ArrayLengthValue}", value, IfArrayLength(op, arrayVariable, "{ArrayLengthValue}", trueCommand, otherwiseCommand))); }
/// <summary> /// Given an array filter using IfValue, and store matched item to destination variable. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sourceArrayVariable"></param> /// <param name="property"></param> /// <param name="op"></param> /// <param name="value"></param> /// <param name="destinationArrayVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand FilterArray <T>(string sourceArrayVariable = "{SourceArray}", string property = "Property", ComparsionOperator op = ComparsionOperator.Equals, T value = default(T), string destinationArrayVariable = "{DestinationArray}", IScriptCommand nextCommand = null) { string valueVariable = ParameterDicUtils.CombineVariable(sourceArrayVariable, "ValueCompare"); return(Assign(valueVariable, value, FilterArray(sourceArrayVariable, property, op, valueVariable, destinationArrayVariable, nextCommand))); }
/// <summary> /// Iterate an IEnumeration and return true if anyone's property equals to the value. /// <example> /// IScriptCommand iterateCommand2 = /// ScriptCommands.ForEachIfAnyValue<DateTime>("{Items}", null, ComparsionOperator.Equals, DateTime.Today, /// ScriptCommands.PrintDebug("True"), ScriptCommands.PrintDebug("False")); /// </example> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="itemsVariable"></param> /// <param name="property"></param> /// <param name="op"></param> /// <param name="value"></param> /// <param name="nextCommand"></param> /// <param name="otherwiseCommand"></param> /// <returns></returns> public static IScriptCommand ForEachIfAnyValue <T>(string itemsVariable = "{Items}", string property = null, ComparsionOperator op = ComparsionOperator.Equals, T value = default(T), IScriptCommand nextCommand = null, IScriptCommand otherwiseCommand = null) { string compareVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Compare"); return(Assign(compareVariable, value, false, ForEachIfAnyValue(itemsVariable, property, op, compareVariable, nextCommand, otherwiseCommand))); }
public static IScriptCommand IfValue <T>(ComparsionOperator op, string variable = "{variable}", T value = default(T), IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { string ifValueValueProperty = "{IfValue-Value}"; return (ScriptCommands.Assign(ifValueValueProperty, value, IfValue(op, variable, ifValueValueProperty, trueCommand, otherwiseCommand))); }
public static IScriptCommand FileListIfSelectionLength(string fileListVariable = "{FileList}", ComparsionOperator op = ComparsionOperator.Equals, int value = 1, IScriptCommand thenCommand = null, IScriptCommand otherwiseCommand = null) { string fileListSelectionVariable = ParameterDic.CombineVariable(fileListVariable, "Selection"); return(UIScriptCommands.FileListAssignSelection(fileListSelectionVariable, ScriptCommands.IfArrayLength(op, fileListSelectionVariable, value, thenCommand, otherwiseCommand))); }
/// <summary> /// Serializable, Use Expression to compare two value in ParameterDic, and run different command based on the result. /// </summary> /// <param name="op"></param> /// <param name="variable1"></param> /// <param name="variable2"></param> /// <param name="trueCommand"></param> /// <param name="otherwiseCommand"></param> /// <returns></returns> public static IScriptCommand IfValue(ComparsionOperator op, string variable1 = "{Variable1}", string variable2 = "{Variable2}", IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { return(new IfValue() { Variable1Key = variable1, Variable2Key = variable2, Operator = op, NextCommand = (ScriptCommandBase)trueCommand, OtherwiseCommand = (ScriptCommandBase)otherwiseCommand, }); }
/// <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> /// Given an array filter using IfValue, and store matched item to destination variable. /// </summary> /// <param name="sourceArrayVariable"></param> /// <param name="property"></param> /// <param name="op"></param> /// <param name="valueVariable"></param> /// <param name="destinationArrayVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand FilterArray(string sourceArrayVariable = "{SourceArray}", string property = "Property", ComparsionOperator op = ComparsionOperator.Equals, string valueVariable = "{Value}", string destinationArrayVariable = "{DestinationArray}", IScriptCommand nextCommand = null) { string currentItemVariable = ParameterDicUtils.CombineVariable(sourceArrayVariable, "Current"); string currentPropertyVariable = ParameterDicUtils.CombineVariable(sourceArrayVariable, "Current" + (property == null ? "" : "." + property)); string tempArrayVariable = ParameterDicUtils.CombineVariable(sourceArrayVariable, "Temp"); return(ForEach(sourceArrayVariable, currentItemVariable, IfValue(op, currentPropertyVariable, valueVariable, ConcatArray(tempArrayVariable, new object[] { currentItemVariable }, tempArrayVariable)), Assign(destinationArrayVariable, tempArrayVariable, nextCommand))); }
/// <summary> /// Iterate an IEnumeration and return true if anyone's property equals to the specified variable. /// </summary> /// <example> /// IScriptCommand iterateCommand2 = /// ScriptCommands.ForEachIfAnyValue<DateTime>("{Items}", "Day", ComparsionOperator.Equals, "Today.Day", /// ScriptCommands.PrintDebug("True"), ScriptCommands.PrintDebug("False")); /// </example> /// <param name="itemsVariable"></param> /// <param name="property"></param> /// <param name="op"></param> /// <param name="compareVariable"></param> /// <param name="nextCommand"></param> /// <param name="otherwiseCommand"></param> /// <returns></returns> public static IScriptCommand ForEachIfAnyValue(string itemsVariable = "{Items}", string property = null, ComparsionOperator op = ComparsionOperator.Equals, string compareVariable = "{Variable}", IScriptCommand nextCommand = null, IScriptCommand otherwiseCommand = null) { string currentItemVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Current"); string currentPropertyVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Current" + ((property == null) ? "" : "." + property)); string resultVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Result"); return (Assign(resultVariable, false, false, ForEach(itemsVariable, currentItemVariable, resultVariable, IfValue(op, currentPropertyVariable, compareVariable, Assign(resultVariable, true, false)), IfTrue(resultVariable, nextCommand, otherwiseCommand)))); }
public static IScriptCommand FileListIfSelectionLength( ComparsionOperator op = ComparsionOperator.Equals, int value = 1, IScriptCommand thenCommand = null, IScriptCommand otherwiseCommand = null) { return(FileListIfSelectionLength("{FileList}", op, value, thenCommand, otherwiseCommand)); }
public static IScriptCommand IfDependencyProperty <T>(string elementVariable = "{Sender}", DependencyProperty property = null, ComparsionOperator op = ComparsionOperator.Equals, T value = default(T), IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { string destinationVariable = ParameterDic.CombineVariable(elementVariable, property.ToString() + "Value"); return(HubScriptCommands.GetDependencyProperty(elementVariable, property, destinationVariable, ScriptCommands.IfValue(op, destinationVariable, value, trueCommand, otherwiseCommand))); }