public MongoDbClient(MongoDbOptions options)
        {
            Options = options;

            var url    = MongoUrl.Create(options.ConnectionString);
            var client = new MongoClient(url);

            Database = client.GetDatabase(url.DatabaseName);

            Configurations = Database.GetCollection <ConfigurationSnapshot>(options.CollectionNamePrefix + options.ConfigurationCollectionName);
            Security       = Database.GetCollection <SecuritySnapshot>(options.CollectionNamePrefix + options.SecurityCollectionName);
        }
Beispiel #2
0
        public static void AddImageServerMongoDb(this IServiceCollection collection, MongoDbOptions options)
        {
            collection.AddSingleton(options);
            collection.AddSingleton <MongoDbClient>();
            collection.AddSingleton <IConfigurationRepository, ConfigurationRepository>();
            collection.AddSingleton <IImageRepository, ImageRepository>();
            collection.AddSingleton <IThumbnailRepository, ThumbnailRepository>();
            collection.AddSingleton <ISecurityConfigurationRepository, SecurityConfigurationRepository>();

            if (options.UseObjectIds)
            {
                collection.RemoveAll <IIdGenerator>();
                collection.AddSingleton <IIdGenerator, ObjectIdGenerator>();
            }
        }