示例#1
0
 public override void Load(ConfigNode node)
 {
     base.Load(node);
     foreach (var n in node.GetNodes())
     {
         var it = TypedConfigNodeObject.FromConfig(n) as T;
         if (it != null)
         {
             List.Add(it);
         }
     }
 }
示例#2
0
        public static TypedConfigNodeObject FromConfig(ConfigNode node)
        {
            TypedConfigNodeObject obj = null;
            var typename = node.GetValue("type");

            if (typename == null)
            {
                return(obj);
            }
            var type = Type.GetType(typename);

            if (type == null)
            {
                Utils.Log("Unable to create {}: Type not found.", typename);
                return(obj);
            }
            try
            {
                obj = Activator.CreateInstance(type) as TypedConfigNodeObject;
                obj.Load(node);
            }
            catch (Exception ex) { Utils.Log("Unable to create {}: {}\n{}", typename, ex.Message, ex.StackTrace); }
            return(obj);
        }