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
using AddInPlugin.Entity;
using OpenTap;
using System.ComponentModel;
using System.IO;
using UtilLib;
 
namespace OpenTapEditor.Util
{
    public class StepTypeLoader
    {
        public static List<ITypeData> Steps { get; private set; }
        public static List<AdapterData> CustomSteps { get; private set; }
 
        static StepTypeLoader()
        {
            LoadStep();
        }
 
        public static void LoadStep()
        {
            LoadAllStep(null);
            LoadAdapterStep();
        }
 
        public static void LoadAllStep(TypeData parentType)
        {
            TypeData AsTypeData(ITypeData typedata)
            {
                do
                {
                    if (typedata is TypeData td)
                        return td;
                    typedata = typedata?.BaseType;
                } while (typedata != null);
                return null;
            }
 
            var types = TypeData.GetDerivedTypes(TypeData.FromType(typeof(ITestStep)))
               .Where(x => x.CanCreateInstance)
               .Where(x => x.GetAttribute<BrowsableAttribute>()?.Browsable ?? true)
               .Where(x => parentType == null ? true : TestStepList.AllowChild(AsTypeData(parentType).Type, AsTypeData(x)?.Type))
               .OrderBy(x => x.GetAttribute<DisplayAttribute>()?.Order);
 
            Steps = types.ToList();
        }
 
        public static void LoadAdapterStep()
        {
            var datas = new List<AdapterData>();
            try
            {
                if (File.Exists(PathHelper.AdapterDataPath))
                {
                    datas = XmlHelper.DeserializeFromXml<List<AdapterData>>(PathHelper.AdapterDataPath);
                }
            }
            catch (Exception ex)
            {
 
            }
            CustomSteps = datas;
        }
    }
}