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


C# GridFS.MongoGridFS类代码示例

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


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

示例1: MongoGridFSFileInfo

 internal MongoGridFSFileInfo(
     MongoGridFS gridFS,
     BsonDocument fileInfo
 ) {
     this.gridFS = gridFS;
     CacheFileInfo(fileInfo);
 }
开发者ID:simi--,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoGridFSFileInfo.cs

示例2: 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

示例3: 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

示例4: MongoGridFSFileInfo

 public MongoGridFSFileInfo(
     MongoGridFS gridFS,
     string remoteFileName
 )
     : this(gridFS, remoteFileName, gridFS.Settings.DefaultChunkSize)
 {
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoGridFSFileInfo.cs

示例5: Upload

 /// <summary>
 /// Store a file in the database
 /// </summary>
 /// <param name="stream">The stream of the files content</param>
 /// <param name="fileName">The remote filename</param>
 /// <param name="contentType">The file's content type</param>
 /// <returns>GridFS File Info</returns>
 public MongoGridFSFileInfo Upload(Stream stream, string fileName, string contentType)
 {
     MongoGridFS fs = new MongoGridFS(this.store);
     MongoGridFSCreateOptions options = new MongoGridFSCreateOptions();
     options.ContentType = contentType;
     return fs.Upload(stream, fileName, options);
 }
开发者ID:gazeth,项目名称:Bullet,代码行数:14,代码来源:GridFS.cs

示例6: 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

示例7: Queue

        /// <summary>
        /// Construct MongoQueue
        /// </summary>
        /// <param name="collection">collection</param>
        /// <exception cref="ArgumentNullException">collection is null</exception>
        public Queue(MongoCollection collection)
        {
            if (collection == null) throw new ArgumentNullException("collection");

            this.collection = collection;
            this.gridfs = collection.Database.GetGridFS(MongoGridFSSettings.Defaults);
        }
开发者ID:cihanozhan,项目名称:mongo-queue-csharp,代码行数:12,代码来源:Queue.cs

示例8: Add

        /// <summary>
        /// 添加本地文件
        /// </summary>
        /// <param name="filePath">本地文件路径</param>
        /// <param name="remoteFile">服务Id</param>
        /// <returns></returns>
        public MetaInfo Add(string filePath, string remoteFile)
        {
            try
            {
                _logger.DebugFormat("Add File filePath:{0}, remoteId:{1}", filePath, remoteFile);

                MongoGridFSCreateOptions option = new MongoGridFSCreateOptions
                {
                    Id = remoteFile,
                    UploadDate = DateTime.Now,
                    ContentType = MimeMapper.GetMimeMapping(filePath),
                };

                using (var stream = new FileStream(filePath, FileMode.Open))
                {
                    MongoGridFS fs = new MongoGridFS(_context.DataBase);

                    var info = fs.Upload(stream, remoteFile, option);
                    return new MetaInfo
                    {
                        fileName = remoteFile,
                        MD5 = info.MD5,
                        MimeType = info.ContentType,
                    };
                }

            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                _logger.Error(ex.StackTrace);
                throw;
            }
        }
开发者ID:ideayapai,项目名称:docviewer,代码行数:40,代码来源:MongoPolicy.cs

示例9: 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

示例10: MongoGridFSTests

 public MongoGridFSTests()
 {
     _server = LegacyTestConfiguration.Server;
     _database = LegacyTestConfiguration.Database;
     _gridFS = _database.GridFS;
     _gridFS.Chunks.RemoveAll();
     _gridFS.Files.RemoveAll();
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:8,代码来源:MongoGridFSTests.cs

示例11: 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

示例12: OnTestFixtureSetUp

        protected override void OnTestFixtureSetUp() {
            base.OnTestFixtureSetUp();

            var settings = new MongoGridFSSettings
                           {
                               ChunkSize = 16,
                               SafeMode = SafeMode.True
                           };
            gridFS = Database.GetGridFS(settings);
        }
开发者ID:debop,项目名称:NFramework,代码行数:10,代码来源:MongoGridFSStreamFixture.cs

示例13: BookContext

        public BookContext()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
            var con = new MongoUrlBuilder(connectionString);

            client = new MongoClient(connectionString);
            database = client.GetDatabase(con.DatabaseName);

            gridFS = new MongoGridFS(new MongoServer(new MongoServerSettings { Server = con.Server }),con.DatabaseName, new MongoGridFSSettings());
        }
开发者ID:Ubuntus,项目名称:TestWithMongoDB,代码行数:10,代码来源:BookContext.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: MongoGridFSFileInfo

 public MongoGridFSFileInfo(
     MongoGridFS gridFS,
     string remoteFileName,
     int chunkSize
 )
 {
     this.gridFS = gridFS;
     this.chunkSize = chunkSize;
     this.id = BsonObjectId.GenerateNewId();
     this.name = remoteFileName;
 }
开发者ID:tomthink,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFSFileInfo.cs


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