當前位置: 首頁>>代碼示例>>C#>>正文


C# GridFS.MongoGridFSSettings類代碼示例

本文整理匯總了C#中MongoDB.Driver.GridFS.MongoGridFSSettings的典型用法代碼示例。如果您正苦於以下問題:C# MongoGridFSSettings類的具體用法?C# MongoGridFSSettings怎麽用?C# MongoGridFSSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MongoGridFSSettings類屬於MongoDB.Driver.GridFS命名空間,在下文中一共展示了MongoGridFSSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestEquals

        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);
        }
開發者ID:vshlos,項目名稱:mongo-csharp-driver,代碼行數:26,代碼來源:MongoGridFSSettingsTests.cs

示例2: ConstructorFeezesSettingsTest

        public void ConstructorFeezesSettingsTest() {
            var settings = new MongoGridFSSettings();
            settings.IsFrozen.Should().Be.False();

            var gridFS = new MongoGridFS(Database, settings);
            gridFS.Settings.IsFrozen.Should().Be.True();
        }
開發者ID:debop,項目名稱:NFramework,代碼行數:7,代碼來源:MongoGridFSFixture.cs

示例3: TestAppendTextWithSecondaryReadPreference

 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);
 }
開發者ID:GGsus,項目名稱:mongo-csharp-driver,代碼行數:27,代碼來源:MongoGridFSTests.cs

示例4: PurgeOrphanedBlobs

        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]);
                    }
                }
            }

        }
開發者ID:ProximoSrl,項目名稱:Jarvis.DocumentStore,代碼行數:35,代碼來源:CheckOrphanedBlobs.cs

示例5: MongoReaderPlugin

 /// <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;
 }
開發者ID:eakova,項目名稱:resizer,代碼行數:16,代碼來源:MongoReaderPlugin.cs

示例6: TestCreateWithRemoteFileNameAndCreateOptions

 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);
 }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:26,代碼來源:MongoGridFSFileInfoTests.cs

示例7: TestConstructorFreezesSettings

 public void TestConstructorFreezesSettings()
 {
     var settings = new MongoGridFSSettings();
     Assert.False(settings.IsFrozen);
     var gridFS = new MongoGridFS(_server, _database.Name, settings);
     Assert.True(gridFS.Settings.IsFrozen);
 }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:7,代碼來源:MongoGridFSTests.cs

示例8: MongoGridFS

 /// <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];
 }
開發者ID:abel,項目名稱:sinan,代碼行數:12,代碼來源:MongoGridFS.cs

示例9: MongoGridFS

 /// <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);
 }
開發者ID:staywellandy,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:MongoGridFS.cs

示例10: TestEquals

        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());
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:33,代碼來源:MongoGridFSFileInfoTests.cs

示例11: MongoGridFS

 /// <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];
 }
開發者ID:FelicePollano,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:MongoGridFS.cs

示例12: TestConstructorFeezesSettings

 public void TestConstructorFeezesSettings()
 {
     var settings = new MongoGridFSSettings();
     Assert.IsFalse(settings.IsFrozen);
     var gridFS = new MongoGridFS(_database, settings);
     Assert.IsTrue(gridFS.Settings.IsFrozen);
 }
開發者ID:robinNode,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:MongoGridFSTests.cs

示例13: TestFixtureSetup

 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);
 }
開發者ID:simi--,項目名稱:mongo-csharp-driver,代碼行數:9,代碼來源:MongoGridFSStreamTests.cs

示例14: MongoGridFSStreamTests

 public MongoGridFSStreamTests()
 {
     _database = LegacyTestConfiguration.Database;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Acknowledged
     };
     _gridFS = _database.GetGridFS(settings);
 }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:10,代碼來源:MongoGridFSStreamTests.cs

示例15: TestDefaults

 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);
 }
開發者ID:subbuballa,項目名稱:mongo-csharp-driver,代碼行數:10,代碼來源:MongoGridFSSettingsTests.cs


注:本文中的MongoDB.Driver.GridFS.MongoGridFSSettings類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。