示例#1
0
        /*
         * /// <summary>
         * /// 解析外键列类型
         * /// </summary>
         * private IEnumerator ParseForeignKeyColumnType()
         * {
         *  foreach (var tableInfo in m_configDataTableInfoDic.Values)
         *  {
         *      foreach (var columnInfo in tableInfo.ColumnInfoList)
         *      {
         *          //遍历所有列定义,如果列名使用“."分割,说明是外键数据类型
         *          string typeStr = columnInfo.TypeStr;
         *          if (typeStr.IndexOf(".") != -1)
         *          {
         *              string[] tuple = typeStr.Split(new char[] { '.' });
         *              if (tuple.Length != 2)
         *              {
         *                  throw new Exception(string.Format("the column {0} at table {1} is a foreign key, but typeStr is not a tuple", columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              string foreignTableName = tuple[0];
         *              string foreignColumnName = tuple[1];
         *              if (!m_configDataTableInfoDic.ContainsKey(foreignTableName))
         *              {
         *                  throw new Exception(string.Format("can't find the foreign table {0} for the column {1} at table {2} ", foreignTableName, columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              var foreignTabelInfo = m_configDataTableInfoDic[foreignTableName];
         *              var foreignColumnInfo = foreignTabelInfo.GetColumnInfoByName(foreignColumnName);
         *              if (foreignColumnInfo == null)
         *              {
         *                  throw new Exception(string.Format("can't find the foreign column {0} for the column {1} at table {2}", foreignColumnName, columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              //设置正确的typeStr
         *              //columnInfo.RealTypeStr = foreignColumnInfo.TypeStr;
         *          }
         *      }
         *      yield return null;
         *  }
         * }
         */

        /// <summary>
        /// 产生ConfigDataLoaderAutoGen.cs
        /// </summary>
        private void GenerateConfigDataLoaderAutoGenFile()
        {
            string outputFolder = PathHelper.GetFullPath(m_setting.m_autoGenCodeOutputPath);

            if (Directory.Exists(outputFolder))
            {
                Directory.Delete(outputFolder, true);
            }
            Directory.CreateDirectory(outputFolder);

            var allConfigDataInfos = new List <ConfigDataTableInfo>(m_configDataTableInfoDic.Values);

            //产生ConfigDataLoaderAutoGen.cs,运行时读取功能
            {
                string template = File.ReadAllText(PathHelper.GetFullPath(m_setting.m_codeTempletePath) + "/ConfigDataLoaderAutoGen.cs.txt");
                string result   = NVelocityHelper.Parse(template, "AllConfigDataInfos", allConfigDataInfos);
                File.WriteAllText(outputFolder + "/ConfigDataLoaderAutoGen.cs", result);
            }
            AssetDatabase.Refresh();
        }