本文整理汇总了C#中MongoDB.Driver.GridFS.MongoGridFS类的典型用法代码示例。如果您正苦于以下问题:C# MongoGridFS类的具体用法?C# MongoGridFS怎么用?C# MongoGridFS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MongoGridFS类属于MongoDB.Driver.GridFS命名空间,在下文中一共展示了MongoGridFS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestFixtureSetup
public void TestFixtureSetup()
{
_server = Configuration.TestServer;
_database = Configuration.TestDatabase;
var settings = new MongoGridFSSettings
{
ChunkSize = 16,
SafeMode = SafeMode.True
};
_gridFS = _database.GetGridFS(settings);
}
开发者ID:nilayparikh,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFSStreamTests.cs
示例17: TestFixtureSetup
public void TestFixtureSetup()
{
_server = Configuration.TestServer;
_database = Configuration.TestDatabase;
var settings = new MongoGridFSSettings(_database)
{
ChunkSize = 16,
WriteConcern = WriteConcern.Errors
};
_gridFS = _database.GetGridFS(settings);
}
开发者ID:subbuballa,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFSStreamTests.cs
示例18: UploadImageToDish
public static MongoGridFSFileInfo UploadImageToDish(this Dish dishWithImages, MongoGridFS gridFS, System.IO.Stream fs, string imageName, string contentType)
{
log.DebugFormat("[UploadImageToDish] This RestaurantBasicData.Id={0}, MongoGridFS, imageName={1}, contentType={2}.", dishWithImages.Id, gridFS.ToString(), imageName, contentType);
MongoGridFSCreateOptions gridFSOption = new MongoGridFSCreateOptions();
gridFSOption.ContentType = contentType;
var gridFsInfo = gridFS.Upload(fs, imageName, gridFSOption);
ImageData convertedValue = ImageServices.ConvertToImageData(gridFsInfo);
dishWithImages.Image = convertedValue;
//dishWithImages.Images[0] = convertedValue;
var fileId = gridFsInfo.Id;
return gridFsInfo;
}
开发者ID:pashkov,项目名称:Spontaneous,代码行数:13,代码来源:ImageServices.cs
示例19: multiThreadedUpload
// uploading all the chunks into grid.fs.files asynchronously but we have to watch out for
// resource competition. so we will only allow upto 'simultaneousUploads' tasks run at a time.
// this ensure that gridfs to not overwhelm with write requests.
public void multiThreadedUpload(List<byte[]> chunks, string id, MongoGridFS grid)
{
SemaphoreSlim max = new SemaphoreSlim(simultaneousUploads);
var tasks = new Task[chunks.Count];
for (var i = 0; i < chunks.Count; i++) {
max.Wait();
var index = i;
var chunkMetadata = new BsonDocument { { "files_id", new ObjectId(id) }, { "n", i }, { "data", chunks[i] } };
tasks[i] = Task.Factory.StartNew(() => writeToGrid(chunkMetadata, grid, index)
, TaskCreationOptions.LongRunning)
.ContinueWith( (task) => max.Release());
}
Task.WaitAll(tasks);
}
开发者ID:senghuot,项目名称:resumable,代码行数:17,代码来源:Resumable.cs
示例20: Setup
public virtual void Setup()
{
collection = new MongoClient(ConfigurationManager.AppSettings["mongoQueueUrl"])
.GetServer()
.GetDatabase(ConfigurationManager.AppSettings["mongoQueueDb"])
.GetCollection(ConfigurationManager.AppSettings["mongoQueueCollection"]);
collection.Drop();
gridfs = collection.Database.GetGridFS(MongoGridFSSettings.Defaults);
gridfs.Files.Drop();
gridfs.Chunks.Drop();
queue = new Queue();
}
开发者ID:cihanozhan,项目名称:mongo-queue-csharp,代码行数:15,代码来源:QueueTests.cs
注:本文中的MongoDB.Driver.GridFS.MongoGridFS类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论