Esempio n. 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);
        }
Esempio n. 2
0
        public void Dispose()
        {
            MiniMeService.Remove <IAimeService>();

            _context?.Dispose();
            _context = null;
        }
Esempio n. 3
0
        public AimeServer(IPEndPoint endPoint) : base(endPoint)
        {
            _context = new AimeContext();
            _context.Database.Migrate();

            MiniMeService.Add <IAimeService>(_context);
        }
Esempio n. 4
0
        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(MiniMeService.Get <ISwitchBoardService>());

            services.AddRequestDecompression(o =>
            {
                o.Providers.Add <Base64DecompressionProvider>();
                o.Providers.Add <ZlibDecompressionProvider>();
            });

            base.ConfigureServices(services);
        }
Esempio n. 5
0
        public override void ConfigureServices(IServiceCollection services)
        {
            services
            .AddDbContext <ChunithmContext>()
            .AddSingleton(MiniMeService.Get <IAimeService>())
            .AddRequestDecompression(o =>
            {
                o.Providers.Add <ZlibDecompressionProvider>();
            })
            .AddResponseCompression(o =>
            {
                o.Providers.Add <ZlibCompressionProvider>();
            });

            base.ConfigureServices(services);
        }
Esempio n. 6
0
        private static IEnumerable <ServerBase> CreateServers()
        {
            var switchBoard = MiniMeService.Get <ISwitchBoardService>();
            var dnsEntry    = Dns.GetHostEntry(switchBoard.Host);

            if (dnsEntry.AddressList.Length == 0)
            {
                throw new Exception("Dns address not found.");
            }

            var address = dnsEntry.AddressList[0];

            yield return(new AimeServer(new IPEndPoint(address, switchBoard.Ports.Aime)));

            yield return(new AllNetServer(new IPEndPoint(address, switchBoard.Ports.AllNet)));

            yield return(new ChunithmServer(new IPEndPoint(address, switchBoard.Ports.Chunithm)));

            yield return(new BillingServer(new IPEndPoint(address, switchBoard.Ports.Billing)));
        }