コード例 #1
0
        public static CaptureItem Read(XmlNode node)
        {
            if (node.Attributes != null)
            {
                if (node.Attributes["id"] != null && node.Attributes["link"] != null)
                {
                    var item = new CaptureItem();
                    item.Id   = node.Attributes["id"].Value;
                    item.Name = node.Attributes["name"].Value;
                    item.Link = node.Attributes["link"].Value;
                    return(item);
                }
            }

            return(null);
        }
コード例 #2
0
        public static CaptureItem Read(XmlNode node)
        {
            if (node.Attributes != null)
            {
                if (node.Attributes["id"] != null && node.Attributes["link"] != null)
                {
                    var item = new CaptureItem();
                    item.Id = node.Attributes["id"].Value;
                    item.Name = node.Attributes["name"].Value;
                    item.Link = node.Attributes["link"].Value;
                    return item;
                }
            }

            return null;
        }
コード例 #3
0
        public static Configuration Read(XmlDocument configXML)
        {
            var result = new Configuration();

            //XmlNodeList nodes = configXML.SelectNodes("//GeneratedData/GeneratedEvents");
            XmlNodeList nodes = configXML.SelectNodes("//GeneratedEvents");

            if (nodes != null)
            {
                if (nodes.Count > 0)
                {
                    XmlNode node = nodes[0];

                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (child.NodeType == XmlNodeType.Element)
                        {
                            if (child.InnerText != null)
                            {
                                Type         Setting = typeof(Configuration);
                                PropertyInfo info    = Setting.GetProperty(child.Name);

                                if (info != null)
                                {
                                    Type t = info.PropertyType;
                                    info.SetValue(result, Convert.ChangeType(child.InnerText, t), null);
                                }
                                else if (child.Name.ToLower() == "event")
                                {
                                    if (child.NodeType == XmlNodeType.Element && child.Attributes != null)
                                    {
                                        if (child.Attributes["name"] != null)
                                        {
                                            var ev = new Event();
                                            ev.Values = new List <Value>();

                                            ev.Name = child.Attributes["name"].Value.ToString();

                                            foreach (XmlNode Childnode in child.ChildNodes)
                                            {
                                                if (Childnode.NodeType == XmlNodeType.Element)
                                                {
                                                    switch (Childnode.Name.ToLower())
                                                    {
                                                    case "value":

                                                        var value = Value.Read(Childnode);
                                                        ev.Values.Add(value);

                                                        break;

                                                    case "default":

                                                        var d = Return.Read(Childnode);
                                                        d.Id       = "DEFAULT_ID";
                                                        ev.Default = d;

                                                        break;

                                                    case "capture":

                                                        foreach (XmlNode itemNode in Childnode.ChildNodes)
                                                        {
                                                            if (itemNode.NodeType == XmlNodeType.Element)
                                                            {
                                                                var item = CaptureItem.Read(itemNode);
                                                                if (item != null)
                                                                {
                                                                    ev.CaptureItems.Add(item);
                                                                }
                                                            }
                                                        }

                                                        break;
                                                    }
                                                }
                                            }

                                            ev.PreviousValue = ev.Default;

                                            result.Events.Add(ev);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }