alielie
2026-09-10 f3889f2d36c50cf99468594854def9b7ed069fb5
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
using OpenTap.Addin.Util;
using OpenTap;
using OpenTap.Addin;
using OpenTap.Addin.Annotation;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using OpenTap.Addin.Entity;
 
namespace AddInPlugin
{
    [Browsable(false)]
    public abstract class VariableTestStep : TestStep
    {
        protected ObservableCollection<MethodVariable> methodVariables = new ObservableCollection<MethodVariable>();
        [Display("参数", Order: 0.0, Description: "运行参数.")]
        [BindingList(nameof(MethodVariables))]
        public virtual ObservableCollection<MethodVariable> MethodVariables
        {
            get => methodVariables;
            set
            {
                methodVariables = value;
                foreach (var mv in value)
                {
                    mv.Type = Type.GetType(mv.TypeName);
                }
                OnPropertyChanged(nameof(MethodVariables));
                OnMethodVariablesChanged(value);
            }
        }
 
        protected virtual void OnMethodVariablesChanged(ObservableCollection<MethodVariable> variables)
        {
 
        }
 
        public override void PrePlanRun()
        {
            base.PrePlanRun();
        }
 
        protected virtual void UpdateVariableToRuntime()
        {
            //if (IsConstructorMethod)
            //{
            //    var methodVariable = MethodVariables[0];
            //    PlanRun.UpdateRuntimeVariable(methodVariable.ValueStr, instance);
            //}
            foreach (var mv in MethodVariables)
            {
                if (EnableReport)
                {
                    if (mv.Log)
                    {
                        var detail = new ReportDetail
                        {
                            Name = mv.Name,
                        };
                        try
                        {
                            detail.Type = mv.Type.Name;
                            detail.Normal = true;
                            detail.Value = mv.Value?.ToString();
                        }
                        catch (Exception ex)
                        {
                            detail.Normal = false;
                            detail.Exception = ex;
                        }
                        StepRun.Report.Details.Add(detail);
                    }
                }
 
                if (mv.Direction == VariableDirection.Out && !string.IsNullOrEmpty(mv.ValueStr))
                {
                    PlanRun.Update(this, mv.ValueStr, mv.Value);
                }
            }
        }
    }
}