예제 #1
0
        private static async Task <ParsedDBCFile <TDBCEntryType> > ParseDBCFile <TDBCEntryType>(string filePath, Stopwatch watch) where TDBCEntryType : IDBCEntryIdentifiable
        {
            ParsedDBCFile <TDBCEntryType> dbc = null;

            using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                DBCEntryReader <TDBCEntryType> reader = new DBCEntryReader <TDBCEntryType>(fileStream, new NullLogger <DBCEntryReader <TDBCEntryType> >());

                watch.Start();
                dbc = await reader.Parse();
            }

            return(dbc);
        }
예제 #2
0
        public static async Task DumpDBCTable <TDBCEntryType>(string filePath)
            where TDBCEntryType : IDBCEntryIdentifiable
        {
            Stopwatch watch = new Stopwatch();
            ParsedDBCFile <TDBCEntryType> dbc = await ParseDBCFile <TDBCEntryType>(filePath, watch);

            watch.Stop();

            Console.WriteLine($"Loaded {filePath} in Milliseconds: {watch.ElapsedMilliseconds}");

            //Just dump it to a file
            // serialize JSON directly to a file
            using (StreamWriter file = File.CreateText($"Dump-{Path.GetFileNameWithoutExtension(filePath)}-{Guid.NewGuid().ToString()}.txt"))
            {
                JsonSerializer serializer = new JsonSerializer()
                {
                    Formatting = Formatting.Indented
                };
                serializer.Serialize(file, dbc);
            }
        }
        private static async Task <ParsedDBCFile <TDBCEntryType> > ParseDBCFile <TDBCEntryType>(string filePath, Stopwatch watch) where TDBCEntryType : IDBCEntryIdentifiable
        {
            ParsedDBCFile <TDBCEntryType> dbc = null;

            using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                SerializerService serializer = new SerializerService();
                foreach (Type t in DBCEntryReader.RequiredSerializeableTypes)
                {
                    serializer.RegisterType(t);
                }

                serializer.RegisterType <TDBCEntryType>();
                serializer.Compile();

                DBCEntryReader <TDBCEntryType> reader = new DBCEntryReader <TDBCEntryType>(fileStream, serializer);

                watch.Start();
                dbc = await reader.Parse();
            }

            return(dbc);
        }