generated from ricardo/MVCLogin
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MongoDB.Driver;
|
|
using SumaTube.Infra.Contracts.Repositories.Videos;
|
|
using SumaTube.Infra.MongoDB.Repositories.Videos;
|
|
using SumaTube.Infra.VideoSumarizer.Contracts;
|
|
using SumaTube.Infra.VideoSumarizer.Videos;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SumaTube.Infra.Register
|
|
{
|
|
public static class InfraServicesRegister
|
|
{
|
|
public static IServiceCollection AddInfraServices(this IServiceCollection services, ConfigurationManager configuration)
|
|
{
|
|
var mongoConnectionString = configuration.GetConnectionString("MongoDB") ?? "mongodb://localhost:27017";
|
|
var mongoDatabaseName = configuration.GetValue<string>("MongoDB:DatabaseName") ?? "SumaTube";
|
|
|
|
services.AddSingleton<IMongoClient>(sp =>
|
|
{
|
|
return new MongoClient(mongoConnectionString);
|
|
});
|
|
|
|
services.AddScoped<IMongoDatabase>(sp =>
|
|
{
|
|
var client = sp.GetRequiredService<IMongoClient>();
|
|
return client.GetDatabase(mongoDatabaseName);
|
|
});
|
|
|
|
services.AddScoped<IVideoSumarizerService, VideoSumarizerService>();
|
|
services.AddScoped<IVideoSummaryRepository, VideoSummaryRepository>();
|
|
return services;
|
|
}
|
|
}
|
|
}
|