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


C# ScriptObject.ParseString方法代码示例

本文整理汇总了C#中ScriptObject.ParseString方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptObject.ParseString方法的具体用法?C# ScriptObject.ParseString怎么用?C# ScriptObject.ParseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptObject的用法示例。


在下文中一共展示了ScriptObject.ParseString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

 public override bool Execute(ScriptObject scriptObject)
 {
     var varName = LoadedParams["name"];
     if (!string.IsNullOrEmpty(varName))
     {
         var val = scriptObject.ParseString(LoadedParams["value"]);
         int intval = 0;
         int intinc = 0;
         if (int.TryParse(val, out intval) &&
             int.TryParse(scriptObject.ParseString(LoadedParams["inc"]), out intinc))
         {
             intval += intinc;
             val = intval.ToString();
         }
         if (varName.StartsWith("session."))
         {
             IList<PropertyInfo> props = new List<PropertyInfo>(typeof (PhotoSession).GetProperties());
             foreach (PropertyInfo prop in props)
             {
                 if (prop.PropertyType == typeof (string) || prop.PropertyType == typeof (int) ||
                     prop.PropertyType == typeof (bool))
                 {
                     if (varName.Split('.')[1].ToLower() == prop.Name.ToLower())
                     {
                         if (prop.PropertyType == typeof (string))
                         {
                             prop.SetValue(ServiceProvider.Settings.DefaultSession, val, null);
                         }
                         if (prop.PropertyType == typeof (bool))
                         {
                             prop.SetValue(ServiceProvider.Settings.DefaultSession, val == "true", null);
                         }
                         if (prop.PropertyType == typeof (int))
                         {
                             int i = 0;
                             if (int.TryParse(val, out i))
                                 prop.SetValue(ServiceProvider.Settings.DefaultSession, i, null);
                         }
                     }
                 }
             }
         }
         else
         {
             scriptObject.Variabiles[varName] = val;
         }
     }
     return base.Execute(scriptObject);
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:49,代码来源:SetVariable+.cs

示例2: Execute

 public override bool Execute(ScriptObject scriptObject)
 {
     try
     {
         int cameranum = 0;
         if (int.TryParse(scriptObject.ParseString(LoadedParams["cameranum"]), out cameranum))
         {
             if (cameranum > -1 && cameranum < ServiceProvider.DeviceManager.ConnectedDevices.Count)
             {
                 ServiceProvider.DeviceManager.SelectedCameraDevice =
                     ServiceProvider.DeviceManager.ConnectedDevices[cameranum];
                 scriptObject.CameraDevice = ServiceProvider.DeviceManager.ConnectedDevices[cameranum];
             }
             else
             {
                 ServiceProvider.ScriptManager.OutPut("Camera with number " + cameranum + "not exist");
             }
         }
         else
         {
             ServiceProvider.ScriptManager.OutPut("Wrong camera number");
         }
     }
     catch (Exception exception)
     {
         ServiceProvider.ScriptManager.OutPut("Exception on select camera " + exception.Message);
     }
     return true;
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:29,代码来源:SelectCamera.cs

示例3: Execute

        public override bool Execute(ScriptObject scriptObject)
        {
            int time = 0;
            int.TryParse(scriptObject.ParseString(LoadedParams["time"]), out time);
            Executing = true;
            DateTime currTime = DateTime.Now;
            if (LoadedParams["for"] == "camera" && ServiceProvider.DeviceManager.SelectedCameraDevice != null)
            {
                ServiceProvider.ScriptManager.OutPut(string.Format("Waiting .... for camera"));
                while (ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy)
                {
                    if (ServiceProvider.ScriptManager.ShouldStop)
                        break;
                    Thread.Sleep(100);
                }
            }
            double dif = time - (DateTime.Now - currTime).TotalSeconds;
            if (dif > 0)
            {
                ServiceProvider.ScriptManager.OutPut(string.Format("Waiting .... {0}s", dif));
                while ((DateTime.Now - currTime).TotalSeconds < time)
                {
                    if (ServiceProvider.ScriptManager.ShouldStop)
                        break;
                    Thread.Sleep(100);
                }
            }

            Executing = false;
            IsExecuted = true;
            return true;
        }
开发者ID:avencherus,项目名称:digiCamControl,代码行数:32,代码来源:WaitCommand.cs

示例4: 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

示例5: Execute

 public override bool Execute(ScriptObject scriptObject)
 {
     ServiceProvider.ScriptManager.OutPut(scriptObject.ParseString(LoadedParams["text"]));
     return true;
 }
开发者ID:brunoklein99,项目名称:nikon-camera-control,代码行数:5,代码来源:Echo.cs

示例6: 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

示例7: Execute

 public override bool Execute(ScriptObject scriptObject)
 {
     string property = scriptObject.ParseString(LoadedParams["property"].ToLower());
     string val = scriptObject.ParseString(LoadedParams["value"]).Trim();
     switch (property)
     {
         case "iso":
             {
                 scriptObject.CameraDevice.IsoNumber.SetValue(val);
                 if (!scriptObject.CameraDevice.IsoNumber.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
             }
             break;
         case "aperture":
             {
                 if (!val.Contains("."))
                     val = val + ".0";
                 if (!scriptObject.CameraDevice.FNumber.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
                 scriptObject.CameraDevice.FNumber.SetValue(val);
             }
             break;
         case "shutter":
             {
                 if (!val.Contains("/") && !val.EndsWith("s") && !val.Equals("bulb"))
                 {
                     val += "s";
                 }
                 if (val.Equals("bulb"))
                 {
                     val = "Bulb";
                 }
                 scriptObject.CameraDevice.ShutterSpeed.SetValue(val);
                 if (!scriptObject.CameraDevice.ShutterSpeed.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
             }
             break;
         case "ec":
             {
                 scriptObject.CameraDevice.ExposureCompensation.SetValue(val);
                 if (!scriptObject.CameraDevice.ExposureCompensation.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
             }
             break;
         case "wb":
             {
                 scriptObject.CameraDevice.WhiteBalance.SetValue(val);
                 if (!scriptObject.CameraDevice.WhiteBalance.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
             }
             break;
         case "cs":
             {
                 scriptObject.CameraDevice.CompressionSetting.SetValue(val);
                 if (!scriptObject.CameraDevice.CompressionSetting.Values.Contains(val))
                     ServiceProvider.ScriptManager.OutPut(string.Format("Wrong value {1} for property {0}",
                                                                        property, val));
             }
             break;
         default:
             {
                 ServiceProvider.ScriptManager.OutPut("Wrong property :" + property);
             }
             break;
     }
     return true;
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:72,代码来源:SetCamera.cs

示例8: Execute

 public override bool Execute(ScriptObject scriptObject)
 {
     MessageBox.Show(scriptObject.ParseString(LoadedParams["text"]), "DCC Script");
     return true;
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:5,代码来源:Alert.cs


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