using AddInPlugin.Entity; using OpenTap; using System.ComponentModel; using System.IO; using UtilLib; namespace OpenTapEditor.Util { public class StepTypeLoader { public static List Steps { get; private set; } public static List 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()?.Browsable ?? true) .Where(x => parentType == null ? true : TestStepList.AllowChild(AsTypeData(parentType).Type, AsTypeData(x)?.Type)) .OrderBy(x => x.GetAttribute()?.Order); Steps = types.ToList(); } public static void LoadAdapterStep() { var datas = new List(); try { if (File.Exists(PathHelper.AdapterDataPath)) { datas = XmlHelper.DeserializeFromXml>(PathHelper.AdapterDataPath); } } catch (Exception ex) { } CustomSteps = datas; } } }