public ReadModelService(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); this.collection = database.GetCollection <Package>(settings.ReadModelCollectionName); }
/// <summary> /// Конструктор. /// </summary> /// <param name="settings">Настройки подключения к Mongo.</param> /// <param name="context">Контекст подключения к Mongo.</param> /// <param name="logger">Для логирования событий.</param> public MessageTemplatesRepository(IOptions <MongoSettings> settings, MongoContext context, ILogger <MessageTemplate> logger) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); MongoSettings mongoSettings = settings?.Value ?? throw new ArgumentNullException(nameof(settings)); collection = context.GetCollection <MessageTemplate>(mongoSettings.CollectionName); }
public StatusController(ProxySettings proxySettings, MongoSettings mongoSettings, ProxyStore store, Status status) { ProxySettings = proxySettings; MongoSettings = mongoSettings; Store = store; Status = status; }
public DataService(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _data = database.GetCollection <CellInfoMongoModel>(settings.CollectionName); }
public MongoRepository(MongoSettings mongoSettings) { var database = new MongoClient(mongoSettings.ConnectionString) .GetDatabase(mongoSettings.Database); _collection = database.GetCollection <TDocument>(GetCollectionName(typeof(TDocument))); }
public ServicesRepository(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _services = database.GetCollection <Service>(settings.ServicesCollectionName); }
public MongoWrapper(IOptionsMonitor <MongoSettings> dbConfig) { _options = dbConfig.CurrentValue; var mongoClient = new MongoClient(_options.ConnectionString); db = mongoClient.GetDatabase(_options.Database); }
public SiteSettingsService(MongoSettings.Service.IMongoSettingsService dbService) { _dbService = dbService; _dbService.SettingsChanged += _dbService_SettingsChanged; LoadSiteSettings(); }
public TodoContext(MongoSettings settings) { var client = new MongoClient(settings.Host); var db = client.GetDatabase(settings.Database); Todos = db.GetCollection <Todo>(nameof(Todo)); }
public MongoCRUD(MongoSettings settings) { var client = new MongoClient(); this.db = client.GetDatabase(settings.DataBaseName); this.collectionName = settings.CollectionName; }
public NewsService(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.Database); _news = database.GetCollection <News> ("news"); }
public CRUDService(MongoService mongoService, MongoSettings settings, AppEngine lambdaManager) { _mongoService = mongoService; _settings = settings; this.lambdaManager = lambdaManager; LoadCollectionNames(); }
public void MongoBookDBContext_Constructor_Success() { try { var settings = new MongoSettings() { Connection = "mongodb://*****:*****@127.0.0.1:27017/BillTrackerDB", DatabaseName = "BillTrackerDB" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c .GetDatabase(_mockOptions.Object.Value.DatabaseName, null)) .Returns(_mockDB.Object); //Action var context = new MongoDBContext(_mockOptions.Object); if (context != null) { //Write test result in text file String testResult = "MongoBookDBContext_Constructor_Success= True"; fileUtility.WriteTestCaseResuItInText(testResult); } //Assert Assert.NotNull(context); } catch (Exception ex) { var error = ex; //Write test result in text file String testResult = "MongoBookDBContext_Constructor_Success= False"; fileUtility.WriteTestCaseResuItInText(testResult); } }
public EventStoreService(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); this.collection = database.GetCollection <EventStore>(settings.EventStoreCollectionName); }
public async Task RunBeforeAllTests() { //Setup MongoDB InMemory MongoDbServer = MongoDbRunner.Start(); // Setup IoC Container var builder = new ContainerBuilder(); builder.RegisterModule(new IoCModuleApplicationService()); builder.RegisterModule(new IoCModuleInfrastructure()); builder.RegisterModule(new IoCModuleAutoMapper()); builder.RegisterModule(new IoCModuleDomainTest()); builder.RegisterModule(new IoCModuleDatabase()); var settings = new MongoSettings { ConnectionString = MongoDbServer.ConnectionString, DatabaseName = "Database-Domain-Tests" }; builder.RegisterInstance(settings); Container = builder.Build(); //Apply Db Migrations var migrator = Container.Resolve <IDatabaseMigrator>(); await migrator.ApplyMigrations(); }
public MongoCodeManagmentService(IOptionsMonitor <MongoSettings> optionsMonitor) { _mongoDBStoreDatabaseSettings = optionsMonitor.CurrentValue; var client = new MongoClient(_mongoDBStoreDatabaseSettings.ConnectionString); var database = client.GetDatabase(_mongoDBStoreDatabaseSettings.DatabaseName); _uploadData = database.GetCollection <UploadData>(CollectionName); }
public MongoDataStore(IOptions <MongoSettings> mongoSettings) { _mongoSettings = mongoSettings.Value; var client = new MongoClient(_mongoSettings.ConnectionString); var database = client.GetDatabase(_mongoSettings.DatabaseName); _collection = database.GetCollection <T>(GetCollectionName()); }
/// <summary> /// Конструктор, создает подключение к БД. /// </summary> /// <param name="settings">Настройки подключения к Mongo.</param> public MongoContext(IOptions <MongoSettings> settings) { MongoSettings mongoSettings = settings?.Value ?? throw new ArgumentNullException(nameof(settings)); MongoUrl url = MongoUrl.Create(mongoSettings.ConnectionString); IMongoClient client = new MongoClient(url); database = client.GetDatabase(url.DatabaseName); }
public MongoContext(MongoSettings mongoSettings) { _mongoSettings = mongoSettings; _commands = new List <Func <Task> >(); Configure(); }
public ApplicationContext(MongoSettings settings) { string connectionString = @"mongodb://*****:*****@mongo:27017"; MongoClient client = new MongoClient(connectionString); IMongoDatabase database = client.GetDatabase("resultsDB"); Users = database.GetCollection <User>("users"); Criteria = database.GetCollection <ResultCriterion>("criteria"); }
public MongoDataContext(MongoSettings settings) { var client = new MongoClient(settings.ConnectionString); if (client != null) { _database = client.GetDatabase(settings.Database); } }
public UsersApiController(IOptions <MongoSettings> mongoSettings, IOptions <EmailSettings> emailSettings, IViewRenderService viewRenderService) { _MongoSettings = mongoSettings.Value; _EmailSettings = emailSettings.Value; _client = new MongoClient(_MongoSettings.MongoDbHost); _database = _client.GetDatabase(_MongoSettings.DatabaseName); _emailHelper = new EmailHelper(_EmailSettings); this._renderService = viewRenderService; }
public MongoContext(IOptions <MongoSettings> mongoSettings) { _commands = new List <Func <Task> >(); _mongoSettings = mongoSettings.Value; _mongoClient = new MongoClient(_mongoSettings.Connection); _db = _mongoClient.GetDatabase(_mongoSettings.DatabaseName); }
public QueridometroRepository(IOptions <MongoSettings> options) { _appSettings = options.Value; var client = new MongoClient(_appSettings.ConnectionString); var database = client.GetDatabase(_appSettings.Database); _queridometro = database.GetCollection <Core.Entities.Queridometro>(_appSettings.Collection); }
public ReviewsApiController(IOptions <MongoSettings> mongoSettings, IOptions <EmailSettings> emailSettings, IViewRenderService viewRenderService) { _MongoSettings = mongoSettings.Value; _client = new MongoClient(_MongoSettings.MongoDbHost); _database = _client.GetDatabase(_MongoSettings.DatabaseName); _imagesBucket = new GridFSBucket(_database, new GridFSBucketOptions() { BucketName = "gallery" }); }
public DataBaseHelper(string connection, string database) { var settings = new MongoSettings { Connection = connection, DatabaseName = database }; _mongoContext = new MongoContext(settings); }
public void Deve_Registrar_Logs_No_Repositorio_MongoDB() { //Given var dataBaseName = "mongo-auto-create"; var entity = new AggregateRoot(); var mongoSettings = new MongoSettings { DatabaseName = dataBaseName, ConnectionString = "mongodb://127.0.0.1:27017" }; var setMock = new Mock <IMongoCollection <AggregateRoot> >(); var mongoContextMock = new Mock <MongoContext>(mongoSettings); var logger = new XunitLogger <MongoRepository <AggregateRoot, Guid> >(); var loggerFactoryMock = new Mock <ILoggerFactory>(); loggerFactoryMock.Setup(setup => setup.CreateLogger(It.IsAny <string>())).Returns(logger); var repositoryMock = new MongoRepository <AggregateRoot, Guid>(mongoContextMock.Object, loggerFactoryMock.Object); //When repositoryMock.GetByIdAsync(entity.Id).ConfigureAwait(false); repositoryMock.GetAllAsync(); repositoryMock.InsertAsync(entity); repositoryMock.UpdateAsync(entity); repositoryMock.DeleteAsync(entity); repositoryMock.DeleteAsync(entity.Id).ConfigureAwait(false); repositoryMock.SaveChangesAsync(); //Then var msgContructor = "Inicializando MongoRepository<AggregateRoot, Guid>"; var msgGetById = $"Método: GetByIdAsync( {{id:{ entity.Id }}} ) Retorno: type AggregateRoot"; var msgGetAllAsync = "Método: GetAllAsync() Retorno: IAsyncEnumerable<AggregateRoot>"; var msgInsertAsync = $"Método: InsertAsync( {{entity:{ entity.ToJson()}}} )"; var msgUpdateAsync = $"Método: UpdateAsync( {{entity:{ entity.ToJson()}}} )"; var msgDeleteAsync = $"Método: DeleteAsync( {{entity:{ entity.ToJson()}}} )"; var msgDeleteNotFoundAsync = $"Método: DeleteAsync( {{id:{ entity.Id }}} ) Registro não encontrado"; var msgSaveChanges = "Método: SaveChangesAsync()"; logger.Logs.Should().HaveCount(9); logger.Logs.Any(a => a.Equals(msgGetById)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgContructor)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgGetAllAsync)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgInsertAsync)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgUpdateAsync)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgDeleteAsync)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgDeleteNotFoundAsync)).Should().BeTrue(); logger.Logs.Any(a => a.Equals(msgSaveChanges)).Should().BeTrue(); mongoContextMock.Object.MongoClient.DropDatabase(dataBaseName); mongoContextMock.Object.Dispose(); }
public ImagesApiController(IHostingEnvironment env, IOptions <MongoSettings> mongoSettings) { hostingEnv = env; _mongoSettings = mongoSettings.Value; _client = new MongoClient(_mongoSettings.MongoDbHost); _database = _client.GetDatabase(_mongoSettings.DatabaseName); _imagesBucket = new GridFSBucket(_database, new GridFSBucketOptions() { BucketName = "gallery" }); }
public static void Setup(IServiceCollection services, AppSettings appSettings) { var mongoSettings = new MongoSettings( appSettings.MongoConfiguration.ConnectionString, appSettings.MongoConfiguration.Database); services.AddSingleton(typeof(IMongoSettings), mongoSettings); services.AddSingleton(typeof(IMongoClient), new MongoClient(mongoSettings.ConnectionString)); services.AddSingleton <IMongoWrapper, MongoWrapper>(); }
public FileInfoService( MongoSettings mongoSettings, ISaveFileService saveFileService, IHttpContextAccessor contextAccessor) { var client = new MongoClient(mongoSettings.ConnectionString); var database = client.GetDatabase(mongoSettings.DatabaseName); _files = database.GetCollection <FileInfo>(mongoSettings.CollectionName); _saveFileService = saveFileService; _contextAccessor = contextAccessor; }
private static IOptions <MongoSettings> CreateMongoSettingsOptions() { var mongoSettings = new MongoSettings() { ConnectionString = "mongodb://localhost:27017?maxPoolSize=5", Database = DbName, CollectionPrefix = DbPrefix }; var mongoSettingsOptions = Options.Create(mongoSettings); return(mongoSettingsOptions); }
public MongoConnection(MongoSettings mongoSettings) { m_mongoSettings = mongoSettings; }