コード例 #1
0
        public BaseRepository(IMongoConfiguration settings)
        {
            var client   = new MongoClient(settings.ConnectionString);
            var database = client.GetDatabase(settings.DatabaseName);

            _mongoCollection = database.GetCollection <TModel>(typeof(TModel).Name.ToLowerInvariant());
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWorkflowDataAccess"/> class.
 /// </summary>
 /// <param name="configuration">The configuration options.</param>
 public MongoWorkflowDataAccess(IMongoConfiguration configuration)
 {
     this.Configuration = configuration;
     MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
     this.Server = client.GetServer();
     this.Database = this.Server.GetDatabase(configuration.Database);
 }
コード例 #3
0
ファイル: MongoEventStore.cs プロジェクト: mastoj/TJ.CQRS
 public MongoEventStore(IMongoConfiguration mongoConfiguration, IEventBus eventBus)
     : base(eventBus)
 {
     _server = MongoServer.Create(mongoConfiguration.Url);
     var mongoDatabaseSettings = _server.CreateDatabaseSettings(mongoConfiguration.DatabaseName);
     _database = _server.GetDatabase(mongoDatabaseSettings);
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoSystemEventLogger"/> class.
 /// </summary>
 /// <param name="configuration">The configuration options.</param>
 public MongoSystemEventLogger(IMongoConfiguration configuration)
 {
     this.Configuration = configuration;
     MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
     this.Server = client.GetServer();
     this.Database = this.Server.GetDatabase(configuration.Database);
 }
コード例 #5
0
 public MessageMongoRepository(ITenantService tenantService, IMongoConfiguration mongoConfiguration)
     : base(tenantService, mongoConfiguration, "messages")
 {
     CreateIndexIfNotExists("message-index",
                            Builders <IMessageDetail> .IndexKeys
                            .Ascending(i => i.MessageId)
                            .Ascending(i => i.SentBy));
 }
コード例 #6
0
 public LoginService(IDistributedCache cache
                     , IMongoConfiguration mongoConfig
                     , IHubContext <LoginHub> loginHub
                     , IPlayerService playerService) : base(cache, mongoConfig)
 {
     _loginHub      = loginHub;
     _playerService = playerService;
 }
コード例 #7
0
        public void SetUp()
        {
            configuration = Substitute.For <IMongoConfiguration>();

            configuration.ConnectionString.Returns(MongoDbConnectionStringValue);

            mongoClientFactory = new MongoClientFactory();
        }
コード例 #8
0
        public ReportRepository(IMongoConfiguration configuration)
        {
            _configuration = configuration;

            var client = new MongoClient(_configuration.ConnectionString);

            _database = client.GetDatabase(_configuration.Database);
        }
コード例 #9
0
        public MongoClient GetOrCreate(IMongoConfiguration mongoConfiguration)
        {
            if (this.mongoClient == null)
            {
                this.mongoClient = new MongoClient(mongoConfiguration.ConnectionString);
            }

            return(this.mongoClient);
        }
コード例 #10
0
 protected MongoRepositoryBase(
     IMongoClientProvider mongoClientProvider,
     IMongoConfiguration mongoConfiguration)
 {
     this.MongoConfiguration = mongoConfiguration;
     this.MongoClient        = mongoClientProvider.GetOrCreate(this.MongoConfiguration);
     this.MongoDatabase      = this.MongoClient.GetDatabase(this.MongoConfiguration.DatabaseName);
     this.MongoCollection    = this.GetOrCreateCollection();
 }
コード例 #11
0
        public MongoProvider(IMongoConfiguration configuration)
        {
            Configuration = configuration;
            var connectionString = Configuration.ConnectionString;
            var dbName           = configuration.DatabaseName;

            Client    = new MongoClient(connectionString);
            _database = Client.GetDatabase(dbName);
        }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseInitialiser"/> class.
 /// </summary>
 /// <param name="mongoConfiguration">The MongoDB configuration settings.</param>
 /// <param name="installOptions">The database install options.</param>
 /// <param name="variables">A cache of install variables.</param>
 /// <param name="installLogger">Logs installation results.</param>
 public DatabaseInitialiser(IMongoConfiguration mongoConfiguration, DatabaseInitialiserOptions installOptions, InstallVariables variables, InstallLogger installLogger)
 {
     this.mongoConfiguration = mongoConfiguration;
     this.installConfiguration = installOptions;
     this.installVariables = variables;
     this.installLogger = installLogger;
     this.ReadInput = delegate { return string.Empty; };
     this.ReadPassword = delegate { return string.Empty; };
 }
コード例 #13
0
 public BaseService(IDistributedCache cache, IMongoConfiguration mongoConfig = null)
 {
     cacheDB = cache;
     if (mongoConfig != null)
     {
         _mongoConfig = mongoConfig;
         mongoClient  = new MongoClient(mongoConfig.ConnectionString);
         mongoDB      = mongoClient.GetDatabase(mongoConfig.DatabaseName);
     }
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoDataAccess" /> class.
 /// </summary>
 /// <param name="configuration">The configuration options.</param>
 public MongoDataAccess(IMongoConfiguration configuration)
 {
     this.Configuration = configuration;
     MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
     this.Server = client.GetServer();
     this.Database = this.Server.GetDatabase(configuration.Database);
     this.JsonSettings = new JsonWriterSettings
                         {
                             OutputMode = JsonOutputMode.Strict,
                             Indent = false,
                             NewLineChars = string.Empty
                         };
 }
コード例 #15
0
        public BoardService(IDistributedCache cache
                            , IMongoConfiguration mongoConfiguration
                            , IPlayerService playerService
                            , IHubContext <BoardHub> boardHub) : base(cache, mongoConfiguration)
        {
            _playerService    = playerService;
            _boardHub         = boardHub;
            _mapBoard         = new Dictionary <Guid, Board>();
            _mapPlayerInBoard = new Dictionary <Guid, Board>();

            _dicNewBoards = new Dictionary <Guid, Board>();
            _dicBoards    = new Dictionary <Guid, Board>();
        }
コード例 #16
0
        public MongoFactory(IMongoConfiguration mongoConfiguration)
        {
            _databaseName = mongoConfiguration.DatabaseName;

            var username = mongoConfiguration.Username;
            var password = mongoConfiguration.Password;
            var host = mongoConfiguration.Host;
            var port = mongoConfiguration.Port;

            var credentials = MongoCredential.CreateCredential(_databaseName, username, password);
            var settings = MongoHelpers.GetMongoClientSettings(host, port, credentials);

            _mongoClient = new MongoClient(settings);
        }
コード例 #17
0
        public MongoFactory(IMongoConfiguration mongoConfiguration)
        {
            _databaseName = mongoConfiguration.DatabaseName;

            var username = mongoConfiguration.Username;
            var password = mongoConfiguration.Password;
            var host     = mongoConfiguration.Host;
            var port     = mongoConfiguration.Port;

            var credentials = MongoCredential.CreateCredential(_databaseName, username, password);
            var settings    = MongoHelpers.GetMongoClientSettings(host, port, credentials);

            _mongoClient = new MongoClient(settings);
        }
コード例 #18
0
        /// <summary>
        /// Creates the client.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        /// <exception cref="NStruct.FatalException">
        /// Mongo host has not configured!
        /// or
        /// Database has not created!
        /// </exception>
        private IMongoClient CreateClient(IMongoConfiguration configuration)
        {
            if (string.IsNullOrEmpty(configuration.Host))
            {
                throw new FatalException("Mongo host has not configured!");
            }
            if (string.IsNullOrEmpty(configuration.Database))
            {
                throw new FatalException("Database has not created!");
            }

            var client = new MongoClient(MongoUrl.Create(configuration.Host));

            _mongoDatabase = client.GetDatabase(configuration.Database);

            return(client);
        }
コード例 #19
0
        public void SetUp()
        {
            // Arrange
            configurationFactory = Substitute.For <IMongoConfigurationFactory>();
            configuration        = Substitute.For <IMongoConfiguration>();
            client = Substitute.For <IMongoClient>();

            configurationFactory.Create().Returns(configuration);

            configuration.ConnectionString.Returns(MongoDbConnectionStringValue);
            configuration.DatabaseName.Returns(MongoDbDatabaseNameValue);

            var database = Substitute.For <IMongoDatabase>();

            client.GetDatabase(configuration.DatabaseName).Returns(database);

            databaseFactory = new MongoDatabaseFactory();
        }
コード例 #20
0
ファイル: MongoContext.cs プロジェクト: jdheywood/4um
        public MongoContext(IMongoConfigurationFactory configurationFactory,
                            IMongoClientFactory clientFactory,
                            IMongoDatabaseFactory databaseFactory,
                            IMongoCollectionFactory <Question> questionCollectionFactory,
                            IMongoCollectionFactory <Answer> answerCollectionFactory,
                            IMongoCollectionFactory <SearchTerm> searchTermCollectionFactory)
        {
            this.configurationFactory        = configurationFactory;
            this.clientFactory               = clientFactory;
            this.databaseFactory             = databaseFactory;
            this.questionCollectionFactory   = questionCollectionFactory;
            this.answerCollectionFactory     = answerCollectionFactory;
            this.searchTermCollectionFactory = searchTermCollectionFactory;

            configuration = configurationFactory.Create();
            var client = clientFactory.Create(configuration);

            database = databaseFactory.GetDatabase(configuration, client);

            EnforceTextIndexes();
        }
コード例 #21
0
 public MongoConnection(IMongoConfiguration configuration)
 {
     _configuration = configuration;
 }
コード例 #22
0
 public GameConfigService(IDistributedCache cache, IMongoConfiguration mongoConfig) : base(cache, mongoConfig)
 {
     LoadRankDefinition();
 }
コード例 #23
0
 public PositionReaderService(IMongoConfiguration mongoConfiguration)
 {
     _mongoConfiguration = mongoConfiguration;
 }
コード例 #24
0
 /// <summary>
 /// Gathering repository
 /// </summary>
 /// <param name="configuration"></param>
 public GatheringRepository(IMongoConfiguration configuration)
 {
     _mongoCollection = configuration.MongoDatabase.GetCollection <Gathering>(typeof(Gathering).Name);
 }
コード例 #25
0
 public IdempotenceWriterService(IMongoConfiguration mongoConfiguration)
 {
     _mongoConfiguration = mongoConfiguration;
 }
コード例 #26
0
 public IMongoDatabase GetDatabase(IMongoConfiguration configuration, IMongoClient client)
 {
     return(client.GetDatabase(configuration.DatabaseName));
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoDataAccess"/> class.
 /// </summary>
 /// <param name="configuration">The configuration options.</param>
 public MongoDataAccess(IMongoConfiguration configuration)
 {
     MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
     MongoServer server = client.GetServer();
     this.database = server.GetDatabase(configuration.Database);
 }
コード例 #28
0
        public OrderRepository(IMongoConfiguration mongoConfiguration, IMongoClient client)
        {
            var database = client.GetDatabase(mongoConfiguration.Database);

            _collection = database.GetCollection <Order>(mongoConfiguration.OrderCollection);
        }
コード例 #29
0
        public MongoContext(IMongoConfiguration mongoConfig)
        {
            var client = new MongoClient(mongoConfig.connectionString);

            _database = client.GetDatabase(mongoConfig.databaseName);
        }
コード例 #30
0
ファイル: PostRepository.cs プロジェクト: mastoj/NBlog
 //            : base(mongoConfiguration)
 public PostRepository(IMongoConfiguration mongoConfiguration)
 {
 }
コード例 #31
0
 public ReadDbContext(IMongoConfiguration mongoConfiguration)
     : base(mongoConfiguration)
 {
 }
コード例 #32
0
 public MongoDbContext(IMongoConfiguration configuration)
 {
     _mongoClient   = new MongoClient(configuration.ConnectionString);
     _mongoDatabase = _mongoClient.GetDatabase(configuration.DbName);
     Schools        = _mongoDatabase.GetCollection <School>(configuration.SchoolsCollectionName);
 }
コード例 #33
0
ファイル: MongoClientFactory.cs プロジェクト: jdheywood/4um
 public IMongoClient Create(IMongoConfiguration configuration)
 {
     return(new MongoClient(configuration.ConnectionString));
 }
コード例 #34
0
 protected MongoRepositoryTemplate(
     IMongoClientProvider mongoClientProvider,
     IMongoConfiguration mongoConfiguration)
     : base(mongoClientProvider, mongoConfiguration)
 {
 }
コード例 #35
0
 public TenantMongoRepository(
     IMongoClientProvider mongoClientProvider,
     IMongoConfiguration mongoConfiguration)
     : base(mongoClientProvider, mongoConfiguration)
 {
 }
コード例 #36
0
 public ContentTypeMongoRepository(
     IMongoClientProvider mongoClientProvider,
     IMongoConfiguration mongoConfiguration)
     : base(mongoClientProvider, mongoConfiguration)
 {
 }
コード例 #37
0
 protected MongoDbContext(IMongoConfiguration mongoConfiguration)
 {
     _mongoClient = new MongoClient(mongoConfiguration.GetConnectionString());
     _database    = _mongoClient.GetDatabase(mongoConfiguration.GetDatabaseName());
 }
コード例 #38
0
        public UserInfoDbContext(IMongoConfiguration configuration)
        {
            var client = new MongoClient(configuration.ConnectionString);

            _database = client.GetDatabase(MongoUrl.Create(configuration.ConnectionString).DatabaseName);
        }
コード例 #39
0
ファイル: UserRepository.cs プロジェクト: mastoj/NBlog
 // : base(mongoConfiguration)
 public UserRepository(IMongoConfiguration mongoConfiguration)
 {
 }