public override void Write(DataTableInfo tableInfo)
        {
            Type objType;

            objType = Reader.DataTableInfoToType(tableInfo);

            sb.Clear();
            var objs = Reader.LoadDataObjects(tableInfo.Name, objType).ToArray();

            serializer.Serialize(objs, sb);
            string outputFile = Path.Combine(OutputDir, tableInfo.Name + ".json");

            File.WriteAllText(outputFile, sb.ToString(), new UTF8Encoding(false));
            Console.WriteLine($"output {BuildDataUtility.ToRelativePath(outputFile, OutputDir)}. table <{tableInfo.Name}> type <{objType.FullName}> data length <{objs.Length}>");
        }
示例#2
0
        private static void BuildData(BuildOptions options, DataReader reader)
        {
            Console.WriteLine();
            Console.WriteLine("*** Build Data Begin ***");
            DateTime startTime = DateTime.Now;

            Console.WriteLine($"output directory: {BuildDataUtility.ToRelativePath(reader.Config.Output.Path, ".")}");
            Type writerType = GetDataWriterType(reader.Config);

            using (var writer = (DataWriter)Activator.CreateInstance(writerType))
            {
                writer.LoadConfig(reader.Config);
                writer.Open(reader);

                writer.WriteAll();
            }
            var usedTime = (DateTime.Now - startTime).TotalSeconds;

            Console.WriteLine("*** Build Data End. time:{0:0.#}s ***", usedTime);
        }