public LuaSqlConfigBase(int luasqlScriptCount)
        {
            luasqlScriptCount = luasqlScriptCount < 1 ? 1 : luasqlScriptCount;

            _lsqlscripts = new List <LuaSqlScript>();
            for (int i = 0; i < luasqlScriptCount; i++)
            {
                var script = new LuaSqlScript();
                _lsqlscripts.Add(script);
                LuaConfigInit(script);
            }
        }
示例#2
0
        protected string GetLuaLayoutName(LuaSqlScript script, LuaSqlModel luasql)
        {
            var layout = luasql.Config[LuaSqlConfigConst.SqlConfigLayoutLabel];
            var sqllay = layout?.ToString();

            if (sqllay == null)
            {
                //如果表配置没有配置layout,那么获取全局配置的
                layout = script.ConfigGlobal[LuaSqlConfigConst.SqlConfigLayoutLabel];
                sqllay = layout?.ToString();
            }
            return(sqllay);
        }
示例#3
0
        /// <summary>
        /// 获取或新增LuaSqlModel
        /// </summary>
        protected LuaSqlModel AddOrGetLuaSql(LuaSqlScript script, string tableName)
        {
            LuaSqlModel templuasql = new LuaSqlModel();
            var         luasql     = script.Luasqls.GetOrAdd(tableName, templuasql);

            if (luasql == templuasql)
            {
                //初始化
                luasql.TableName = tableName;
                InitLuaSql(script, luasql);
            }

            return(luasql);
        }
示例#4
0
        protected void ScriptLayoutInit(LuaSqlScript script, LuaSqlModel luasql)
        {
            var lname = GetLuaLayoutName(script, luasql);

            if (!string.IsNullOrEmpty(lname))
            {
                LuaSqlModel layoutlsql;
                if (script.Luasqls.TryGetValue(lname, out layoutlsql))
                {
                    ScriptLayoutInit(script, layoutlsql);    //先合并分部页中的layout(分布页也是可以设置layout的)
                    CombineGlobalConfig(luasql, layoutlsql); //脚本合并
                }
                else
                {
                    throw new KeyNotFoundException($"Can not find the layout [{ lname }]");
                }
            }
        }
示例#5
0
        /// <summary>
        /// 初始化luasql对象数据
        /// </summary>
        /// <param name="luasql"></param>
        protected void InitLuaSql(LuaSqlScript script, LuaSqlModel luasql)
        {
            lock (script)
            {
                //设置表对象
                script.SqlTables[luasql.TableName] = new Dictionary <string, object>();
                //初始化表信息
                var t = (Table)script.SqlTables[luasql.TableName];
                t[LuaSqlConfigConst.SqlTableNameLabel]  = luasql.TableName;
                t[LuaSqlConfigConst.SqlConfigSqlsLabel] = new Dictionary <string, object>();
                t[LuaSqlConfigConst.SqlTableNameLabel]  = luasql.TableName;
                t[LuaSqlConfigConst.TablePoliciesLabel] = new Dictionary <string, object>();
                t[LuaSqlConfigConst.SqlPoliciesLabel]   = new Dictionary <string, object>();

                luasql.Config = t;
                luasql.Sqls   = (Table)luasql.Config[LuaSqlConfigConst.SqlConfigSqlsLabel];

                AddTableInfo(luasql);
            }
        }
 /// <summary>
 /// 脚本初始化(合并布局页等等)
 /// </summary>
 /// <param name="luasql"></param>
 abstract protected void DoLuaSqlInit(LuaSqlScript script, LuaSqlModel luasql);
 /// <summary>
 /// lua脚本配置初始化
 /// </summary>
 /// <param name="script"></param>
 /// <returns></returns>
 abstract protected void LuaConfigInit(LuaSqlScript script);
示例#8
0
 override protected void DoLuaSqlInit(LuaSqlScript script, LuaSqlModel luasql)
 {
     //初始化布局页
     ScriptLayoutInit(script, luasql);
 }
示例#9
0
 override protected void LuaConfigInit(LuaSqlScript script)
 {
     script.AddOrGetLuaSql += AddOrGetLuaSql;
 }