当前位置: 首页>>代码示例>>C#>>正文


C# GridFS.MongoGridFSFileInfo类代码示例

本文整理汇总了C#中MongoDB.Driver.GridFS.MongoGridFSFileInfo的典型用法代码示例。如果您正苦于以下问题:C# MongoGridFSFileInfo类的具体用法?C# MongoGridFSFileInfo怎么用?C# MongoGridFSFileInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MongoGridFSFileInfo类属于MongoDB.Driver.GridFS命名空间,在下文中一共展示了MongoGridFSFileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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 info = new MongoGridFSFileInfo(_gridFS, "filename", createOptions);
     Assert.IsTrue(aliases.SequenceEqual(info.Aliases));
     Assert.AreEqual(123, info.ChunkSize);
     Assert.AreEqual("content", info.ContentType);
     Assert.AreEqual(_gridFS, info.GridFS);
     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:robinNode,项目名称:mongo-csharp-driver,代码行数:26,代码来源:MongoGridFSFileInfoTests.cs

示例2: TestEquals

        public void TestEquals()
        {
            var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 };
            var a1 = new MongoGridFSFileInfo(_gridFS, "f", createOptions);
            var a2 = new MongoGridFSFileInfo(_gridFS, "f", createOptions);
            var a3 = a2;
            var b = new MongoGridFSFileInfo(_gridFS, "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:robinNode,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoGridFSFileInfoTests.cs

示例3: TestEquals

        public void TestEquals()
        {
            var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 };
            var a = new MongoGridFSFileInfo(gridFS, "f", createOptions);
            var b = new MongoGridFSFileInfo(gridFS, "f", createOptions);
            var c = new MongoGridFSFileInfo(gridFS, "g", createOptions);
            var n = (MongoCredentials) 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,代码行数:27,代码来源:MongoGridFSFileInfoTests.cs

示例4: MongoGridFSStream

 public MongoGridFSStream(
     MongoGridFSFileInfo fileInfo,
     FileMode mode
 )
     : this(fileInfo, mode, FileAccess.ReadWrite)
 {
 }
开发者ID:kolupaev,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoGridFSStream.cs

示例5: 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.NotSame(a1, a2);
            Assert.Same(a2, a3);
            Assert.True(a1.Equals((object)a2));
            Assert.False(a1.Equals((object)null));
            Assert.False(a1.Equals((object)"x"));

            Assert.True(a1 == a2);
            Assert.True(a2 == a3);
            Assert.False(a1 == b);
            Assert.False(a1 == null1);
            Assert.False(null1 == a1);
            Assert.True(null1 == null2);

            Assert.False(a1 != a2);
            Assert.False(a2 != a3);
            Assert.True(a1 != b);
            Assert.True(a1 != null1);
            Assert.True(null1 != a1);
            Assert.False(null1 != null2);

            Assert.Equal(a1.GetHashCode(), a2.GetHashCode());
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:33,代码来源:MongoGridFSFileInfoTests.cs

示例6: MongoStorageFile

        internal MongoStorageFile(MongoGridFSFileInfo fileInfo )
        {
            if (fileInfo == null)
                throw new ArgumentNullException("fileInfo");

            this.fileInfo = fileInfo;
        }
开发者ID:jango2015,项目名称:WebVella-ERP,代码行数:7,代码来源:MongoStorageFile.cs

示例7: GridFsBlobDescriptor

        public GridFsBlobDescriptor(BlobId blobId, MongoGridFSFileInfo mongoGridFsFileInfo)
        {
            if (mongoGridFsFileInfo == null) throw new ArgumentNullException("mongoGridFsFileInfo");
            _mongoGridFsFileInfo = mongoGridFsFileInfo;
            BlobId = blobId;

            FileNameWithExtension = new FileNameWithExtension(_mongoGridFsFileInfo.Name);
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:8,代码来源:GridFsBlobDescriptor.cs

示例8: FileModelFromGridFSMetadata

        public static FileModel FileModelFromGridFSMetadata(MongoGridFSFileInfo gfs_entry)
        {
            var file_model = new FileModel();

            file_model.Filename = gfs_entry.Metadata["Filename"].AsString;
            file_model.PatientID = gfs_entry.Metadata["PatientID"].AsString;
            file_model.ID = gfs_entry.Id.AsObjectId;

            return file_model;
        }
开发者ID:snasser,项目名称:patient_portal,代码行数:10,代码来源:PatientRepository.cs

示例9: SetMetadata

 /// <summary>
 /// Sets the metadata for an existing GridFS file.
 /// </summary>
 /// <param name="fileInfo">The GridFS file.</param>
 /// <param name="metadata">The metadata.</param>
 public void SetMetadata(MongoGridFSFileInfo fileInfo, BsonValue metadata)
 {
     var database = GetDatabase(ReadPreference.Primary);
     var filesCollection = GetFilesCollection(database);
     var query = Query.EQ("_id", fileInfo.Id);
     var update = (metadata == null) ? Update.Unset("metadata") : Update.Set("metadata", metadata);
     filesCollection.Update(query, update, _settings.WriteConcern);
 }
开发者ID:paberline,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs

示例10: CreateText

 /// <summary>
 /// Creates or opens a GridFS file for writing UTF-8 encoded text.
 /// </summary>
 /// <param name="remoteFileName">The remote file name.</param>
 /// <param name="createOptions">The create options.</param>
 /// <returns>A stream writer.</returns>
 public StreamWriter CreateText(string remoteFileName, MongoGridFSCreateOptions createOptions)
 {
     if (_settings.ReadPreference != ReadPreference.Primary)
     {
         var gridFS = GetPrimaryGridFSSettings();
         return gridFS.CreateText(remoteFileName, createOptions);
     }
     using (_server.RequestStart(null, ReadPreference.Primary))
     {
         var serverInstance = _server.RequestConnection.ServerInstance;
         var fileInfo = new MongoGridFSFileInfo(_server, serverInstance, _databaseName, _settings, remoteFileName, createOptions);
         return fileInfo.CreateText();
     }
 }
开发者ID:ExM,项目名称:mongo-csharp-driver,代码行数:20,代码来源:MongoGridFS.cs

示例11: SetContentType

 /// <summary>
 /// Sets the content type for an existing GridFS file.
 /// </summary>
 /// <param name="fileInfo">The GridFS file.</param>
 /// <param name="contentType">The content type.</param>
 public void SetContentType(MongoGridFSFileInfo fileInfo, string contentType)
 {
     var database = GetDatabase(ReadPreference.Primary);
     var filesCollection = GetFilesCollection(database);
     var query = Query.EQ("_id", fileInfo.Id);
     var update = (contentType == null) ? Update.Unset("contentType") : Update.Set("contentType", contentType);
     filesCollection.Update(query, update, _settings.WriteConcern);
 }
开发者ID:paberline,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs

示例12: OpenWrite

 /// <summary>
 /// Opens an existing GridFS file for writing.
 /// </summary>
 /// <param name="remoteFileName">The remote file name.</param>
 /// <param name="createOptions">The create options.</param>
 /// <returns>A stream.</returns>
 public MongoGridFSStream OpenWrite(
     string remoteFileName,
     MongoGridFSCreateOptions createOptions
 ) {
     var fileInfo = new MongoGridFSFileInfo(this, remoteFileName, createOptions);
     return fileInfo.OpenWrite();
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs

示例13: SetContentType

 /// <summary>
 /// Sets the content type for an existing GridFS file.
 /// </summary>
 /// <param name="fileInfo">The GridFS file.</param>
 /// <param name="contentType">The content type.</param>
 public void SetContentType(
     MongoGridFSFileInfo fileInfo,
     string contentType
 ) {
     var query = Query.EQ("_id", fileInfo.Id);
     var update = (contentType == null) ? Update.Unset("contentType") : Update.Set("contentType", contentType);
     files.Update(query, update);
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs

示例14: OpenText

 /// <summary>
 /// Opens an existing UTF-8 encoded text GridFS file for reading.
 /// </summary>
 /// <param name="remoteFileName">The remote file name.</param>
 /// <returns>A stream reader.</returns>
 public StreamReader OpenText(
     string remoteFileName
 ) {
     var fileInfo = new MongoGridFSFileInfo(this, remoteFileName);
     return fileInfo.OpenText();
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFS.cs

示例15: Open

 /// <summary>
 /// Opens a GridFS file with the specified mode.
 /// </summary>
 /// <param name="remoteFileName">The remote file name.</param>
 /// <param name="mode">The mode.</param>
 /// <returns>A stream.</returns>
 public MongoGridFSStream Open(
     string remoteFileName,
     FileMode mode
 ) {
     var fileInfo = new MongoGridFSFileInfo(this, remoteFileName);
     return fileInfo.Open(mode);
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs


注:本文中的MongoDB.Driver.GridFS.MongoGridFSFileInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。