• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GridFS.MongoGridFSFileInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Download

        /// <summary>
        /// Downloads a GridFS file.
        /// </summary>
        /// <param name="stream">The destination stream.</param>
        /// <param name="fileInfo">The GridFS file.</param>
        public void Download(
            Stream stream,
            MongoGridFSFileInfo fileInfo
        ) {
            using (database.RequestStart(database.Settings.SlaveOk)) {
                EnsureIndexes();

                string md5Client;
                using (var md5Algorithm = MD5.Create()) {
                    var numberOfChunks = (fileInfo.Length + fileInfo.ChunkSize - 1) / fileInfo.ChunkSize;
                    for (int n = 0; n < numberOfChunks; n++) {
                        var query = Query.And(
                            Query.EQ("files_id", fileInfo.Id),
                            Query.EQ("n", n)
                        );
                        var chunk = chunks.FindOne(query);
                        if (chunk == null) {
                            string errorMessage = string.Format("Chunk {0} missing for GridFS file '{1}'.", n, fileInfo.Name);
                            throw new MongoGridFSException(errorMessage);
                        }
                        var data = chunk["data"].AsBsonBinaryData;
                        if (data.Bytes.Length != fileInfo.ChunkSize) {
                            // the last chunk only has as many bytes as needed to complete the file
                            if (n < numberOfChunks - 1 || data.Bytes.Length != fileInfo.Length % fileInfo.ChunkSize) {
                                string errorMessage = string.Format("Chunk {0} for GridFS file '{1}' is the wrong size.", n, fileInfo.Name);
                                throw new MongoGridFSException(errorMessage);
                            }
                        }
                        stream.Write(data.Bytes, 0, data.Bytes.Length);
                        md5Algorithm.TransformBlock(data.Bytes, 0, data.Bytes.Length, null, 0);
                    }

                    md5Algorithm.TransformFinalBlock(new byte[0], 0, 0);
                    md5Client = BsonUtils.ToHexString(md5Algorithm.Hash);
                }

                if (!md5Client.Equals(fileInfo.MD5, StringComparison.OrdinalIgnoreCase)) {
                    throw new MongoGridFSException("Download client and server MD5 hashes are not equal.");
                }
            }
        }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:46,代码来源:MongoGridFS.cs


示例17: AppendText

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


示例18: OpenWrite

 /// <summary>
 /// Opens an existing GridFS file for writing.
 /// </summary>
 /// <param name="remoteFileName">The remote file name.</param>
 /// <returns>A stream.</returns>
 public MongoGridFSStream OpenWrite(string remoteFileName)
 {
     if (_settings.ReadPreference != ReadPreference.Primary)
     {
         var gridFS = GetPrimaryGridFSSettings();
         return gridFS.OpenWrite(remoteFileName);
     }
     using (_server.RequestStart(null, ReadPreference.Primary))
     {
         var serverInstance = _server.RequestConnection.ServerInstance;
         var fileInfo = new MongoGridFSFileInfo(_server, serverInstance, _databaseName, _settings, remoteFileName);
         return fileInfo.OpenWrite();
     }
 }
开发者ID:ExM,项目名称:mongo-csharp-driver,代码行数:19,代码来源:MongoGridFS.cs


示例19: 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
 ) {
     var fileInfo = new MongoGridFSFileInfo(this, remoteFileName, createOptions);
     return fileInfo.CreateText();
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoGridFS.cs


示例20: CreateText

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GridFS.MongoGridFSSettings类代码示例发布时间:2022-05-26
下一篇:
C# GridFS.MongoGridFSCreateOptions类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap