private static string GenerateEnumItems(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          firstProperty = true;

            int startRow = 4;

            stringBuilder
            .AppendLine("        /// <summary>")
            .AppendFormat("        /// {0}", "无").AppendLine()
            .AppendLine("        /// </summary>")
            .AppendFormat("        {0} = {1},", "None", "0").AppendLine().AppendLine();

            for (int i = startRow; i < dataTableProcessor.RawRowCount; i++)
            {
                int index = i - startRow;

                if (firstProperty)
                {
                    firstProperty = false;
                }
                else
                {
                    stringBuilder.AppendLine().AppendLine();
                }

                stringBuilder
                .AppendLine("        /// <summary>")
                .AppendFormat("        /// {0}", dataTableProcessor.GetValue(i, 2)).AppendLine()
                .AppendLine("        /// </summary>")
                .AppendFormat("        {0} = {1},", dataTableProcessor.GetValue(i, 3), dataTableProcessor.GetValue(i, 1));
            }
            return(stringBuilder.ToString());
        }
        private static void DataTableCodeGenerator(DataTableProcessor dataTableProcessor, StringBuilder codeContent, object userData)
        {
            string dataTableName = (string)userData;

            codeContent.Replace("__DATA_TABLE_CREATE_TIME__", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            codeContent.Replace("__DATA_TABLE_NAME_SPACE__", "StarForce");
            codeContent.Replace("__DATA_TABLE_CLASS_NAME__", "DR" + dataTableName);
            codeContent.Replace("__DATA_TABLE_COMMENT__", dataTableProcessor.GetValue(0, 1) + "。");
            codeContent.Replace("__DATA_TABLE_ID_COMMENT__", "获取" + dataTableProcessor.GetComment(dataTableProcessor.IdColumn) + "。");
            codeContent.Replace("__DATA_TABLE_PROPERTIES__", GenerateDataTableProperties(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_PARSER__", GenerateDataTableParser(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_PROPERTY_ARRAY__", GenerateDataTablePropertyArray(dataTableProcessor));
        }
Example #3
0
        /// <summary>
        /// 加载数据表文件
        /// </summary>
        private static void LoadDataTable()
        {
            rows = new List <Row>();

            for (int i = 0; i < m_tableProcessor.RawRowCount; i++)
            {
                Row newRow = new Row();
                for (int j = 0; j < m_tableProcessor.RawColumnCount; j++)
                {
                    newRow.RowData.Add(m_tableProcessor.GetValue(i, j));
                }
                rows.Add(newRow);
            }
        }
Example #4
0
        //数据表脚本生成器
        private static void CustomDataTableCodeGenerator(DataTableProcessor dataTableProcessor, StringBuilder codeContent, object userData)
        {
            string dataTableName = (string)userData;

            codeContent.Replace("__DATA_TABLE_CREATE_TIME__", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));                 //替换数据表创建时间
            codeContent.Replace("__DATA_TABLE_NAME_SPACE__", "Game.Runtime");                                                    //替换数据表所在命名空间,这里去掉命名空间
            codeContent.Replace("__DATA_TABLE_CLASS_NAME__", DataTableExtension.DataRowClassPrefixName + dataTableName);         //类名
            codeContent.Replace("__DATA_TABLE_COMMENT__", dataTableProcessor.GetValue(0, 1));                                    //脚本注释名
            codeContent.Replace("__DATA_TABLE_ID_COMMENT__", "获取" + dataTableProcessor.GetComment(dataTableProcessor.IdColumn)); //id注释
            codeContent.Replace("__DATA_TABLE_PROPERTIES__", GenerateDataTableProperties(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_STRING_PARSER__", GenerateDataTableStringParser(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_BYTES_PARSER__", GenerateDataTableBytesParser(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_STREAM_PARSER__", GenerateDataTableStreamParser(dataTableProcessor));
            codeContent.Replace("__DATA_TABLE_PROPERTY_ARRAY__", GenerateDataTablePropertyArray(dataTableProcessor));
        }