当前位置: 首页>>代码示例>>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;未经允许,请勿转载。