Пример #1
0
        public override void Deserialize(XmlElement element)
        {
            string tp = element.GetAttribute("type");

            this.lma_type = System.Type.GetType("KnowledgeBase." + tp);
            foreach (XmlElement xma in element.GetElementsByTagName("SubAttribute"))
            {
                this.Name = element.GetAttribute("name");
                ScalarAttribute sa = (ScalarAttribute)Activator.CreateInstance(this.lma_type);
                sa.Deserialize(xma);
                this.Push(sa);
            }
        }
Пример #2
0
 public void Push(ScalarAttribute attribute)
 {
     if (this.lma_type == null)
     {
         throw new InvalidOperationException("Не определен тип множественного атрибута!");
     }
     if (attribute.GetType() != this.lma_type)
     {
         throw new InvalidCastException("Неверный тип!");
     }
     foreach (ScalarAttribute sa in this.lma_attrs)
     {
         if (sa.Name == attribute.Name && sa.Type == attribute.Type)
         {
             throw new  AttributeAlreadyExistsException(attribute.Name);
         }
     }
     this.lma_attrs.Insert(this.lma_attrs.Count, attribute);
 }
Пример #3
0
 private void deser_attrs(Element e, XmlNode x, Root r)
 {
     foreach (XmlNode n in x.ChildNodes)
     {
         Type       t  = null;
         XmlElement xe = (XmlElement)n;
         if (xe.Name == "Attribute")
         {
             if (xe.GetAttribute("type") == "LINK")
             {
                 int i = int.Parse(xe.InnerText);
                 if (!ls.ContainsKey(i))
                 {
                     ls[i] = new Link(e, xe.GetAttribute("name"));
                 }
                 else
                 {
                     ((Link)ls[i]).Element2 = e;
                 }
                 continue;
             }
             t = (Type)this.scalars[xe.GetAttribute("type")];
             if (xe.GetAttribute("multiplicity") == "False")
             {
                 ScalarAttribute s = (ScalarAttribute)Activator.CreateInstance(t);
                 s.Deserialize(xe);
                 e.AddAttribute(s);
             }
             else if (xe.GetAttribute("multiplicity") == "True")
             {
                 MultipleAttribute lma = new MultipleAttribute("");
                 lma.Deserialize(xe);
                 e.AddAttribute(lma);
             }
         }
     }
 }