當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。