Exemplo n.º 1
0
 public virtual void OnLuaParseEnd()
 {
     if (MetaTable == null)
     {
         MetaTable = GetDynVal(LuaTableKey);
     }
     Default = (T)LuaReader.Read(MetaTable, typeof(T));
 }
Exemplo n.º 2
0
        public virtual void Add(DynValue table)
        {
            if (MetaTable == null)
            {
                MetaTable = GetDynVal(LuaTableKey);
            }
            if (!MetaTable.IsNil())
            {
                baseTable = AddByDefault(MetaTable, table);
            }
            else
            {
                baseTable = table;
            }

            //获得Lua类模板
            string temp      = GetStrByBaseTable(Template);
            Type   classType = typeof(T);

            if (temp != null)
            {
                classType = Type.GetType(NameSpace + "." + temp, true, false);
                if (classType == null)
                {
                    CLog.Error("无法找到此类型:" + temp);
                }
                TempClassData = classType.Assembly.CreateInstance(classType.FullName) as T;
            }
            else
            {
                TempClassData = new T();
            }

            TempClassData = (T)LuaReader.Read(baseTable, classType);
            if (TempClassData == null)
            {
                return;
            }
            string key = TempClassData.TDID;

            if (Data.ContainsKey(key))
            {
                CLog.Error(baseTable.ToString() + "已经存在这个key:" + key);
                return;
            }
            //TempClassData.OnBeAddedToData();
            //Add(key, TempClassData);
            //Keys.Add(key);
            TempClassData.TDID = key;
            Register(TempClassData);
        }