示例#1
0
        public static void InitTestStepInfo()
        {
            List <TestStepInfo> stepInfoList        = new List <TestStepInfo>();
            List <TestStepInfo> stepInfoListFromXml = GetTestStepInfoFromXml();

            getTypeFromAssemble();
            foreach (var type in StepTypelist)
            {
                Assembly assembly  = Assembly.LoadFile(type.AssemblyPath);
                string   str       = type.Type.FullName;
                Type     modelType = assembly.GetType(str);
                TestStep step      = Activator.CreateInstance(modelType) as TestStep;
                if (step != null)
                {
                    TestStepInfo stepInfo = new TestStepInfo()
                    {
                        Assembly             = assembly,
                        TypeName             = step.GetType().Name,
                        StepType             = step.GetType(),
                        DisplayName          = type.Att.DisplayName,
                        TestStepViewModelStr = type.Att.StepTypeStr,
                        AdvUserControlStr    = type.Att.UserControlType,
                        TestTraceTypeList    = step.ItemTypeNameList,
                        IsFixedItem          = type.Att.IsFixedItem,
                        IsNeedCal            = type.Att.IsNeedCal
                    };
                    if (stepInfoListFromXml.Where(x => x.TypeName == stepInfo.TypeName).Count() > 0)
                    {
                        //if (step.SupportedMeasClsInfoList != null)
                        //{
                        //    stepInfo.MeasClsInfoList = step.SupportedMeasClsInfoList.ToList();
                        //}
                        //else
                        //{
                        stepInfo.MeasClsInfoList = stepInfoListFromXml.Where(x => x.TypeName == stepInfo.TypeName).FirstOrDefault().MeasClsInfoList;
                        //}
                        stepInfo.Settings            = stepInfoListFromXml.Where(x => x.TypeName == stepInfo.TypeName).FirstOrDefault().Settings;
                        stepInfo.LocalSettingViewStr = stepInfoListFromXml.Where(x => x.TypeName == stepInfo.TypeName).FirstOrDefault().LocalSettingViewStr;
                        stepInfoList.Add(stepInfo);
                    }
                    //else
                    //{
                    //    if (step.SupportedMeasClsInfoList != null)
                    //    {
                    //        stepInfo.MeasClsInfoList = step.SupportedMeasClsInfoList.ToList();
                    //    }
                    //}

                    // stepInfoList.Add(stepInfo);
                    if (step.LocalSettingTypeList != null)
                    {
                        foreach (var itemType in step.LocalSettingTypeList)
                        {
                            if (!localSettingTypelist.Contains(itemType))
                            {
                                localSettingTypelist.Add(itemType);
                            }
                        }
                    }
                }
            }
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "FormulaCalcTestStep", DisplayName = TestStepType.Cal
            });
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "LoopTestStep", DisplayName = TestStepType.Loop
            });
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "ManualLoopTestStep", DisplayName = TestStepType.Manual
            });
            stepInfoList.Add(new TestStepInfo()
            {
                TypeName = "LinkTestStep", DisplayName = TestStepType.Link
            });

            TestStepInfoMgr.Instance.TestStepInfoList = stepInfoList.ToArray();
            TestStepInfoMgr.Instance.LoadInstruInfoFromFile();
        }
示例#2
0
        //从XML文件中读取MeasClsInfo的信息
        public static List <TestStepInfo> GetTestStepInfoFromXml()
        {
            List <TestStepInfo> stepInfoListFromXml = new List <TestStepInfo>();

            try
            {
                XElement rooEl = XElement.Load(@"./configfiles/MeasClsInfo.xml");

                var xmlStepInfoList = rooEl.Elements("TestStepInfo");
                foreach (var xmlstepInfo in xmlStepInfoList)
                {
                    string       typeName    = GetAttibute(xmlstepInfo, "TypeName");
                    string       displayName = GetAttibute(xmlstepInfo, "DisplayName");
                    TestStepInfo stepInfo    = new TestStepInfo()
                    {
                        TypeName = typeName, DisplayName = displayName
                    };
                    try
                    {
                        var xmlMeasClsInfolist = xmlstepInfo.Elements("MeasClsInfo");
                        foreach (var xmlMeasClsInfo in xmlMeasClsInfolist)
                        {
                            string      measTypeName    = GetAttibute(xmlMeasClsInfo, "TypeName");
                            string      measDisplayName = GetAttibute(xmlMeasClsInfo, "DisplayName");
                            string      measInfo        = GetAttibute(xmlMeasClsInfo, "Info");
                            MeasClsInfo measClsInfo     = new MeasClsInfo()
                            {
                                TypeName = measTypeName, DisplayName = measDisplayName, Info = measInfo
                            };
                            stepInfo.MeasClsInfoList.Add(measClsInfo);
                            //添加所有InstruInfo配置
                            var xmlInstruInfolist            = xmlMeasClsInfo.Elements("InstruInfo");
                            List <InstruInfo> instruInfolist = new List <InstruInfo>();
                            foreach (var xmlInstruInfo in xmlInstruInfolist)
                            {
                                string instruName        = GetAttibute(xmlInstruInfo, "Name");
                                string instruDispalyName = GetAttibute(xmlInstruInfo, "DisplayName");
                                bool   isManualInit      = false;
                                try
                                {
                                    string isManualInitStr = GetAttibute(xmlInstruInfo, "IsManualInit");
                                    isManualInit = Symtant.GeneFunLib.StringExtensions.ScpiResToBool(isManualInitStr);
                                }
                                catch
                                {
                                }
                                bool isCal = false;
                                try
                                {
                                    string isCalStr = GetAttibute(xmlInstruInfo, "IsCal");
                                    isCal = Symtant.GeneFunLib.StringExtensions.ScpiResToBool(isCalStr);
                                }
                                catch
                                {
                                }
                                InstruInfo instruInfo = new InstruInfo()
                                {
                                    Name = instruName, DisplayName = instruDispalyName, IsManuallyInit = isManualInit, IsCal = isCal
                                };
                                instruInfolist.Add(instruInfo);
                            }
                            measClsInfo.InstruInfoList = instruInfolist.ToArray();
                            //添加所有ConfigInfo配置
                            var xmlConfiglist = xmlMeasClsInfo.Elements("ConfigInfo");
                            List <PathConfigInfo> configList = new List <PathConfigInfo>();
                            foreach (var xmlConfig in xmlConfiglist)
                            {
                                string         configName     = GetAttibute(xmlConfig, "Name");
                                string         configValue    = GetAttibute(xmlConfig, "Path");
                                string         configInfo     = GetAttibute(xmlConfig, "Info");
                                PathConfigInfo pathConfigInfo = new PathConfigInfo()
                                {
                                    Name = configName, Path = configValue, Info = configInfo
                                };

                                var xmlConfigSettings = xmlConfig.Elements("set");
                                foreach (var xmlConfigSet in xmlConfigSettings)
                                {
                                    var k = xmlConfigSet.Attribute("key");
                                    if (k != null && k.Value != null)
                                    {
                                        var v = xmlConfigSet.Attribute("value");
                                        if (v != null && v.Value != null)
                                        {
                                            pathConfigInfo.Settings.Add(k.Value.Trim(), v.Value.Trim());
                                        }
                                    }
                                }
                                configList.Add(pathConfigInfo);
                            }
                            measClsInfo.PathConfigInfoList = configList.ToArray();
                            //添加所有其他配置
                            measClsInfo.Settings.Clear();
                            var xmlClsSettings = xmlMeasClsInfo.Elements("set");
                            foreach (var xmlClsSet in xmlClsSettings)
                            {
                                var k = xmlClsSet.Attribute("key");
                                if (k != null && k.Value != null)
                                {
                                    var v = xmlClsSet.Attribute("value");
                                    if (v != null && v.Value != null)
                                    {
                                        measClsInfo.Settings.Add(k.Value.Trim(), v.Value.Trim());
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        stepInfo.MeasClsInfoList = null;
                    }
                    try
                    {
                        stepInfo.Settings.Clear();
                        var xmlStepSettings = xmlstepInfo.Elements("set");
                        foreach (var xmlStepSet in xmlStepSettings)
                        {
                            var k = xmlStepSet.Attribute("key");
                            if (k != null && k.Value != null)
                            {
                                var v = xmlStepSet.Attribute("value");
                                if (v != null && v.Value != null)
                                {
                                    stepInfo.Settings.Add(k.Value.Trim(), v.Value.Trim());
                                }
                            }
                        }
                    }
                    catch
                    { stepInfo.Settings = null; }
                    try
                    {
                        var xmlLocalSettingViewStr = xmlstepInfo.Element("LocalSettingView");
                        stepInfo.LocalSettingViewStr = GetAttibute(xmlLocalSettingViewStr, "value");
                    }
                    catch
                    {
                        stepInfo.LocalSettingViewStr = null;
                    }
                    stepInfoListFromXml.Add(stepInfo);
                }
            }
            catch
            {
            }
            return(stepInfoListFromXml);
        }