public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { var queueManagerFactory = new QueueManagerFactory(); var queueManager = queueManagerFactory.Make(); services.AddSingleton(typeof(IQueueManager), queueManager); AuthSettings.RootUserPictures = hostContext.Configuration["rootUserPictures"]; var connectionString = hostContext.Configuration["connectionString"]; var contextFactory = new AuthServiceDBContextFactory(connectionString); var repositoryFactory = new RepositoryFactory(); repositoryFactory.Add(typeof(IUserRepository), () => new UserRepository(contextFactory)); repositoryFactory.Add(typeof(ITokenRepository), () => new TokenRepository(contextFactory)); services.AddSingleton(typeof(IRepositoryFactory), repositoryFactory); var messageLogger = new MessageLogger(queueManager, AuthSettings.Host); services.AddSingleton(typeof(IMessageLogger), messageLogger); var processorContext = new MessageProcessorContext { QueueManager = queueManager, RepositoryFactory = repositoryFactory, Logger = messageLogger }; var processorFactory = new MessageProcessorFactory(processorContext); processorFactory.AddFromAssembly(Assembly.GetExecutingAssembly()); services.AddSingleton(typeof(IMessageProcessorFactory), processorFactory); var obsoleteUserPictureRemover = new ObsoleteUserPictureRemover(repositoryFactory); obsoleteUserPictureRemover.Remove(); services.AddHostedService <AuthWorker>(); });
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { var queueManagerFactory = new QueueManagerFactory(); var queueManager = queueManagerFactory.Make(); services.AddSingleton(typeof(IQueueManager), queueManager); var connectionString = hostContext.Configuration["connectionString"]; var contextFactory = new LoggerServiceDBContextFactory(connectionString); var repositoryFactory = new RepositoryFactory(); repositoryFactory.Add(typeof(ILogRepository), () => new LogRepository(contextFactory)); services.AddSingleton(typeof(IRepositoryFactory), repositoryFactory); var processorContext = new MessageProcessorContext { QueueManager = queueManager, RepositoryFactory = repositoryFactory }; var processorFactory = new MessageProcessorFactory(processorContext); processorFactory.AddFromAssembly(Assembly.GetExecutingAssembly()); services.AddSingleton(typeof(IMessageProcessorFactory), processorFactory); services.AddHostedService <LoggerWorker>(); });
public void ConfigureServices(IServiceCollection services) { services.AddSingleton(typeof(IAuthenticationManager), typeof(AuthenticationManager)); var queueManagerFactory = new QueueManagerFactory(); var queueManager = queueManagerFactory.Make(); services.AddSingleton(typeof(IQueueManager), queueManager); services.AddSingleton(typeof(IMessageLogger), new MessageLogger(queueManager, Host)); BrokerNotifier.Instance.Init(queueManager); services.AddSignalR(options => { options.MaximumReceiveMessageSize = Int64.MaxValue; }); services.AddControllers(); }