コード例 #1
0
        private static void GenerateDataTableFilesAndScripts()
        {
            for (int i = 0; i < ProcedurePreload.DataTableNames.Length; i++)
            {
                string dataTableName = ProcedurePreload.DataTableNames[i];
                EditorUtility.DisplayProgressBar("序列化数据表文件和数据脚本", Utility.Text.Format("正在序列化{0}/{1}", i + 1, ProcedurePreload.DataTableNames.Length), (float)i / ProcedurePreload.DataTableNames.Length);
                try
                {
                    DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTableName);
                    if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTableName))
                    {
                        Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTableName));
                        break;
                    }

                    DataTableGenerator.GenerateDataFile(dataTableProcessor, dataTableName);     //创建数据文件
                    DataTableGenerator.GenerateCodeFile(dataTableProcessor, dataTableName);     //创建脚本文件
                }
                catch (Exception e)
                {
                    Debug.LogError(e.ToString());
                }
            }

            EditorUtility.ClearProgressBar();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        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());
        }
コード例 #3
0
        public PlainDataTableResult(IQueryable <TSource> query, IFilterRequest request, OutputType?outputType = null)
            : base(outputType)
        {
            IDataTableFilterProcessor filterProcessor = new DataTableFilterProcessor();
            IDataTableProcessor       processor       = new DataTableProcessor(filterProcessor);

            this.Data = processor.Process(query, request);
        }
コード例 #4
0
        private static string GenerateDataTableStringParser(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder
            .AppendLine("        public override bool ParseDataRow(GameFrameworkSegment<string> dataRowSegment)")
            .AppendLine("        {")
            .AppendLine("            // Star Force 示例代码,正式项目使用时请调整此处的生成代码,以处理 GCAlloc 问题!")
            .AppendLine("            string[] columnTexts = dataRowSegment.Source.Substring(dataRowSegment.Offset, dataRowSegment.Length).Split(DataTableExtension.DataSplitSeparators);")
            .AppendLine("            for (int i = 0; i < columnTexts.Length; i++)")
            .AppendLine("            {")
            .AppendLine("                columnTexts[i] = columnTexts[i].Trim(DataTableExtension.DataTrimSeparators);")
            .AppendLine("            }")
            .AppendLine()
            .AppendLine("            int index = 0;");

            for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
            {
                if (dataTableProcessor.IsCommentColumn(i))
                {
                    // 注释列
                    stringBuilder.AppendLine("            index++;");
                    continue;
                }

                if (dataTableProcessor.IsIdColumn(i))
                {
                    // 编号列
                    stringBuilder.AppendLine("            m_Id = int.Parse(columnTexts[index++]);");
                    continue;
                }

                if (dataTableProcessor.IsSystem(i))
                {
                    string languageKeyword = dataTableProcessor.GetLanguageKeyword(i);
                    if (languageKeyword == "string")
                    {
                        stringBuilder.AppendFormat("            {0} = columnTexts[index++];", dataTableProcessor.GetName(i)).AppendLine();
                    }
                    else
                    {
                        stringBuilder.AppendFormat("            {0} = {1}.Parse(columnTexts[index++]);", dataTableProcessor.GetName(i), languageKeyword).AppendLine();
                    }
                }
                else
                {
                    stringBuilder.AppendFormat("            {0} = DataTableExtension.Parse{1}(columnTexts[index++]);", dataTableProcessor.GetName(i), dataTableProcessor.GetType(i).Name).AppendLine();
                }
            }

            stringBuilder
            .AppendLine()
            .AppendLine("            GeneratePropertyArray();")
            .AppendLine("            return true;")
            .Append("        }");

            return(stringBuilder.ToString());
        }
コード例 #5
0
        // POST api/values
        public IHttpActionResult Post([FromBody] FilterRequest filter)
        {
            IDataTableFilterProcessor   filterProcessor = new DataTableFilterProcessor();
            IDataTableProcessor         processor       = new DataTableProcessor(filterProcessor);
            IPageResponse <UserProfile> response        = processor.Process(UserProfiles.AsQueryable(), filter,
                                                                            (x) => x.Where(y => y.BirthDate > new DateTime(2014, 01, 01)));

            return(Ok(response));
        }
コード例 #6
0
        // 生成byte文件
        public static void GenerateDataFile(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            string binaryDataFileName = Utility.Path.GetCombinePath(DataTablePath, dataTableName + ".bytes");

            if (!dataTableProcessor.GenerateDataFile(binaryDataFileName, Encoding.UTF8) && File.Exists(binaryDataFileName))
            {
                File.Delete(binaryDataFileName);
            }
        }
コード例 #7
0
        public void TestProcess()
        {
            string    expr = ".1 + 28 / 7 * (45 + (3 - .8))";
            Processor p    = new DataTableProcessor();

            double expected = 188.9;

            Assert.AreEqual(expected, p.Process(expr));
        }
コード例 #8
0
        // POST api/values
        //public void Post([FromBody]UserProfile userProfile)
        //{
        //    UserProfiles.Add(userProfile);
        //}

        // POST api/values
        public IHttpActionResult Post([FromBody]FilterRequest filter)
        {
            IDataTableFilterProcessor filterProcessor = new DataTableFilterProcessor();
            IDataTableProcessor processor = new DataTableProcessor(filterProcessor);
            IPageResponse<UserProfile> response = processor.Process(UserProfiles.AsQueryable(), filter,
                (x) => x.Where(y => y.BirthDate > new DateTime(2014, 01, 01)));

            return Ok(response);
        }
コード例 #9
0
        public MutableDataTableResult(IQueryable <object> query, IFilterRequest request, OutputType?outputType = null)
            : base(outputType)
        {
            IDataTableFilterProcessor filterProcessor = new DataTableFilterProcessor();
            IDataTableProcessor       processor       = new DataTableProcessor(filterProcessor);
            IPageResponse <object>    response        = processor.Process(query, request);

            this.Data = response;
        }
コード例 #10
0
        public static void GenerateDataFile(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            string binaryDataFileName = Utility.Path.GetRegularPath(Path.Combine(DataTablePath, dataTableName + ".bytes"));

            if (!dataTableProcessor.GenerateDataFile(binaryDataFileName) && File.Exists(binaryDataFileName))
            {
                File.Delete(binaryDataFileName);
            }
        }
        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__", "Flower");
            codeContent.Replace("__DATA_TABLE_ENUM_NAME__", "Enum" + dataTableName);
            //codeContent.Replace("__DATA_TABLE_COMMENT__", dataTableProcessor.GetValue(0, 1) + "。");
            codeContent.Replace("__DATA_TABLE_ENUM_ITEM__", GenerateEnumItems(dataTableProcessor));
        }
コード例 #12
0
        public static void GenerateCodeFile(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            dataTableProcessor.SetCodeTemplate(CSharpCodeTemplateFileName, Encoding.UTF8);
            dataTableProcessor.SetCodeGenerator(DataTableCodeGenerator);

            string csharpCodeFileName = Utility.Path.GetRegularPath(Path.Combine(CSharpCodePath, "DR" + dataTableName + ".cs"));

            if (!dataTableProcessor.GenerateCodeFile(csharpCodeFileName, Encoding.UTF8, dataTableName) && File.Exists(csharpCodeFileName))
            {
                File.Delete(csharpCodeFileName);
            }
        }
コード例 #13
0
        //生成数据文件
        public static void GenerateDataFile(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            string binaryDataFileName = Utility.Path.GetCombinePath(RuntimeAssetUtility.DataTablePath, RuntimeAssetUtility.BytesFolder, dataTableName + RuntimeAssetUtility.bytesExtension);       //二进制的数据文件名

            if (!dataTableProcessor.GenerateDataFile(binaryDataFileName, Encoding.UTF8) && File.Exists(binaryDataFileName))
            {
                //创建失败,并且文件存在,则删除
                File.Delete(binaryDataFileName);
                Debug.LogError(Utility.Text.Format("失败:生成数据表文件 -> {0}", dataTableName));
            }
            AssetDatabase.Refresh();
        }
コード例 #14
0
        public IActionResult Index(DataTablePostModel dataTablePostModel)
        {
            var model = db.Album.Select(q => new DataTableAlbumList
            {
                Id   = q.Id,
                Name = q.Name
            });

            var Albums = DataTableProcessor <DataTableAlbumList> .ProcessCollection(model, dataTablePostModel).ToList();

            return(View());
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        private static string GenerateDataTableStreamParser(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder
            .AppendLine("        public override bool ParseDataRow(GameFrameworkSegment<Stream> dataRowSegment)")
            .AppendLine("        {")
            .AppendLine("            Log.Warning(\"Not implemented ParseDataRow(GameFrameworkSegment<Stream>)\");")
            .AppendLine("            return false;")
            .Append("        }");

            return(stringBuilder.ToString());
        }
コード例 #17
0
ファイル: DataTableGenerator.cs プロジェクト: xin0205/MyTest
        private static string GenerateDataTableProperties(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          firstProperty = true;

            for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
            {
                if (dataTableProcessor.IsCommentColumn(i))
                {
                    // 注释列
                    continue;
                }

                if (dataTableProcessor.IsIdColumn(i))
                {
                    // 编号列
                    continue;
                }

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


                string typeName = dataTableProcessor.GetLanguageKeyword(i);

                if (dataTableProcessor.IsList(i))
                {
                    typeName = "List<" + dataTableProcessor.GetLanguageKeyword(i) + ">";
                }


                stringBuilder
                .AppendLine("        /// <summary>")
                .AppendFormat("        /// 获取{0}。", dataTableProcessor.GetComment(i)).AppendLine()
                .AppendLine("        /// </summary>")
                .AppendFormat("        public {0} {1}", typeName, dataTableProcessor.GetName(i)).AppendLine()
                .AppendLine("        {")
                .AppendLine("            get;")
                .AppendLine("            private set;")
                .Append("        }");
            }

            return(stringBuilder.ToString());
        }
コード例 #18
0
        //生成重写解析字节流数据的方法
        private static string GenerateDataTableBytesParser(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder
            .AppendLine("    public override bool ParseDataRow(GameFrameworkSegment<byte[]> dataRowSegment)")
            .AppendLine("    {")
            .AppendLine("        // Star Force 示例代码,正式项目使用时请调整此处的生成代码,以处理 GCAlloc 问题!")
            .AppendLine("        using (MemoryStream memoryStream = new MemoryStream(dataRowSegment.Source, dataRowSegment.Offset, dataRowSegment.Length, false))")
            .AppendLine("        {")
            .AppendLine("            using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))")
            .AppendLine("            {")
            .AppendLine("                try")
            .AppendLine("                {");

            for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
            {
                if (dataTableProcessor.IsCommentColumn(i))
                {
                    // 注释列
                    continue;
                }

                if (dataTableProcessor.IsIdColumn(i))
                {
                    // 编号列
                    stringBuilder.AppendLine("                    m_Id = binaryReader.ReadInt32();");
                    continue;
                }

                stringBuilder.AppendFormat("                    {0} = binaryReader.Read{1}();", dataTableProcessor.GetName(i), dataTableProcessor.GetType(i).Name).AppendLine();
            }

            stringBuilder
            .AppendLine("                }")
            .AppendLine("                catch (Exception e)")
            .AppendLine("                {")
            .AppendLine("                    Log.Error(\"ParseDataRow is failure, error message is:\\n{0}.\", e.ToString());")
            .AppendLine("                    return false;")
            .AppendLine("                }")
            .AppendLine("            }")
            .AppendLine("        }")
            .AppendLine()
            .AppendLine("        GeneratePropertyArray();")
            .AppendLine("        return true;")
            .Append("    }");

            return(stringBuilder.ToString());
        }
コード例 #19
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));
        }
        private static void GenerateDataTableEnum()
        {
            foreach (string dataTableName in GenerateDataTables)
            {
                DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTableName);
                if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTableName))
                {
                    Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTableName));
                    break;
                }

                GenerateEnumFile(dataTableProcessor, dataTableName);
            }

            AssetDatabase.Refresh();
        }
コード例 #21
0
        //生成脚本文件
        public static void GenerateCodeFile(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            dataTableProcessor.SetCodeTemplate(CSharpCodeTemplateFileName, Encoding.UTF8);
            dataTableProcessor.SetCodeGenerator(CustomDataTableCodeGenerator);

            string csharpCodeFileName = Utility.Path.GetCombinePath(CSharpCodePath, DataTableExtension.DataRowClassPrefixName + dataTableName + ".cs");

            if (!dataTableProcessor.GenerateCodeFile(csharpCodeFileName, Encoding.UTF8, dataTableName) && File.Exists(csharpCodeFileName))
            {
                //创建失败,并且文件存在,则删除
                File.Delete(csharpCodeFileName);
                Debug.LogError(Utility.Text.Format("失败:生成数据表结构 -> {0}", dataTableName));
            }

            AssetDatabase.Refresh();
        }
コード例 #22
0
        private static void GenerateDataTables()
        {
            foreach (string dataTableName in ProcedurePreload.DataTableNames)
            {
                DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTableName);
                if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTableName))
                {
                    Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTableName));
                    break;
                }

                DataTableGenerator.GenerateDataFile(dataTableProcessor, dataTableName);
                DataTableGenerator.GenerateCodeFile(dataTableProcessor, dataTableName);
            }

            Debug.Log("一键生成模板脚本,我在这里留个坑 什么先不做");
            AssetDatabase.Refresh();
        }
コード例 #23
0
        public static bool CheckRawData(DataTableProcessor dataTableProcessor, string dataTableName)
        {
            for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
            {
                string name = dataTableProcessor.GetName(i);
                if (string.IsNullOrEmpty(name) || name == "#")
                {
                    continue;
                }

                if (!NameRegex.IsMatch(name))
                {
                    Debug.LogWarning(Utility.Text.Format("Check raw data failure. DataTableName='{0}' Name='{1}'", dataTableName, name));
                    return(false);
                }
            }

            return(true);
        }
コード例 #24
0
        public IActionResult Index(DataTablePostModel dataTablePostModel)
        {
            var model = db.FAQ.Select(q => new DataTableFAQList
            {
                Id = q.Id,
                Question = q.Question,
                Answer = q.Answer
            });

            var FAQs = DataTableProcessor<DataTableFAQList>.ProcessCollection(model, dataTablePostModel).ToList();

            dynamic response = new
            {
                Data = FAQs,
                Draw = dataTablePostModel.draw,
                RecordsFiltered = model.ToList().Count,
                RecordsTotal = model.ToList().Count
            };
            return StatusCode(200, response);
        }
コード例 #25
0
        private static void GenerateDataTables()
        {
            foreach (string dataTableName in ProcedurePreload.DataTableNames)
            {
                DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTableName);
                if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTableName))
                {
                    UnityEngine.Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTableName));
                    break;
                }

                // dataTableName: Aircraft.txt
                // 生成byte文件: Aircraft.bytes
                DataTableGenerator.GenerateDataFile(dataTableProcessor, dataTableName);
                // 生成c#文件: Aircraft.cs
                DataTableGenerator.GenerateCodeFile(dataTableProcessor, dataTableName);
            }

            AssetDatabase.Refresh();
        }
コード例 #26
0
        public IActionResult Images(DataTablePostModel dataTablePostModel, int albumId)
        {
            var model = db.albumItem.Where(q => q.AlbumId == albumId).Select(q => new DataTableAlbumItemList
            {
                Id    = q.Id,
                Image = q.Image
            });

            var Images = DataTableProcessor <DataTableAlbumItemList> .ProcessCollection(model, dataTablePostModel).ToList();

            dynamic response = new
            {
                Data            = Images,
                Draw            = dataTablePostModel.draw,
                RecordsFiltered = model.ToList().Count,
                RecordsTotal    = model.ToList().Count
            };

            return(StatusCode(200, response));
        }
コード例 #27
0
        public IActionResult Index(DataTablePostModel dataTablePostModel)
        {
            var model = db.Album.Select(q => new DataTableAlbumList
            {
                Id   = q.Id,
                Name = q.Name
            });

            var Albums = DataTableProcessor <DataTableAlbumList> .ProcessCollection(model, dataTablePostModel).ToList();

            dynamic response = new
            {
                Data            = Albums,
                Draw            = dataTablePostModel.draw,
                RecordsFiltered = model.ToList().Count,
                RecordsTotal    = model.ToList().Count
            };

            return(StatusCode(200, response));
        }
コード例 #28
0
        public IActionResult Index(DataTablePostModel dataTablePostModel)
        {
            var model = db.Slider.Select(q => new DataTableSliderList
            {
                Id          = q.Id,
                Image       = q.Image,
                ScreenOrder = q.ScreenOrder
            });

            var Sliders = DataTableProcessor <DataTableSliderList> .ProcessCollection(model, dataTablePostModel).ToList();

            dynamic response = new
            {
                Data            = Sliders,
                Draw            = dataTablePostModel.draw,
                RecordsFiltered = model.ToList().Count,
                RecordsTotal    = model.ToList().Count
            };

            return(StatusCode(200, response));
        }
コード例 #29
0
        /// <summary>
        /// 打开编辑窗口
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="position">位置</param>
        public static void OpenWindow(string fileName, Vector2 position)
        {
            m_fileName       = fileName;
            m_tableProcessor = DataTableGenerator.CreateDataTableProcessor(fileName);
            if (!DataTableGenerator.CheckRawData(m_tableProcessor, fileName))
            {
                Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", fileName));
                return;
            }
            LoadDataTable();

            Rect rect = new Rect(DataTableEditorLaunchWindow.WindowRect);

            rect.position = position;
            var window = DataTableEditorWindow.GetWindowWithRect <DataTableEditorWindow>(rect, true, DataTableEditorConfig.GetConfig().WindowTitle);

            window.position = rect;
            window.minSize  = new Vector2(m_tableProcessor.RawColumnCount * (TextFieldWidth + 4) + 5, m_tableProcessor.RawRowCount * (TextFieldHeight + 2) + 215);
            window.maxSize  = new Vector2(m_tableProcessor.RawColumnCount * (TextFieldWidth + 4) + 5, m_tableProcessor.RawRowCount * (TextFieldHeight + 2) + 215);
            window.ShowUtility();
        }
コード例 #30
0
        //生成属性
        private static string GenerateDataTableProperties(DataTableProcessor dataTableProcessor)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          firstProperty = true; //是否是第一条属性的标志位

            for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
            {
                if (dataTableProcessor.IsCommentColumn(i))      // 注释列
                {
                    continue;
                }

                if (dataTableProcessor.IsIdColumn(i))       // 编号列
                {
                    continue;
                }

                if (firstProperty)
                {
                    firstProperty = false;
                }
                else
                {
                    stringBuilder.AppendLine().AppendLine();        //非第一条属性,要另起两行,保持与上衣属性的间距
                }

                stringBuilder
                .AppendLine("    /// <summary>")
                .AppendFormat("    /// 获取{0}", dataTableProcessor.GetComment(i)).AppendLine()           //列的注释
                .AppendLine("    /// </summary>")
                .AppendFormat("    public {0} {1} ", dataTableProcessor.GetLanguageKeyword(i), dataTableProcessor.GetName(i))
                .Append("{ get; private set; }");
                //.Append(" {")
                //.Append(" get;")
                //.Append(" private set;")
                //.Append(" }");
            }

            return(stringBuilder.ToString());
        }
コード例 #31
0
        public static void GenerateDataTables(List <GameFramework.DataTableTools.DataTableGenerateWindow.DataTableName> dataTableNames)
        {
            foreach (var dataTable in dataTableNames)
            {
                if (!dataTable.IsOn)
                {
                    continue;
                }

                DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTable.Name);
                if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTable.Name))
                {
                    Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTable.Name));
                    break;
                }

                DataTableGenerator.GenerateDataFile(dataTableProcessor, dataTable.Name);
                DataTableGenerator.GenerateCodeFile(dataTableProcessor, dataTable.Name);
            }

            AssetDatabase.Refresh();
        }