public MediaServiceConfiguration() { CoreConfig = BlobStorageConfig.GetConfig("./Resource/blobstorageconfig.json"); WebConfig = WebConfig.GetWebConfig("./webconfig.json"); MongoDbConfig mongoDbConfig = MongoDbConfig.GetMongoDbConfig("./Resource/mongodbconfig.json"); ImageService = ImageServiceFactory.GetImageService(CoreConfig, mongoDbConfig); }
public TestMongoDb(ITestOutputHelper output) { MongoDbConfig mongoDbConfig = MongoDbConfig.GetMongoDbConfig(@"C:\Users\t-chwang\source\repos\ImageServingPlatform\Tests\mongodbconfig.json"); this.context = new MediaRecordMongoDatabaseContext(mongoDbConfig); manager = new ImageMongoDbManager(context); this.output = output; }
static void TestMongoModelGetIdByMD5() { MediaRecordMongoDatabaseContext context; ImageMongoDbManager manager; MongoDbConfig mongoDbConfig = MongoDbConfig.GetMongoDbConfig(@"C:\Users\t-chwang\source\repos\ImageServingPlatform\Core\DBManager\resource\mongodbconfig.json"); context = new MediaRecordMongoDatabaseContext(mongoDbConfig); manager = new ImageMongoDbManager(context); String str = manager.GetIdByMD5(0xdead); str = manager.GetIdByMD5(123); Console.WriteLine(str); }
static void TestMongoModel() { MediaRecordMongoDatabaseContext context; ImageMongoDbManager manager; MongoDbConfig mongoDbConfig = MongoDbConfig.GetMongoDbConfig(@"C:\Users\t-chwang\source\repos\ImageServingPlatform\Core\DBManager\resource\mongodbconfig.json"); context = new MediaRecordMongoDatabaseContext(mongoDbConfig); manager = new ImageMongoDbManager(context); Image image = new Image { Width = 500, Height = 500, BlobName = "Shit", MD5 = 123 }; image = manager.Create(image); Console.WriteLine(image.Id); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddOptions(); // services.Configure<MediaServiceConfiguration>(Configuration); services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); BlobStorageConfig blobStorageConfig = BlobStorageConfig.GetConfig("./Resource/blobstorageconfig.json"); FileStorageConfig fileStorageConfig = FileStorageConfig.GetConfig("./Resource/filestorageconfig.json"); MongoDbConfig mongoDbConfig = MongoDbConfig.GetMongoDbConfig("./Resource/mongodbconfig.json"); WebConfig webConfig = WebConfig.GetWebConfig("./webconfig.json"); services.AddSingleton <IImageService, ImageService>( s => ImageServiceFactory.GetImageServiceCached(blobStorageConfig, fileStorageConfig, mongoDbConfig) ); services.AddSingleton <WebConfig, WebConfig>(c => webConfig); services.AddMvc(); }