Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ColorWriter.WriteLine("Please, input unformatted json string:", ConsoleColor.White);

            var unformattedJson = Console.ReadLine();
            var formattedJson   = unformattedJson.ToJson();

            ColorWriter.WriteLine("Indented JSON:", ConsoleColor.White);
            ColorWriter.WriteLine(formattedJson, ConsoleColor.Blue);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static async void RunWithTest(ISettings settings)
        {
            HttpListener listener = new HttpListener();

            listener.Prefixes.Add(settings.Address);
            listener.Start();

            Console.WriteLine($"Http server is run. Current address: {settings.Address}");
            ConsoleCounter counter = new ConsoleCounter();

            while (true)
            {
                HttpListenerContext context = await listener.GetContextAsync();

                HttpListenerRequest  request  = context.Request;
                HttpListenerResponse response = context.Response;

                counter.Show();
                counter.Tick();

                var jsonRequest = GetJsonFromStream(request.InputStream);
                ColorWriter.WriteLine($"Message was recived:\n\n{jsonRequest}\n", ConsoleColor.Blue);
            }
        }