当前位置: 首页>>代码示例>>C#>>正文


C# ScriptObject.ExecuteCommands方法代码示例

本文整理汇总了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;
 }
开发者ID:brunoklein99,项目名称:nikon-camera-control,代码行数:19,代码来源:Loop.cs

示例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;
        }
开发者ID:brunoklein99,项目名称:nikon-camera-control,代码行数:70,代码来源:IfCommand.cs


注:本文中的ScriptObject.ExecuteCommands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。