Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionMetadata"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="databaseName">Name of the database.</param>
 /// <param name="collectionName">The name.</param>
 /// <param name="connection">The connection.</param>
 internal CollectionMetadata(MongoConfiguration configuration, string databaseName, string collectionName, Connection connection)
 {
     //Todo: Add public constrcutors for users to call
     _fullName = databaseName + "." + collectionName;
     _name = collectionName;
     _database = new MongoDatabase(configuration, connection, databaseName);
 }
        /// <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;
        }
 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>
        /// Creates the configuration.
        /// </summary>
        /// <returns></returns>
        public MongoConfiguration CreateConfiguration()
        {
            var configuration = new MongoConfiguration();

            UpdateConfiguration(configuration);

            return configuration;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseMetadata"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="name">The name.</param>
 /// <param name="conn">The conn.</param>
 internal DatabaseMetadata(MongoConfiguration configuration, string name, Connection conn)
 {
     //Todo: add public constrcutor for users to call
     _configuration = configuration;
     _connection = conn;
     _name = name;
     _database = new MongoDatabase(_configuration, conn, name);
 }
Ejemplo n.º 6
0
        /// <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);
        }
 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>
        /// Updates the configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        public void UpdateConfiguration(MongoConfiguration configuration)
        {
            if(configuration == null)
                throw new ArgumentNullException("configuration");

            if(Connections!=null)
            {
                var connection = Connections.Cast<ConnectionElement>().FirstOrDefault(c=>c.IsDefault);
                if(connection != null)
                    configuration.ConnectionString = connection.ConnectionString;
            }

            configuration.ReadLocalTime = ReadLocalTime;
        }
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        public void UpdateConfiguration(MongoConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (Connections != null)
            {
                var connection = Connections.Cast <ConnectionElement>().FirstOrDefault(c => c.IsDefault);
                if (connection != null)
                {
                    configuration.ConnectionString = connection.ConnectionString;
                }
            }

            configuration.ReadLocalTime = ReadLocalTime;
        }
Ejemplo n.º 10
0
 public static MongoConfiguration GetConfiguration(String connectionString)
 {
     MongoConfiguration config = new MongoConfiguration();
     config.ConnectionString = connectionString;
     return config;
 }
 public void CanNotChangeSerializationFactoryAfterValidate()
 {
     var config = new MongoConfiguration();
     config.ValidateAndSeal();
     config.SerializationFactory = null;
 }
 public void CanNotChangeReadLocalTimeAfterValidate()
 {
     var config = new MongoConfiguration();
     config.ValidateAndSeal();
     config.ReadLocalTime = true;
 }
 public void CanNotChangeMappingStoreAfterValidate()
 {
     var config = new MongoConfiguration();
     config.ValidateAndSeal();
     config.MappingStore = null;
 }
 public void CanNotChangeConnectionStringAfterValidate()
 {
     var config = new MongoConfiguration();
     config.ValidateAndSeal();
     config.ConnectionString = "";
 }
 public void IsNotModifiableAfterValidate()
 {
     var config = new MongoConfiguration();
     config.ValidateAndSeal();
     Assert.IsFalse(config.IsModifiable);            
 }
Ejemplo n.º 16
0
 public void SetUp()
 {
     var configure = new MongoConfigurationBuilder();
     configure.ConnectionString("mongoserver");
     config = configure.BuildConfiguration();
 }
Ejemplo n.º 17
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "MongoCollection&lt;T&gt;" /> class.
 /// </summary>
 /// <param name = "configuration">The configuration.</param>
 /// <param name = "connection">The connection.</param>
 /// <param name = "databaseName">Name of the database.</param>
 /// <param name = "name">The name.</param>
 internal MongoCollection(MongoConfiguration configuration, Connection connection, string databaseName, string name)
 {
     //Todo: add public constrcutor for users to call
     _collection = new MongoCollection<Document>(configuration, connection, databaseName, name);
 }
Ejemplo n.º 18
0
 public MongoEventStore(string connectionString, ITypeCatalog typeCatalog)
 {
     var connectionStringBuilder = new MongoConnectionStringBuilder(connectionString);
     databaseName = connectionStringBuilder.Database;
     configuration = BuildMongoConfiguration(typeCatalog, connectionString);
 }
 public void IsModifiableByDefault()
 {
     var config = new MongoConfiguration();
     Assert.IsTrue(config.IsModifiable);
 }
Ejemplo n.º 20
0
 private SessionStore()
 {
     configure = new MongoConfigurationBuilder();
     configure.ConnectionStringAppSettingKey("mongoserver");
     config = configure.BuildConfiguration();
 }