public void MongoDbConventionTest()
        {
            MongoDbConvention.SetCamelCaseElementNameConvention();
            var convention = ConventionRegistry.Lookup(typeof(Type)).Conventions.FirstOrDefault(c => c.Name == "CamelCaseElementName");

            convention.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets MongoDb services.
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddMongoDb(this IServiceCollection services, IConfiguration configuration)
        {
            MongoDbConvention.SetCamelCaseElementNameConvention();

            services.Configure <MongoDbConfiguration>(configuration.GetSection("Database"));
            services.TryAddSingleton <IValidateOptions <MongoDbConfiguration>, MongoDbConfigurationValidation>();

            services.AddSingleton <IDataRepository, DataRepository>();

            return(services);
        }
Ejemplo n.º 3
0
 public MongoProvider(SeederConfiguration configuration)
 {
     MongoDbConvention.SetCamelCaseElementNameConvention();
     Collections = new List <ISeed>
     {
         new MongoDiscountSeed(configuration),
         new MongoTagSeed(configuration),
         new MongoUserSeed(configuration),
         new MongoExternalUserSeed(configuration)
     };
 }
        /// <summary>
        /// Gets MongoDb services.
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddMongoDb(this IServiceCollection services)
        {
            MongoDbConvention.SetCamelCaseElementNameConvention();

            services.AddSingleton <IDbConfiguration, MongoDbConfiguration>();
            services.AddSingleton <IDiscountRepository, DiscountRepository>();
            services.AddSingleton <IAddressRepository, QuickSearchRepository>();
            services.AddSingleton <ICompanyRepository, QuickSearchRepository>();
            services.AddSingleton <IUserRepository, UserRepository>();
            services.AddSingleton <ITagRepository, QuickSearchRepository>();
            services.AddSingleton <IStatisticsRepository, StatisticsRepository>();

            return(services);
        }