Ejemplo n.º 1
0
 public NoteController(IMediator mediator, IMapper mapper, IOptions <FileServiceOptions> options, ITokenService tokenService)
 {
     _mediator         = mediator;
     _mapper           = mapper;
     _localFileOptions = options.Value;
     _tokenService     = tokenService;
 }
Ejemplo n.º 2
0
        public FileService(IOptionsMonitor <FileServiceOptions> options)
        {
            _options = options.CurrentValue;

            basePath = Path.Combine(Environment.CurrentDirectory, _options.BasePath);
            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor for dependency injection
 /// </summary>
 /// <param name="options"></param>
 public LocalFileService(IOptions <FileServiceOptions> options)
 {
     _localFileOptions = options.Value;
 }
Ejemplo n.º 6
0
 public FileService(IRandomGenerator random, IOptions <FileServiceOptions> options)
 {
     this.random   = random;
     this.settings = options.Value;
 }