Ejemplo n.º 1
0
        public static IRepositoryProvider Initialize(SupportedPersistenceType type)
        {
            switch (type)
            {
            case SupportedPersistenceType.MongoDB:
                return(MongoInitializer.Initialize("mongodb://localhost:27017", "Scrummy"));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Ejemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddRazorPages();

            // mongodb
            var connectionName = ISDEVELOPER ? "MongoNetWork" : "MongoAtlas";

            var mongoSettings = Configuration.GetSection(connectionName).Get <MongoSettings>();

            // collections
            services.AddSingleton <IMongoService <Book> >(MongoInitializer.Initialize <Book>(mongoSettings));

            // Swagger (by ilustration)
            if (ISDEVELOPER)
            {
                services.AddSwaggerGen(c => {
                    c.SwaggerDoc("v1", new OpenApiInfo {
                        Title   = "Blazor Mongo API",
                        Version = "v1"
                    });
                });
            }
        }
 private async Task SetupMongo_WithAuth()
 {
     MongoService = MongoInitializer.Initialize(DatabaseName, _schemaTypes);
     await Task.Delay(Delay);
 }