Example #1
0
        public void JMAQuakeConverterTest(string sourcePath, string expectedPath)
        {
            StreamReader reader  = new StreamReader(sourcePath, Encoding.UTF8);
            string       content = reader.ReadToEnd();

            reader.Close();

            Core   core = JMAQuakeConverter.fromString(content);
            string json = JsonConvert.SerializeObject(core, Formatting.Indented).Replace("\r", "");

            if (!File.Exists(expectedPath))
            {
                StreamWriter writer = new StreamWriter(expectedPath, false, Encoding.UTF8);
                writer.Write(json);
                writer.Close();

                Assert.Ignore();
                return;
            }

            StreamReader expectedReader = new StreamReader(expectedPath, Encoding.UTF8);
            string       expectedJson   = expectedReader.ReadToEnd().Replace("\r", "");

            expectedReader.Close();

            Assert.AreEqual(expectedJson, json);
        }
Example #2
0
        //public static void Main(string[] args)
        //{
        //    // P:\lib\p2pquake\quake_checker\downloads

        //    string[] files = Directory.GetFiles(@"P:\lib\p2pquake\quake_checker\downloads", "*.html");
        //    foreach (string file in files)
        //    {
        //        Console.WriteLine(file);
        //        Main2(new string[] {file, null}); // @"Z:\TEMP\output.json"});
        //        Console.ReadLine();
        //    }
        //}


        public static void Main(string[] args)
        {
            // Console.WriteLine("runtime: {0}", Type.GetType("Mono.Runtime") == null ? ".NET Framework?" : "Mono");

            if (args.Length < 1)
            {
                Console.Error.WriteLine("usage: QuakeAnalyzer <input.html> [<output.json>]");
                return;
            }

            string inputFileName  = args[0];
            string outputFileName = (args.Length >= 2) ? args[1] : null;

            Console.Error.WriteLine("Convert from " + inputFileName + " to " + outputFileName + ".");

            // ファイル読み込み
            StreamReader reader  = new StreamReader(inputFileName, Encoding.UTF8);
            string       content = reader.ReadToEnd();

            reader.Close();

            // Console.WriteLine (content);

            Core   core = JMAQuakeConverter.fromString(content);
            string json = JsonConvert.SerializeObject(core, Formatting.Indented);

            if (outputFileName != null)
            {
                // ファイル書き込み
                StreamWriter writer = new StreamWriter(outputFileName, false, new UTF8Encoding(false));
                writer.Write(json);
                writer.Close();
            }
            else
            {
                Console.WriteLine(json);
            }

            Console.Error.WriteLine("Finish at " + DateTime.Now.ToString());
        }
Example #3
0
 public static Core CreateFromString(string content)
 {
     return(JMAQuakeConverter.fromString(content));
 }