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); }
public void Dispose() { MiniMeService.Remove <IAimeService>(); _context?.Dispose(); _context = null; }
public AimeServer(IPEndPoint endPoint) : base(endPoint) { _context = new AimeContext(); _context.Database.Migrate(); MiniMeService.Add <IAimeService>(_context); }
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); }
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); }
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))); }