Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     _database = database;
     _settings = settings.FrozenCopy();
     _chunks   = database[settings.ChunksCollectionName, settings.SafeMode];
     _files    = database[settings.FilesCollectionName, settings.SafeMode];
 }
Esempio n. 2
0
        public void ConstructorFeezesSettingsTest() {
            var settings = new MongoGridFSSettings();
            settings.IsFrozen.Should().Be.False();

            var gridFS = new MongoGridFS(Database, settings);
            gridFS.Settings.IsFrozen.Should().Be.True();
        }
 public void TestConstructorFeezesSettings()
 {
     var settings = new MongoGridFSSettings();
     Assert.IsFalse(settings.IsFrozen);
     var gridFS = new MongoGridFS(_database, settings);
     Assert.IsTrue(gridFS.Settings.IsFrozen);
 }
 public void TestCreateWithRemoteFileNameAndCreateOptions()
 {
     var aliases = new string[] { "a", "b" };
     var uploadDate = new DateTime(2011, 11, 10, 19, 57, 0, DateTimeKind.Utc);
     var metadata = new BsonDocument("x", 1);
     var createOptions = new MongoGridFSCreateOptions()
     {
         Aliases = aliases,
         ChunkSize = 123,
         ContentType = "content",
         Id = 1,
         Metadata = metadata,
         UploadDate = uploadDate
     };
     var settings = new MongoGridFSSettings();
     var info = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "filename", createOptions);
     Assert.IsTrue(aliases.SequenceEqual(info.Aliases));
     Assert.AreEqual(123, info.ChunkSize);
     Assert.AreEqual("content", info.ContentType);
     Assert.AreEqual(1, info.Id.AsInt32);
     Assert.AreEqual(0, info.Length);
     Assert.AreEqual(null, info.MD5);
     Assert.AreEqual(metadata, info.Metadata);
     Assert.AreEqual("filename", info.Name);
     Assert.AreEqual(uploadDate, info.UploadDate);
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     _database = database;
     _settings = settings.FrozenCopy();
     _chunks = database[settings.ChunksCollectionName, settings.SafeMode];
     _files = database[settings.FilesCollectionName, settings.SafeMode];
 }
Esempio n. 6
0
 /// <summary>
 ///     Create a MongoReaderPlugin with an existing MongoDatabase and specific settings for GridFS
 /// </summary>
 /// <param name="prefix">The virtual folder representing GridFS assets</param>
 /// <param name="db">An existing MongoDatabase instance</param>
 /// <param name="gridSettings">
 ///     Settings for the GridFS connection
 ///     <see href="http://api.mongodb.org/csharp/1.8/html/7a3abd48-0532-8e7f-3c05-6c9812eb06f8.htm" />
 /// </param>
 public MongoReaderPlugin(string prefix, MongoDatabase db, MongoGridFSSettings gridSettings)
 {
     _db = db;
     _gridSettings = gridSettings;
     _grid = _db.GetGridFS(gridSettings);
     VirtualFilesystemPrefix = prefix;
 }
        private static void PurgeOrphanedBlobs(HashSet<String> blobsToDelete, String connectionString, String format)
        {
            Console.WriteLine("Found {0} orphaned blobs in BlobStorage named {1}", blobsToDelete.Count, format);
            if (blobsToDelete.Count > 0)
            {
                Console.WriteLine("Press y if you want to delete them, any other key to list without deletion");
                var key = Console.ReadKey();
                Console.WriteLine();
                if (Char.ToLower(key.KeyChar) == 'y')
                {
                    var uri = new MongoUrl(ConfigurationManager.AppSettings[connectionString]);
                    var client = new MongoClient(uri);

                    var database = client.GetServer().GetDatabase(uri.DatabaseName);
                    var settings = new MongoGridFSSettings()
                    {
                        Root = format
                    };
                    var gridfs = database.GetGridFS(settings);
                    foreach (var blobToDelete in blobsToDelete)
                    {
                        gridfs.DeleteById(blobToDelete);
                        Console.WriteLine("Deleted {0} in database {1}", blobToDelete, ConfigurationManager.AppSettings[connectionString]);
                    }
                }
                else
                {
                    foreach (var blobToDelete in blobsToDelete)
                    {
                        Console.WriteLine("Blob {0} in database {1} is orphaned", blobToDelete, ConfigurationManager.AppSettings[connectionString]);
                    }
                }
            }

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoGridFSFileInfo"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="serverInstance">The server instance.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="gridFSSettings">The GridFS settings.</param>
        /// <param name="remoteFileName">The remote file name.</param>
        /// <param name="createOptions">The create options.</param>
        public MongoGridFSFileInfo(
            MongoServer server,
            MongoServerInstance serverInstance,
            string databaseName,
            MongoGridFSSettings gridFSSettings,
            string remoteFileName,
            MongoGridFSCreateOptions createOptions)
            : this(server, serverInstance, databaseName, gridFSSettings)
        {
            if (remoteFileName == null)
            {
                throw new ArgumentNullException("remoteFileName");
            }
            if (createOptions == null)
            {
                throw new ArgumentNullException("createOptions");
            }

            _aliases     = createOptions.Aliases;
            _chunkSize   = (createOptions.ChunkSize == 0) ? gridFSSettings.ChunkSize : createOptions.ChunkSize;
            _contentType = createOptions.ContentType;
            _id          = createOptions.Id;
            _metadata    = createOptions.Metadata;
            _name        = remoteFileName;
            _uploadDate  = createOptions.UploadDate;
            _cached      = true; // prevent values from being overwritten by automatic Refresh
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     _database = database;
     _settings = settings.FrozenCopy();
     _chunks   = database.GetCollection(settings.ChunksCollectionName);
     _files    = database.GetCollection(settings.FilesCollectionName);
 }
        public void TestEquals()
        {
            var a = new MongoGridFSSettings(123, "root", SafeMode.True);
            var b = new MongoGridFSSettings(123, "root", SafeMode.True);;
            var c = new MongoGridFSSettings(345, "root", SafeMode.True);
            var n = (SafeMode) null;

            Assert.IsTrue(object.Equals(a, b));
            Assert.IsFalse(object.Equals(a, c));
            Assert.IsFalse(a.Equals(n));
            Assert.IsFalse(a.Equals(null));

            Assert.IsTrue(a == b);
            Assert.IsFalse(a == c);
            Assert.IsFalse(a == null);
            Assert.IsFalse(null == a);
            Assert.IsTrue(n == null);
            Assert.IsTrue(null == n);

            Assert.IsFalse(a != b);
            Assert.IsTrue(a != c);
            Assert.IsTrue(a != null);
            Assert.IsTrue(null != a);
            Assert.IsFalse(n != null);
            Assert.IsFalse(null != n);
        }
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     _database = database;
     _settings = settings.FrozenCopy();
     _chunks = database.GetCollection(settings.ChunksCollectionName);
     _files = database.GetCollection(settings.FilesCollectionName);
 }
Esempio n. 12
0
 public void TestConstructorFreezesSettings()
 {
     var settings = new MongoGridFSSettings();
     Assert.False(settings.IsFrozen);
     var gridFS = new MongoGridFS(_server, _database.Name, settings);
     Assert.True(gridFS.Settings.IsFrozen);
 }
 public void TestAppendTextWithSecondaryReadPreference()
 {
     _gridFS.Delete(Query.Null);
     Assert.IsFalse(_gridFS.Exists("HelloWorld.txt"));
     var settings = new MongoGridFSSettings() { ReadPreference = ReadPreference.Secondary };
     var gridFS = _database.GetGridFS(settings);
     using (var writer = gridFS.AppendText("HelloWorld.txt"))
     {
         Assert.IsFalse(writer.BaseStream.CanRead);
         Assert.IsTrue(writer.BaseStream.CanSeek);
         Assert.IsTrue(writer.BaseStream.CanWrite);
         writer.Write("Hello");
     }
     Assert.IsTrue(_gridFS.Exists("HelloWorld.txt"));
     using (var writer = gridFS.AppendText("HelloWorld.txt"))
     {
         writer.Write(" World");
     }
     var memoryStream = new MemoryStream();
     _gridFS.Download(memoryStream, "HelloWorld.txt");
     var bytes = memoryStream.ToArray();
     Assert.AreEqual(0xEF, bytes[0]); // the BOM
     Assert.AreEqual(0xBB, bytes[1]);
     Assert.AreEqual(0xBF, bytes[2]);
     var text = Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3);
     Assert.AreEqual("Hello World", text);
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     this.database = database;
     this.settings = settings.FrozenCopy();
     this.chunks   = database[settings.ChunksCollectionName, settings.SafeMode];
     this.files    = database[settings.FilesCollectionName, settings.SafeMode];
 }
 /// <summary>
 /// Initializes a new instance of the MongoGridFS class.
 /// </summary>
 /// <param name="database">The database containing the GridFS collections.</param>
 /// <param name="settings">The GridFS settings.</param>
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
 {
     this.database = database;
     this.settings = settings.FrozenCopy();
     this.chunks = database[settings.ChunksCollectionName, settings.SafeMode];
     this.files = database[settings.FilesCollectionName, settings.SafeMode];
 }
        public void TestEquals()
        {
            var settings = new MongoGridFSSettings();
            var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 };
            var a1 = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "f", createOptions);
            var a2 = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "f", createOptions);
            var a3 = a2;
            var b = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "g", createOptions);
            var null1 = (MongoGridFSFileInfo)null;
            var null2 = (MongoGridFSFileInfo)null;

            Assert.AreNotSame(a1, a2);
            Assert.AreSame(a2, a3);
            Assert.IsTrue(a1.Equals((object)a2));
            Assert.IsFalse(a1.Equals((object)null));
            Assert.IsFalse(a1.Equals((object)"x"));

            Assert.IsTrue(a1 == a2);
            Assert.IsTrue(a2 == a3);
            Assert.IsFalse(a1 == b);
            Assert.IsFalse(a1 == null1);
            Assert.IsFalse(null1 == a1);
            Assert.IsTrue(null1 == null2);

            Assert.IsFalse(a1 != a2);
            Assert.IsFalse(a2 != a3);
            Assert.IsTrue(a1 != b);
            Assert.IsTrue(a1 != null1);
            Assert.IsTrue(null1 != a1);
            Assert.IsFalse(null1 != null2);

            Assert.AreEqual(a1.GetHashCode(), a2.GetHashCode());
        }
 public void TestFixtureSetup() {
     server = MongoServer.Create("mongodb://localhost/?safe=true");
     database = server["onlinetests"];
     var settings = new MongoGridFSSettings {
         ChunkSize = 16,
         SafeMode = SafeMode.True
     };
     gridFS = database.GetGridFS(settings);
 }
Esempio n. 18
0
        public MongoReaderPlugin(NameValueCollection args)
        {
            VirtualFilesystemPrefix = string.IsNullOrEmpty(args["prefix"]) ? "~/gridfs/" : args["prefix"];

            string connectionString = args["connectionString"];
            this.db = MongoDatabase.Create(connectionString);
            gridSettings = new MongoGridFSSettings();
            grid = db.GetGridFS(gridSettings);
        }
 public void TestDefaults()
 {
     var settings = new MongoGridFSSettings(_database);
     Assert.IsFalse(settings.IsFrozen);
     Assert.AreEqual("fs.chunks", settings.ChunksCollectionName);
     Assert.AreEqual(256 * 1024, settings.ChunkSize);
     Assert.AreEqual("fs.files", settings.FilesCollectionName);
     Assert.AreEqual("fs", settings.Root);
     Assert.AreEqual(WriteConcern.Errors, settings.WriteConcern);
 }
        public void TestDefaultsObsolete()
        {
#pragma warning disable 618
            var settings = new MongoGridFSSettings();
            Assert.IsFalse(settings.IsFrozen);
            Assert.AreEqual(0, settings.ChunkSize);
            Assert.AreEqual(null, settings.Root);
            Assert.AreEqual(null, settings.WriteConcern);
#pragma warning restore
        }
 public void TestDefaults()
 {
     var settings = new MongoGridFSSettings();
     Assert.IsFalse(settings.IsFrozen);
     Assert.AreEqual("fs.chunks", settings.ChunksCollectionName);
     Assert.AreEqual(256 * 1024, settings.DefaultChunkSize);
     Assert.AreEqual("fs.files", settings.FilesCollectionName);
     Assert.AreEqual("fs", settings.Root);
     Assert.AreEqual(SafeMode.False, settings.SafeMode);
 }
Esempio n. 22
0
 public MongoGridFSStreamTests()
 {
     _database = LegacyTestConfiguration.Database;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Acknowledged
     };
     _gridFS = _database.GetGridFS(settings);
 }
 public void TestCreationEmpty()
 {
     var settings = new MongoGridFSSettings();
     Assert.AreEqual(0, settings.ChunkSize);
     Assert.AreEqual(null, settings.Root);
     Assert.AreEqual(false, settings.UpdateMD5);
     Assert.AreEqual(false, settings.VerifyMD5);
     Assert.AreEqual(false, settings.IsFrozen);
     Assert.AreEqual(null, settings.WriteConcern);
 }
Esempio n. 24
0
        protected override void OnTestFixtureSetUp() {
            base.OnTestFixtureSetUp();

            var settings = new MongoGridFSSettings
                           {
                               ChunkSize = 16,
                               SafeMode = SafeMode.True
                           };
            gridFS = Database.GetGridFS(settings);
        }
Esempio n. 25
0
        /// <summary>
        /// Initializes a new instance of the MongoGridFS class.
        /// </summary>
        /// <param name="database">The database containing the GridFS collections.</param>
        /// <param name="settings">The GridFS settings.</param>
        public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
        {
            settings = settings.Clone();
            settings.ApplyDefaultValues(database.Settings);
            settings.Freeze();

            _database = database;
            _settings = settings;
            _chunks = database.GetCollection(settings.Root + ".chunks");
            _files = database.GetCollection(settings.Root + ".files");
        }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new instance of the MongoGridFS class.
        /// </summary>
        /// <param name="database">The database containing the GridFS collections.</param>
        /// <param name="settings">The GridFS settings.</param>
        public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
        {
            settings = settings.Clone();
            settings.ApplyDefaultValues(database.Settings);
            settings.Freeze();

            _database = database;
            _settings = settings;
            _chunks   = database.GetCollection(settings.Root + ".chunks");
            _files    = database.GetCollection(settings.Root + ".files");
        }
 public void TestCloneAndEquals()
 {
     var settings = new MongoGridFSSettings {
         DefaultChunkSize = 64 * 1024,
         Root = "root",
         SafeMode = SafeMode.True
     };
     var clone = settings.Clone();
     Assert.IsTrue(settings == clone);
     Assert.AreEqual(settings, clone);
 }
 public void TestFixtureSetup()
 {
     _server = Configuration.TestServer;
     _database = Configuration.TestDatabase;
     var settings = new MongoGridFSSettings(_database)
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Errors
     };
     _gridFS = _database.GetGridFS(settings);
 }
 public void TestFixtureSetup()
 {
     _server = Configuration.TestServer;
     _database = Configuration.TestDatabase;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         SafeMode = SafeMode.True
     };
     _gridFS = _database.GetGridFS(settings);
 }
 // constructors
 public MongoGridFSFileInfoSerializer(
     MongoServer server,
     MongoServerInstance serverInstance,
     string databaseName,
     MongoGridFSSettings gridFSSettings)
 {
     _server         = server;
     _serverInstance = serverInstance;
     _databaseName   = databaseName;
     _gridFSSettings = gridFSSettings;
 }
        public void TestDefaultsObsolete()
        {
#pragma warning disable 618
            var settings = new MongoGridFSSettings(_database);
            Assert.IsFalse(settings.IsFrozen);
            Assert.AreEqual("fs.chunks", settings.ChunksCollectionName);
            Assert.AreEqual(256 * 1024, settings.ChunkSize);
            Assert.AreEqual("fs.files", settings.FilesCollectionName);
            Assert.AreEqual("fs", settings.Root);
            Assert.AreEqual(WriteConcern.Acknowledged, settings.WriteConcern);
#pragma warning restore
        }
 public void TestFreeze()
 {
     var settings = new MongoGridFSSettings();
     Assert.IsFalse(settings.IsFrozen);
     settings.Freeze();
     Assert.IsTrue(settings.IsFrozen);
     settings.Freeze(); // test that it's OK to call Freeze more than once
     Assert.IsTrue(settings.IsFrozen);
     Assert.Throws<InvalidOperationException>(() => settings.DefaultChunkSize = 64 * 1024);
     Assert.Throws<InvalidOperationException>(() => settings.Root = "root");
     Assert.Throws<InvalidOperationException>(() => settings.SafeMode = SafeMode.True);
 }
Esempio n. 33
0
        /// <summary>
        ///     Create a MongoReaderPlugin from plug-in arguments
        /// </summary>
        /// <param name="args"></param>
        public MongoReaderPlugin(NameValueCollection args)
        {
            VirtualFilesystemPrefix = string.IsNullOrEmpty(args["prefix"]) ? "~/gridfs/" : args["prefix"];

            var mongoUrl = new MongoUrl(args["connectionString"]);

            // Using new client, server database initialization. Wordy but recommended.
            var mongoClient = new MongoClient(mongoUrl);
            var mongoServer = mongoClient.GetServer();
            _db = mongoServer.GetDatabase(mongoUrl.DatabaseName);
            _gridSettings = new MongoGridFSSettings();
            _grid = _db.GetGridFS(_gridSettings);
        }
 public void TestCloneAndEquals()
 {
     var settings = new MongoGridFSSettings(_database)
     {
         ChunkSize = 64 * 1024,
         Root = "root",
         SafeMode = SafeMode.True,
         UpdateMD5 = false,
         VerifyMD5 = false
     };
     var clone = settings.Clone();
     Assert.IsTrue(settings == clone);
     Assert.AreEqual(settings, clone);
 }
 public void TestCloneAndEquals()
 {
     var settings = new MongoGridFSSettings(_database)
     {
         ChunkSize = 64 * 1024,
         Root = "root",
         UpdateMD5 = false,
         VerifyMD5 = false,
         WriteConcern = WriteConcern.Errors
     };
     var clone = settings.Clone();
     Assert.IsTrue(settings == clone);
     Assert.AreEqual(settings, clone);
 }
 public void TestCreation()
 {
     var settings = new MongoGridFSSettings {
         DefaultChunkSize = 64 * 1024,
         Root = "root",
         SafeMode = SafeMode.True
     };
     Assert.IsFalse(settings.IsFrozen);
     Assert.AreEqual("root.chunks", settings.ChunksCollectionName);
     Assert.AreEqual(64 * 1024, settings.DefaultChunkSize);
     Assert.AreEqual("root.files", settings.FilesCollectionName);
     Assert.AreEqual("root", settings.Root);
     Assert.AreEqual(SafeMode.True, settings.SafeMode);
 }
        // private static methods
        private static MongoGridFSSettings ApplyDefaultValues(MongoGridFSSettings settings, MongoDatabase database)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }

            settings = settings.Clone();
            settings.ApplyDefaultValues(database.Settings);
            return(settings);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoGridFSFileInfo"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="serverInstance">The server instance.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="gridFSSettings">The GridFS settings.</param>
        /// <param name="fileInfo">The fileInfo.</param>
        public MongoGridFSFileInfo(
            MongoServer server,
            MongoServerInstance serverInstance,
            string databaseName,
            MongoGridFSSettings gridFSSettings,
            BsonDocument fileInfo)
            : this(server, serverInstance, databaseName, gridFSSettings)
        {
            if (fileInfo == null)
            {
                throw new ArgumentNullException("fileInfo");
            }

            _chunkSize = gridFSSettings.ChunkSize;
            CacheFileInfo(fileInfo);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoGridFSFileInfo"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="serverInstance">The server instance.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="gridFSSettings">The GridFS settings.</param>
        /// <param name="remoteFileName">The remote file name.</param>
        public MongoGridFSFileInfo(
            MongoServer server,
            MongoServerInstance serverInstance,
            string databaseName,
            MongoGridFSSettings gridFSSettings,
            string remoteFileName)
            : this(server, serverInstance, databaseName, gridFSSettings)
        {
            if (remoteFileName == null)
            {
                throw new ArgumentNullException("remoteFileName");
            }

            _chunkSize = gridFSSettings.ChunkSize;
            _name      = remoteFileName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoGridFS"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="databaseName">The name of the database.</param>
        /// <param name="settings">The settings.</param>
        public MongoGridFS(MongoServer server, string databaseName, MongoGridFSSettings settings)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (databaseName == null)
            {
                throw new ArgumentNullException("databaseName");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            settings = settings.Clone();
            settings.ApplyDefaultValues(server.Settings);
            settings.Freeze();

            _server       = server;
            _databaseName = databaseName;
            _settings     = settings;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoGridFSFileInfo"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="serverInstance">The server instance.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="gridFSSettings">The GridFS settings.</param>
        private MongoGridFSFileInfo(
            MongoServer server,
            MongoServerInstance serverInstance,
            string databaseName,
            MongoGridFSSettings gridFSSettings)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (databaseName == null)
            {
                throw new ArgumentNullException("databaseName");
            }
            if (gridFSSettings == null)
            {
                throw new ArgumentNullException("gridFSSettings");
            }

            _server         = server;
            _serverInstance = serverInstance;
            _databaseName   = databaseName;
            _settings       = gridFSSettings;
        }
 public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
     : this(GetServer(database), GetDatabaseName(database), ApplyDefaultValues(settings, database))
 {
 }