/// <summary>
        /// Register a StreamManager implementation with MongoDB persistence.
        /// </summary>
        /// <param name="services"></param>
        /// <param name="mongoDBSettings"></param>
        /// <returns></returns>
        public static IServiceCollection PersistWithMongoDB(this IServiceCollection services, MongoDBSettings mongoDBSettings)
        {
            MongoMappers.RegisterMaps();

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new DtoProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            var client        = new MongoClient(mongoDBSettings.ConnectionString);
            var streamManager = new MongoStreamManager(client, mongoDBSettings, mapper);

            services.AddSingleton <IStreamManager>(streamManager);

            return(services);
        }
Exemplo n.º 2
0
 public MongoStreamManager(MongoClient mongoClient, MongoDBSettings mongoDBSettings, IMapper mapper)
 {
     _mongoClient = mongoClient;
     _mapper      = mapper;
     _database    = _mongoClient.GetDatabase(mongoDBSettings.Database);
 }