public NoteController(IMediator mediator, IMapper mapper, IOptions <FileServiceOptions> options, ITokenService tokenService) { _mediator = mediator; _mapper = mapper; _localFileOptions = options.Value; _tokenService = tokenService; }
public FileService(IOptionsMonitor <FileServiceOptions> options) { _options = options.CurrentValue; basePath = Path.Combine(Environment.CurrentDirectory, _options.BasePath); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } }
private void ConfigureFileService(IApplicationBuilder app) { var fileServiceOptions = new FileServiceOptions(); Configuration.GetSection(nameof(FileServiceOptions)).Bind(fileServiceOptions); if (fileServiceOptions.Type == "LocalFileService") { _container.RegisterSingleton(() => app.ApplicationServices.GetService <IOptions <FileServiceOptions> >()); _container.RegisterSingleton <IFileService, LocalFileService>(); } else { ConfigureAzureStorage(app); } }
public static IServiceCollection AddFileService(this IServiceCollection services, IConfiguration configuration) { var fileServiceOptions = new FileServiceOptions(); configuration.GetSection(nameof(FileServiceOptions)).Bind(fileServiceOptions); if (fileServiceOptions.Type == "LocalFileService") { services.AddSingleton <IFileService, LocalFileService>(); } else { services.AddSingleton <IFileService, BlobService>(); } return(services); }
/// <summary> /// Constructor for dependency injection /// </summary> /// <param name="options"></param> public LocalFileService(IOptions <FileServiceOptions> options) { _localFileOptions = options.Value; }
public FileService(IRandomGenerator random, IOptions <FileServiceOptions> options) { this.random = random; this.settings = options.Value; }