Example #1
0
        ASNElement LoadASN(XmlElement el, ASNElement parent)
        {
            ElementType ety     = (ElementType)Enum.Parse(typeof(ElementType), el.GetAttribute("type"));
            string      name    = el.GetAttribute("name").Replace("{$quote$}", "\"");
            string      value   = el.GetAttribute("value").Replace("{$quote$}", "\"");
            string      section = el.GetAttribute("section").Replace("{$quote$}", "\"");
            ASNElement  asn     = null;

            if (ety == ElementType.SEQUENCE)
            {
                asn             = new ASNElement(ety, name);
                asn.SectionName = section;
                if (parent != null)
                {
                    asn.ParentSection = parent;
                }

                foreach (XmlElement e in el.ChildNodes)
                {
                    asn.AddElement(LoadASN(e, asn));
                }
            }
            else
            {
                asn             = new ASNElement(ety, name, value);
                asn.SectionName = section;
                if (parent != null)
                {
                    asn.ParentSection = parent;
                }
            }
            return(asn);
        }
Example #2
0
        public bool HasElement(ASNElement el)
        {
            foreach (ASNElement e in Childs)
            {
                if (e.Name == el.Name)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
 public bool AddElement(ASNElement el)
 {
     if (!HasElement(el) && CanAdd)
     {
         Childs.Add(el);
         el.ParentSection = this;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
        void WriteXmlNode(StreamWriter str, ASNElement el)
        {
            if (el.HasChildrens)
            {
                str.WriteLine("<asn name=\"{0}\" value=\"{1}\" section=\"{2}\" type=\"{3}\">", el.Name.Replace("\"", "{$quote$}"), el.Value.Replace("\"", "{$quote$}"), el.SectionName.Replace("\"", "{$quote$}"), el.EType.ToString());

                foreach (ASNElement e in el.Childs)
                {
                    WriteXmlNode(str, e);
                }


                str.WriteLine("</asn>");
            }
            else
            {
                str.WriteLine("<asn name=\"{0}\" value=\"{1}\" section=\"{2}\" type=\"{3}\" />", el.Name.Replace("\"", "{$quote$}"), el.Value.Replace("\"", "{$quote$}"), el.SectionName.Replace("\"", "{$quote$}"), el.EType.ToString());
            }
        }