public static IDependencyResolver UseMongo(this IDependencyResolver resolver, MongoConfiguration config) { var bus = new Lazy<MongoMessageBus>(() => new MongoMessageBus(config, resolver)); resolver.Register(typeof(IMessageBus), () => bus.Value); return resolver; }
/// <summary> /// Initializes the <see cref="ProfileLevelResponse"/> class. /// </summary> static ProfileLevelResponse() { MongoConfiguration.Initialize(c => c.For <ProfileLevelResponse>(a => { a.ForProperty(p => p.PreviousLevel).UseAlias("was"); a.ForProperty(p => p.SlowOpThreshold).UseAlias("slowms"); })); }
/// <summary> /// Construct MongoCRUD with connection string and databasse name /// </summary> /// <param name="connectionString"></param> /// <param name="database"></param> public MongoCRUD(string connectionString, string database) { this.Configuration = new MongoConfiguration { ConnectionString = connectionString, Database = database }; }
public void Mongo_Configuration_Returns_Null_For_Uninitialized_Type_Connection_Strings() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(user => user.FirstName).UseAlias("thisIsntDying"))); var connection = MongoConfiguration.GetConnectionString(typeof(TestProduct)); Assert.Equal(null, connection); }
public void Mongo_Configuration_Should_AutoMap_Id_Property() { Assert.Equal("_id", MongoConfiguration.GetPropertyAlias(typeof(IdMap0), "_ID")); Assert.Equal("_id", MongoConfiguration.GetPropertyAlias(typeof(IdMap1), "TheID")); Assert.Equal("_id", MongoConfiguration.GetPropertyAlias(typeof(IdMap2), "ID")); Assert.Equal("_id", MongoConfiguration.GetPropertyAlias(typeof(IdMap3), "id")); Assert.Equal("_id", MongoConfiguration.GetPropertyAlias(typeof(IdMap4), "Id")); }
public LinqAggregates() { MongoConfiguration.RemoveMapFor <TestProduct>(); using (var session = new Session()) { session.Drop <TestProduct>(); } }
/// <summary> /// Initializes static members of the <see cref="DbReference{T,TId}"/> class. /// </summary> static DbReference() { MongoConfiguration.Initialize(c => c.For <DbReference <T> >(dbr => { dbr.ForProperty(d => d.Collection).UseAlias("$ref"); dbr.ForProperty(d => d.DatabaseName).UseAlias("$db"); dbr.ForProperty(d => d.Id).UseAlias("$id"); })); }
public void CanUpdateConfigurationFromSection() { var section = ReadFromFile(1); var config = new MongoConfiguration(); Assert.IsEmpty(config.ConnectionString); section.UpdateConfiguration(config); Assert.AreEqual("Server=localhost:27017", config.ConnectionString); }
/// <summary> /// Initializes the <see cref="BuildInfoResponse"/> class. /// </summary> static BuildInfoResponse() { MongoConfiguration.Initialize(c => c.For <BuildInfoResponse>(a => { a.ForProperty(auth => auth.Version).UseAlias("version"); a.ForProperty(auth => auth.GitVersion).UseAlias("gitVersion"); a.ForProperty(auth => auth.SystemInformation).UseAlias("sysInfo"); })); }
static void Main(string[] args) { MongoConfiguration.Initialize(); var autofac = (IComponentContext) new ContainerModule().GetBuilder().Build(); var schedulerService = autofac.Resolve <SchedulerService>(); schedulerService.RunScheduledTasks(); }
/// <summary> /// Initializes a new instance of the <see cref="SerializationFactory"/> class. /// </summary> /// <param name="configuration">The mongo configuration.</param> public SerializationFactory(MongoConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _configuration = configuration; }
static SuperClassObjectFluentMapped() { MongoConfiguration.Initialize(config => config.For <SuperClassObjectFluentMapped>(c => { c.ForProperty(u => u.Id).UseAlias("_id"); c.ForProperty(u => u.Title).UseAlias("t"); })); }
public void Drop <T>() { try { _provider.Database.DropCollection(MongoConfiguration.GetCollectionName(typeof(T))); } catch (MongoException) { } }
protected override void ConfigureTransportAndPersistence(IBusConfigurator cfg) { var mongoCfg = new MongoConfiguration(_fixture.ConnectionString, _fixture.DbName, MongoSagaStateRepositoryOptions.Default, MongoOutboxRepositoryOptions.Default); cfg.UseInMemoryTransport() .UseMongoPersistence(mongoCfg); }
public MongoContext(string conn, string db) { var client = new MongoClient(conn); if (client != null) { _database = client.GetDatabase(db); } MongoConfiguration.EfetuarConfiguracao(); }
public static ILoggerFactory AddMongoDb(this ILoggerFactory factory, Func <string, LogLevel, bool> filter, MongoConfiguration configuration, IHostingEnvironment hostingEnvironment) { ILoggerProvider provider = new MongoLoggerProvider(filter, configuration, hostingEnvironment.ApplicationName, hostingEnvironment.EnvironmentName); factory.AddProvider(provider); return(factory); }
public void Mongo_Configuration_Can_Remove_Mapping() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(h => h.LastName).UseAlias("lName"))); //confirm that mapping was set. Assert.Equal("lName", MongoConfiguration.GetPropertyAlias(typeof(User), "LastName")); MongoConfiguration.RemoveMapFor <User>(); //confirm that mapping was unset. Assert.Equal("LastName", MongoConfiguration.GetPropertyAlias(typeof(User), "LastName")); }
/// <summary> /// Initializes the <see cref="ExplainPlan"/> class. /// </summary> static ExplainPlan() { MongoConfiguration.Initialize(c => c.For <ExplainPlan>(a => { a.ForProperty(auth => auth.Cursor).UseAlias("cursor"); a.ForProperty(auth => auth.StartKey).UseAlias("startKey"); a.ForProperty(auth => auth.IndexBounds).UseAlias("indexBounds"); }) ); }
public static ILoggerFactory AddMongoDb(this ILoggerFactory factory, MongoConfiguration configuration, IHostingEnvironment hostingEnvironment) { ILoggerProvider provider = new MongoLoggerProvider((n, l) => l >= configuration.MinLevel, configuration, hostingEnvironment.ApplicationName, hostingEnvironment.EnvironmentName); factory.AddProvider(provider); return(factory); }
static LastErrorResponse() { MongoConfiguration.Initialize(c => c.For <LastErrorResponse>(a => { a.ForProperty(auth => auth.NumberOfErrors).UseAlias("n"); a.ForProperty(auth => auth.Error).UseAlias("err"); a.ForProperty(auth => auth.Code).UseAlias("code"); }) ); }
/// <summary> /// Initializes the <see cref="PreviousErrorResponse"/> class. /// </summary> static PreviousErrorResponse() { MongoConfiguration.Initialize(c => c.For <PreviousErrorResponse>(a => { a.ForProperty(auth => auth.NumberOfErrors).UseAlias("n"); a.ForProperty(auth => auth.Error).UseAlias("err"); a.ForProperty(auth => auth.NumberOfOperationsAgo).UseAlias("nPrev"); }) ); }
public MongoContext(IOptions <MongoConfiguration> mongoConfiguration, MongoCollectionNamesProvider mongoCollectionNamesProvider) { _mongoDbConfiguration = mongoConfiguration.Value; _mongoCollectionNamesProvider = mongoCollectionNamesProvider; _collectionSettings = new MongoCollectionSettings(); var client = new MongoClient(_mongoDbConfiguration.ServerAddress); _database = client.GetDatabase(_mongoDbConfiguration.DatabaseName); }
/// <summary> /// Initializes the <see cref="DeleteIndicesResponse"/> class. /// </summary> static DeleteIndicesResponse() { MongoConfiguration.Initialize(c => c.For <DeleteIndicesResponse>(a => { a.ForProperty(auth => auth.NumberIndexesWas).UseAlias("nIndexesWas"); a.ForProperty(auth => auth.Message).UseAlias("msg"); a.ForProperty(auth => auth.Namespace).UseAlias("ns "); }) ); }
public LinqDeepGraph() { MongoConfiguration.RemoveMapFor <TestProduct>(); MongoConfiguration.RemoveMapFor <Supplier>(); MongoConfiguration.RemoveMapFor <InventoryChange>(); MongoConfiguration.RemoveMapFor <Address>(); using (var session = new Session()) { session.Drop <TestProduct>(); } }
public void Mongo_Configuration_Echos_Unmapped_Property_Names() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(user => user.FirstName) .UseAlias("first")) /*.WithProfileNamed("Sample")*/); var first = MongoConfiguration.GetPropertyAlias(typeof(User), "FirstName"); var last = MongoConfiguration.GetPropertyAlias(typeof(User), "LastName"); Assert.Equal("first", first); Assert.Equal("LastName", last); }
public void Collection_Creates_Complex_Index() { using (var db = Mongo.Create(TestHelper.ConnectionString())) { MongoConfiguration.Initialize(j => j.For <TestProduct>(k => k.ForProperty(x => x.Inventory).UseAlias("inv"))); var prods = db.GetCollection <TestProduct>(); prods.CreateIndex(j => new { j.Available, j.Inventory.Count }, "complexIndex", true, IndexOption.Ascending); } }
public void SetUp() { var configure = new MongoConfigurationBuilder(); configure.ConnectionStringAppSettingKey("mongoserver"); config = configure.BuildConfiguration(); SessionStateItemCollection sessionItemsCollection = new SessionStateItemCollection(); HttpStaticObjectsCollection staticObjectsCollection = new HttpStaticObjectsCollection(); item = new SessionStateStoreData(sessionItemsCollection, staticObjectsCollection, 1); }
/// <summary> /// Initializes the <see cref="AuthenticationRequest"/> class. /// </summary> static AuthenticationRequest() { MongoConfiguration.Initialize(c => c.For <AuthenticationRequest>(a => { a.ForProperty(auth => auth.Authenticate).UseAlias("authenticate"); a.ForProperty(auth => auth.Nonce).UseAlias("nonce"); a.ForProperty(auth => auth.User).UseAlias("user"); a.ForProperty(auth => auth.Key).UseAlias("key"); }) ); }
static CurrentOperationResponse() { MongoConfiguration.Initialize(c => c.For <CurrentOperationResponse>(a => { a.ForProperty(op => op.OperationId).UseAlias("opid"); a.ForProperty(op => op.Operation).UseAlias("op"); a.ForProperty(op => op.Namespace).UseAlias("ns"); a.ForProperty(op => op.SecondsRunning).UseAlias("secs_running"); a.ForProperty(op => op.Description).UseAlias("desc"); }) ); }
static MongoIndex() { MongoConfiguration.Initialize(c => c.For <MongoIndex>(a => { a.ForProperty(auth => auth.Key).UseAlias("key"); a.ForProperty(auth => auth.Namespace).UseAlias("ns"); a.ForProperty(auth => auth.Unique).UseAlias("unique"); a.ForProperty(auth => auth.Name).UseAlias("name"); }) ); }
/// <summary> /// Initializes a new instance of the <see cref = "Mongo" /> class. /// </summary> /// <param name = "configuration">The mongo configuration.</param> public Mongo(MongoConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } configuration.ValidateAndSeal(); _configuration = configuration; _connection = ConnectionFactoryFactory.GetConnection(configuration.ConnectionString); }