本文整理汇总了C#中ScriptObject.ExecuteCommands方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptObject.ExecuteCommands方法的具体用法?C# ScriptObject.ExecuteCommands怎么用?C# ScriptObject.ExecuteCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptObject
的用法示例。
在下文中一共展示了ScriptObject.ExecuteCommands方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override bool Execute(ScriptObject scriptObject)
{
int loopcount ;
if (!int.TryParse(scriptObject.ParseString(LoadedParams["loopcount"]), out loopcount))
loopcount = int.MaxValue;
for (int i = 0; i < loopcount; i++)
{
scriptObject.Variabiles["loopno"] = i.ToString();
if (ServiceProvider.ScriptManager.ShouldStop)
break;
scriptObject.ExecuteCommands(Commands);
if (scriptObject.ExitLoop)
break;
// prevent CPU overloading
Thread.Sleep(200);
}
scriptObject.ExitLoop = false;
return true;
}
示例2: Execute
public override bool Execute(ScriptObject scriptObject)
{
bool cond = true;
Regex splitter = new Regex("\\s*(.*?)\\s*(>=|<=|!=|=|<|>)\\s*(.*)$");
Match match = splitter.Match(this.LoadedParams["condition"]);
if (match.Groups.Count != 4)
{
ServiceProvider.ScriptManager.OutPut("wrong parameters for if");
return true;
}
string left = match.Groups[1].Value;
string op = match.Groups[2].Value;
string right = match.Groups[3].Value;
left = scriptObject.ParseString(left);
right = scriptObject.ParseString(right);
float leftNum = 0;
float rightNum = 0;
bool numeric = float.TryParse(left, out leftNum);
numeric = numeric && float.TryParse(right, out rightNum);
// try to process our test
if (op == ">=")
{
if (numeric) cond = leftNum >= rightNum;
else cond = left.CompareTo(right) >= 0;
}
else if (op == "<=")
{
if (numeric) cond = leftNum <= rightNum;
else cond = left.CompareTo(right) <= 0;
}
else if (op == "!=")
{
if (numeric) cond = leftNum != rightNum;
else cond = left.CompareTo(right) != 0;
}
else if (op == "=")
{
if (numeric) cond = leftNum == rightNum;
else cond = left.CompareTo(right) == 0;
}
else if (op == "<")
{
if (numeric) cond = leftNum < rightNum;
else cond = left.CompareTo(right) < 0;
}
else if (op == ">")
{
if (numeric) cond = leftNum > rightNum;
else cond = left.CompareTo(right) > 0;
}
else
{
ServiceProvider.ScriptManager.OutPut("Wrong operator :"+op);
return true;
}
if (cond)
{
scriptObject.ExecuteCommands(Commands);
}
return true;
}