Example #1
0
 public static InfoWrapper FromXml(XElement d)
 {
     Action<bCAccessorPropertyObject, XElement, bool> A = (a, b, c) =>
     {
         foreach (XAttribute a2 in b.Attributes())
             if (a2.Name.LocalName != "ClassName")
                 a.Properties[a2.Name.LocalName].Object = FromString(a.Properties[a2.Name.LocalName], a2.Value);
         if(c)
             foreach (XElement e in b.Elements())
             {
                 bCProperty p = a.Properties[e.Name.LocalName];
                 switch (p.PropertyType)
                 {
                     case "eCTemplateEntityProxy":
                         (p.Object as eCTemplateEntityProxy).Guid = new bCGuid(new Guid(e.Attribute("ID").Value));
                         break;
                     case "gCQuestActor":
                         (p.Object as gCQuestActor).ActorType = (gEQuestActor)Enum.Parse(typeof(gEQuestActor), e.Attribute("ActorType").Value);
                         (p.Object as gCQuestActor).Actor = new eCEntityStringProxy(e.Attribute("Actor").Value);
                         break;
                     case "gCSkillValue":
                         (p.Object as gCSkillValue).Amount = int.Parse(e.Attribute("Amount").Value);
                         (p.Object as gCSkillValue).Skill = (gESkill)Enum.Parse(typeof(gESkill), e.Attribute("Skill").Value);
                         break;
                     default:
                         throw new Exception();
                 }
             }
     };
     Action<string, XElement, InfoWrapper> B = (a, b, w) =>
     {
         foreach (XElement e in b.Elements())
             if (e.Name == a)
             {
                 string c = e.Attribute("ClassName").Value;
                 InfoCommandWrapper v = InfoCommandWrapper.getWrapper(c + "_Wrapper", w);
                 A(v.Object, e, true);
                 typeof(InfoWrapper).GetMethod("Add" + a).Invoke(w, new object[]{v});
             }
     };
     InfoWrapper i = new InfoWrapper("", "", gEInfoType.gEInfoType_Comment, gEInfoCondType.gEInfoCondType_Activator);
     if (d.Attribute("ClassName").Value != "gCInfo")
         throw new Exception();
     A(i.nat.Container as bCAccessorPropertyObject, d, false);
     B("Command", d, i);
     B("Condition", d, i);
     i.Build();
     return i;
 }