Exemple #1
0
        private static void Initialize()
        {
            // Encodings

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            // Logger

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(
                theme: AnsiConsoleTheme.Code,
                outputTemplate: "[MiniMe {Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger();

            // SwitchBoard

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", false)
                         .Build();

            MiniMeService.Add <ISwitchBoardService>(
                new SwitchBoard(
                    config.GetValue <string>("Host"),
                    config.GetOptions <MiniMePorts>("Port")));

            // Hook console terminate request for windows
            ConsoleUtility.HookExit(Terminate);
        }