public static MagnetServerBuilder AddMongoStore( this MagnetServerBuilder builder, DatabaseOptions options) { builder.SetMessageStore <MessageStore>(); builder.Services.AddSingleton(options); builder.Services.AddSingleton((c) => new MessageDbContext(new MongoClient(options.ConnectionString), options)); return(builder); }
public static MagnetServerBuilder AddMongoStore( this MagnetServerBuilder builder, IConfiguration configuration) { IConfigurationSection section = configuration.GetSection("Magnet:MongoDb"); DatabaseOptions options = section.Get <DatabaseOptions>(); if (options?.ConnectionString != null) { builder.AddMongoStore(options); } return(builder); }
public MessageDbContext(MongoClient mongoClient, DatabaseOptions options) { _mongoClient = mongoClient; _options = options; }