コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountService"/> class.
 /// </summary>
 /// <param name="staticConfig">The static configuration.</param>
 /// <param name="userData">The user data.</param>
 /// <param name="userTokenData">The user token data.</param>
 /// <param name="adminLogService">The admin log service.</param>
 public AccountService(IStaticConfig staticConfig, IUserData userData, IUserTokenData userTokenData, IAdminLogService adminLogService)
 {
     _staticConfig    = staticConfig;
     _userData        = userData;
     _userTokenData   = userTokenData;
     _adminLogService = adminLogService;
 }
コード例 #2
0
 public BlogController(ILogger <BlogController> logger, IHttpClientFactory httpClientFactory, IStaticConfig staticConfig)
 {
     _logger            = logger;
     this._staticConfig = staticConfig;
     // _httpClient = httpClientFactory.CreateClient("name");//工厂创建   services.AddHttpClient("",options=>options.BaseAddress = new Uri(Configuration["StaticConfigs:BlogApiUrl"]));
     _httpClient = httpClientFactory.CreateClient();
 }
コード例 #3
0
        public SecurityService(IOptions <JwtAuthentication> jwtAuthentication, IStaticConfig staticConfig)
        {
            _jwtAuthentication = jwtAuthentication?.Value ?? throw new ArgumentNullException(nameof(jwtAuthentication));
            _staticConfig      = staticConfig;

            ValidIssuer   = _jwtAuthentication.ValidIssuer;
            ValidAudience = _jwtAuthentication.ValidAudience;
        }
コード例 #4
0
ファイル: ConfigService.cs プロジェクト: wdavidsen/HomePhotos
        public ConfigService(IConfigData config, IDynamicConfig dynamicConfig, IStaticConfig staticConfig)
        {
            _configData   = config;
            DynamicConfig = dynamicConfig;
            StaticConfig  = staticConfig;

            DynamicConfig.PropertyChanged += _dynamicConfig_PropertyChanged;
        }
コード例 #5
0
 /// <summary>Initializes a new instance of the <see cref="AuthController" /> class.</summary>
 /// <param name="logger">The logger.</param>
 /// <param name="jwtAuthentication">The JWT authentication.</param>
 /// <param name="accountService">The account service.</param>
 /// <param name="staticConfig">The static configuration.</param>
 /// <param name="securityService">The security service.</param>
 /// <exception cref="ArgumentNullException">jwtAuthentication</exception>
 public AuthController(ILogger <AuthController> logger,
                       IOptions <JwtAuthentication> jwtAuthentication,
                       IAccountService accountService,
                       IStaticConfig staticConfig,
                       ISecurityService securityService)
 {
     _logger            = logger;
     _jwtAuthentication = jwtAuthentication?.Value ?? throw new ArgumentNullException(nameof(jwtAuthentication));
     _accountService    = accountService;
     _staticConfig      = staticConfig;
     _securityService   = securityService;
 }
コード例 #6
0
 /// <summary>Initializes a new instance of the <see cref="AccountController" /> class.</summary>
 /// <param name="logger">The logger.</param>
 /// <param name="accountService">The account service.</param>
 /// <param name="staticConfig">The static configuration.</param>
 /// <param name="securityService">The security service.</param>
 /// <param name="fileUploadService">The file upload service.</param>
 /// <param name="dynamicConfig">The dynamic configuration.</param>
 public AccountController(ILogger <AccountController> logger,
                          IAccountService accountService,
                          IStaticConfig staticConfig,
                          ISecurityService securityService,
                          IFileUploadService fileUploadService,
                          IDynamicConfig dynamicConfig)
 {
     _logger            = logger;
     _accountService    = accountService;
     _staticConfig      = staticConfig;
     _securityService   = securityService;
     _fileUploadService = fileUploadService;
     _dynamicConfig     = dynamicConfig;
 }
コード例 #7
0
 public LoremIpsumDatabaseService(IStaticConfig staticConfig)
 {
     _staticConfig = staticConfig;
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserTokenData"/> class.
 /// </summary>
 /// <param name="staticConfig">The static configuration.</param>
 public UserTokenData(IStaticConfig staticConfig) : base(staticConfig)
 {
 }
コード例 #9
0
 public MySQLDatabaseService(IStaticConfig staticConfig)
 {
     _staticConfig = staticConfig;
 }
コード例 #10
0
ファイル: LogData.cs プロジェクト: wdavidsen/HomePhotos
 /// <summary>
 /// Initializes a new instance of the <see cref="LogData"/> class.
 /// </summary>
 /// <param name="staticConfig">The static configuration.</param>
 public LogData(IStaticConfig staticConfig) : base(staticConfig)
 {
 }
コード例 #11
0
 public ImageTransformer(ILogger <ImageTransformer> logger, IStaticConfig staticConfig)
 {
     _logger       = logger;
     _staticConfig = staticConfig;
 }
コード例 #12
0
 public HelloWorldDatabaseService(IStaticConfig staticConfig)
 {
     _staticConfig = staticConfig;
 }
コード例 #13
0
 /// <summary>Initializes a new instance of the <see cref="PhotosController" /> class.</summary>
 /// <param name="logger">The logger.</param>
 /// <param name="photoSevice">The photo sevice.</param>
 /// <param name="staticConfig">The static configuration.</param>
 public PhotosController(ILogger <PhotosController> logger, IPhotoService photoSevice, IStaticConfig staticConfig)
 {
     _logger       = logger;
     _photoSevice  = photoSevice;
     _staticConfig = staticConfig;
 }
コード例 #14
0
 public AdminLogService(ILogData logData, IStaticConfig staticConfig)
 {
     _logData = logData;
     _staticConfig = staticConfig;
 }
コード例 #15
0
ファイル: DataBase.cs プロジェクト: wdavidsen/HomePhotos
 /// <summary>
 /// Initializes a new instance of the <see cref="DataBase"/> class.
 /// </summary>
 /// <param name="staticConfig">The static configuration.</param>
 public DataBase(IStaticConfig staticConfig)
 {
     _staticConfig = staticConfig;
     SimpleCRUD.SetDialect(SimpleCRUD.Dialect.SQLite);
 }
コード例 #16
0
 /// <summary>Initializes a new instance of the <see cref="UsersController" /> class.</summary>
 /// <param name="logger">The logger.</param>
 /// <param name="accountService">The account service.</param>
 /// <param name="staticConfig">The static configuration.</param>
 public UsersController(ILogger <UsersController> logger, IAccountService accountService, IStaticConfig staticConfig)
 {
     _logger         = logger;
     _accountService = accountService;
     _staticConfig   = staticConfig;
 }
コード例 #17
0
        /// <summary>
        /// Middleware entry point.
        /// </summary>
        /// <param name="httpContext">The request.</param>
        /// <param name="dynamicConfig">The dynamic configuration.</param>
        /// <param name="staticConfig">The static configuration.</param>
        /// <returns>A void task.</returns>
        public async Task InvokeAsync(HttpContext httpContext, IDynamicConfig dynamicConfig, IStaticConfig staticConfig)
        {
            var request = httpContext.Request;

            if (request.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase) &&
                httpContext.Request.Path.Value.StartsWith(Constants.CacheRoute, StringComparison.InvariantCultureIgnoreCase))
            {
                var folderAndFileInfo = httpContext.Request.Path.Value.Substring(Constants.CacheRoute.Length).Trim('/').Split('/');
                var size = httpContext.Request.Query.ContainsKey("type") ? httpContext.Request.Query["type"].ToString().ToLower() : "thumb";

                switch (size)
                {
                case "thumb":
                case "thumbnail":
                    size = "thumb";
                    break;

                case "small":
                case "sm":
                    size = "small";
                    break;

                case "full":
                case "large":
                case "lg":
                    size = "full";
                    break;
                }

                httpContext.Response.Headers.Add("Cache-Control", "Private");
                httpContext.Response.Headers.Add("Expires", DateTime.UtcNow.AddDays(staticConfig.PhotoExpirationDays).ToString("u"));

                var folder        = folderAndFileInfo[0];
                var fileInfo      = folderAndFileInfo[1].Decrypt(staticConfig.ImagePasscode);
                var fileInfoParts = fileInfo.Split('|');
                var file          = fileInfoParts[0];
                var expiration    = DateTime.Parse(fileInfoParts[1]);

                if (expiration < DateTime.UtcNow.ToStartOfDay())
                {
                    httpContext.Response.StatusCode = 400;
                    return;
                }

                var cachePath = Path.Combine(dynamicConfig.CacheFolder.TrimEnd('/', '\\'), folder, size, file);
                await httpContext.Response.SendFileAsync(cachePath);
            }
            else
            {
                await _next(httpContext);
            }
        }