chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using OpenTap;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
 
namespace AddInPlugin
{
    //[Display("AdapterStep", Description: "ÔËÐÐ.Net", Group: "AddInPlugin")]
 
    [Browsable(false)]
    public class AdapterStep : VariableTestStep
    {
        #region Settings
        // ToDo: Add property here for each parameter the end user should be able to change
        //[Display("Instrument", Order: 0.0, Description: "The instrument that the query is sent to.")]
        //public DllAction Instrument { get; set; }
 
        //// ToDo: Add property here for each parameter the end user should be able to change
        //[Display("Dut", Order: 0.0, Description: "The instrument that the query is sent to.")]
        //public MyDUT Dut { get; set; }
 
        [XmlIgnore]
        private ITestStep innerStep;
 
        private string xmlString;
        public string XmlString
        {
            get => xmlString;
            set
            {
                xmlString = value;
                OnPropertyChanged(nameof(XmlString));
                LoadStepFromXml();
            }
        }
 
        private void LoadStepFromXml()
        {
            TapSerializer serializer = new TapSerializer();
            innerStep = (ITestStep)serializer.DeserializeFromString(XmlString, TypeData.FromType(typeof(ITestStep)));
            UpdateVars();
        }
 
        #endregion
        public AdapterStep()
        {
            // ToDo: Set default values for properties / settings.
        }
 
        protected override void OnMethodVariablesChanged(ObservableCollection<MethodVariable> variables)
        {
            UpdateVars();
        }
 
        private void SetInnerProperty()
        {
            if (innerStep is VariableTestStep vts)
            {
                vts.MethodVariables = this.methodVariables;
            }
        }
 
        private void UpdateVars()
        {
            if (innerStep is VariableTestStep vts)
            {
                var temp = this.MethodVariables;
                methodVariables = vts.MethodVariables;
                foreach (var mv in this.MethodVariables)
                {
                    mv.ValueStr = temp?.FirstOrDefault(e => e.Name == mv.Name)?.ValueStr;
                    mv.Type = Type.GetType(mv.TypeName);
                }
            }
        }
 
        public override void PrePlanRun()
        {
            innerStep.PrePlanRun();
        }
 
        public override void Run()
        {
            try
            {
                SetInnerProperty();
                innerStep.PlanRun = this.PlanRun;
                innerStep.StepRun = this.StepRun;
                innerStep.Run();
                this.Verdict = innerStep.Verdict;
            }
            catch (Exception ex)
            {
                Log.Error("AdapterStep Run Error. {0}", ex);
                this.Verdict = Verdict.Error;
            }
        }
 
        public override void PostPlanRun()
        {
            innerStep.PostPlanRun();
        }
    }
}