Esempio n. 1
0
 public IfContainsStringCommandUC(ICommand command, Test test, EditTest parentForm, EditCommand mainCommandForm, IProjectManager projectManager)
 {
     InitializeComponent();
     this.command         = command as IfContainsStringCommand;
     this.test            = test;
     this.parentForm      = parentForm;
     this.mainCommandForm = mainCommandForm;
     this.projectManager  = projectManager;
 }
        public override object ReadJson(JsonReader reader,
                                        Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jo = JObject.Load(reader);

            string type = (string)jo["_type"];

            if (type == typeof(Project).Name)
            {
                Project item = new Project();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(Test).Name)
            {
                Test item = new Test();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(NavigateToUrlCommand).Name)
            {
                Command item = new NavigateToUrlCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(TakeScreenshotCommand).Name)
            {
                Command item = new TakeScreenshotCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(IfContainsStringCommand).Name)
            {
                Command item = new IfContainsStringCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(FillTextboxCommand).Name)
            {
                Command item = new FillTextboxCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(ClickButtonCommand).Name)
            {
                Command item = new ClickButtonCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            return(null);
        }
Esempio n. 3
0
 private void Save()
 {
     if (parentForm != null)
     {
         if (command == null || command.OrderIndex == 0)
         {
             command                  = new IfContainsStringCommand();
             command.Title            = mainCommandForm.GetTitle();
             command.IfContainsString = txtSearchText.Text;
             Guid?belongToIndex = comboBox1.SelectedValue as Guid?;
             if (belongToIndex.HasValue)
             {
                 command.BelongsToCommandIndex = belongToIndex;
             }
             else
             {
                 command.BelongsToCommandIndex = null;
             }
             command.OrderIndex = 1;
             if (test.Commands.Any())
             {
                 command.OrderIndex = test.Commands.Max(i => i.OrderIndex) + 1;
             }
             test.Commands.Add(command);
         }
         else
         {
             command.Title            = mainCommandForm.GetTitle();
             command.IfContainsString = txtSearchText.Text;
             Guid?belongToIndex = comboBox1.SelectedValue as Guid?;
             if (belongToIndex.HasValue)
             {
                 command.BelongsToCommandIndex = belongToIndex;
             }
             else
             {
                 command.BelongsToCommandIndex = null;
             }
         }
     }
     projectManager.SaveProject();
 }