Example #1
0
        /// <summary>
        /// TestConfig节点处理
        /// </summary>
        /// <param name="testconfigXElement"></param>
        public TestConfigNodes(XElement testconfigXElement)
        {
            //1.转为对象
            TestConfigType testConfigType = new TestConfigType
            {
                Imports    = new List <ConfigurationFile>(),
                Properties = new List <Property>()
            };

            //需要判断Properties下是否包含参数
            XElement proele = testconfigXElement.Element(XName.Get("Properties", ComArgs.RosStr));

            if (proele != null && proele.Elements().Count() != 0)
            {
                foreach (XElement sigXElement in proele.Elements())
                {
                    Property property = new Property
                    {
                        Id          = sigXElement.Attribute(XName.Get("ID", ComArgs.RosStr))?.Value,
                        Value       = sigXElement.Element(XName.Get("Value", ComArgs.RosStr))?.Value,
                        Description = sigXElement.Element(XName.Get("Description", ComArgs.RosStr))?.Value
                    };


                    //添加
                    testConfigType.Properties.Add(property);
                }
            }

            //需要判断Imports是否包含参数
            XElement impele = testconfigXElement.Element(XName.Get("Imports", ComArgs.RosStr));

            if (impele != null && impele.Elements().Count() != 0)
            {
                foreach (XElement sigXElement in impele.Elements())
                {
                    ConfigurationFile configurationFile = new ConfigurationFile
                    {
                        Id   = sigXElement.Attribute(XName.Get("ID", ComArgs.RosStr))?.Value,
                        Type = sigXElement.Attribute(XName.Get("Type", ComArgs.RosStr))?.Value,
                        Path = sigXElement.Element(XName.Get("Path", ComArgs.RosStr))?.Value
                    };


                    //添加
                    testConfigType.Imports.Add(configurationFile);
                }
            }

            //2.根据要求配置testconfig节点
            TestConfig_Info = testConfigType;
        }
Example #2
0
        /// <summary>
        /// 构造函数
        /// 测试配置
        /// <para>主要是2类,一类是ros中定义的参数,一类是对应的所有的控件文件</para>
        /// </summary>
        /// <param name="testConfigType">测试配置对象</param>
        public TestConfigEvents(TestConfigType testConfigType)
        {
            try
            {
                //1.新增参数

                /*
                 * 配置文件中的优先级比本文中的参数优先级高
                 * 所以只有新增,参数自身不支持参数化
                 *
                 */

                if (testConfigType.Properties != null)
                {
                    foreach (Property sigpros in testConfigType.Properties)
                    {
                        if (ComArgs.PropertiesDic.ContainsKey(sigpros.Id))
                        {
                            ComArgs.PropertiesDic[sigpros.Id] = sigpros.Value;
                        }
                        else
                        {
                            ComArgs.PropertiesDic.Add(sigpros.Id, sigpros.Value);
                        }
                    }
                }



                ComArgs.ElementDic = new Dictionary <string, object>(); //初始化
                //2.配置roi/tci元素集
                foreach (ConfigurationFile sigconf in testConfigType.Imports)
                {
                    ElementEntrance             elementEntrance = new ElementEntrance(sigconf); //一个roi/tci元素集的起点
                    Dictionary <string, object> eledic          = elementEntrance.ElementDic;
                    foreach (KeyValuePair <string, object> item in eledic)                      //追加元素字典
                    {
                        ComArgs.ElementDic.Add(item.Key, item.Value);
                    }
                }
                ComArgs.RoLog.WriteLog(LogStatus.LInfo, $"当前元素字典共计 {ComArgs.ElementDic.Count} 个数据...");
            }
            catch (Exception e)
            {
                ComArgs.RoLog.WriteLog(LogStatus.LExpt, "TestConfigEvents发生异常", e.ToString());
            }
        }