private IServiceProvider ConfigureServices() { // Configure logging var logger = LogAdaptor.CreateLogger(); var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new SerilogLoggerProvider(logger)); // Configure services var services = new ServiceCollection() .AddSingleton(_client) .AddSingleton(_config) .AddSingleton(new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, ThrowOnError = false })) .AddSingleton(logger) .AddSingleton <LogAdaptor>() .AddSingleton <InteractiveService>() .AddSingleton <TagService>() /* * .AddDbContext<TagContext>(options => * { * options * .UseNpgsql(_config.Database.ConnectionString) * .UseLoggerFactory(loggerFactory); * })*/; var provider = services.BuildServiceProvider(); // Autowire and create these dependencies now provider.GetService <LogAdaptor>(); provider.GetService <TagService>(); return(provider); }
private IServiceProvider ConfigureServices() { // Configure logging var logger = LogAdaptor.CreateLogger(); var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new SerilogLoggerProvider(logger)); // Configure services var services = new ServiceCollection() .AddSingleton(_client) .AddSingleton(new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, ThrowOnError = false })) .AddSingleton(logger) .AddSingleton <LogAdaptor>() .AddSingleton <InteractiveService>(); var provider = services.BuildServiceProvider(); // Autowire and create these dependencies now provider.GetService <LogAdaptor>(); return(provider); }