Ejemplo n.º 1
0
        public static void InitializeStudents(this IServiceCollection services, IConfiguration config)
        {
            services.AddSingleton <MongoConfiguration, MongoConfiguration>(p => MongoConfiguration.Create(config));
            services.AddTransient <IMongoDatabase, IMongoDatabase>(ConnectToDataStore);

            services.AddSingleton <EmployeeView, EmployeeView>(p => CreateListener <EmployeeView>(p, Streams.Employee));
            services.AddSingleton <UtoView, UtoView>(p => CreateListener <UtoView>(p, Streams.UtoRequests));

            services.AddSingleton <IListener, ListenerCollection>(CreateListenerCollection);

            services.AddTransient <EventReader, EventReader>(p => new EventReader(p.GetService <IMongoDatabase>()));
            services.AddTransient <EventWriter, EventWriter>(p => new EventWriter(p.GetService <IMongoDatabase>(), p.GetService <IListener>()));

            services.AddSingleton <EmployeeWriter, EmployeeWriter>(CreateEmployeeWriter);
            services.AddSingleton <UtoWriter, UtoWriter>(CreateUtoWriter);
        }