using CommonLang.IO;
using CommonLang.Xml;
using CommonNetwork.Http;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace CommonTest
{
    public static class Test
    {
        public static bool TEST_XML = false;
        public static bool TEST_VLQ = false;
        public static bool TEST_MPQ = false;
        public static bool TEST_HTTP_CHUNK = true;

        public static void Execute()
        {
//             if (TEST_XML)
//             {
//                 var xml = XmlUtil.FromString("<f><f size= '20' color='FF5BC61A'>破甲之剑</f><br/><f size= '20'>需等级:1</f><br/>需要声望崇拜</f>");
//                 Console.WriteLine(XmlUtil.ToString(xml));
//             }
//             if (TEST_VLQ)
//             {
//                 using (var ms = new MemoryStream())
//                 {
//                     Random random = new Random();
//                     OutputStream input = new OutputStream(ms, null);
//                     InputStream output = new InputStream(ms, null);
//                     int a = 1, b = 0;
//                     long len = 0;
//                     for (int i = 0; i < 10000; i++)
//                     {
//                         a = random.Next(-i, i);
//                         ms.Position = 0;
//                         input.PutVS32(a);
//                         len = ms.Position;
//                         ms.Position = 0;
//                         b = output.GetVS32();
//                         if (a != b)
//                         {
//                             throw new Exception("VLQ Error");
//                         }
//                         else
//                         {
//                             Console.WriteLine(string.Format("vlq : len={2} {0}={1}", a, b, len));
//                         }
//                     }
//                 }
//             }
//             if (TEST_MPQ)
//             {
//                 MPQ.FileSystem.MPQFileSystem fs = new MPQ.FileSystem.MPQFileSystem();
//                 fs.init(new DirectoryInfo(@"K:\morefuntek\Zeus\GameEditors\Http\res_develop\updates_etc"));
//             }
            if (TEST_HTTP_CHUNK)
            {
                var uil = new Uri("http://dl.sjcs.moreu.cn/tt/res_release/updates_etc/res_20161103182256.mpq.z");
                var data = WebClient.Get(uil);
                Console.WriteLine(data);
            }
        }
    }

    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Test.Execute();
//             Application.EnableVisualStyles();
//             Application.SetCompatibleTextRenderingDefault(false);
//             Application.Run(new FormLaunch());
            //Application.Run(new FormAstar());
        }
    }
}