コード例 #1
0
        /// <summary>
        /// Get the setting <typeparam name="T">value</typeparam> from the specified <param name="key">key</param>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        /// <returns></returns>
        public T Get <T>(string key)
        {
            var cacheKey = string.Format(_baseCacheKey, "Add", typeof(T).Name, key);

            return((T)_cachingProvider.Retrieve <object>(cacheKey, _defaultAbsoluteExpiration, () =>
                                                         _settingProvider.Get <T>(key)));
        }
        public void ApplicationSettingsGetStringTest()
        {
            //Setting needs to be added in App.config
            var expected = "string value";
            var actual   = _settingProvider.Get <string>("stringSetting");

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        protected virtual void OverrideOptions(IdentityOptions options)
        {
            options.Password.RequiredLength         = _settingProvider.Get(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength);
            options.Password.RequiredUniqueChars    = _settingProvider.Get(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars);
            options.Password.RequireNonAlphanumeric = _settingProvider.Get(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric);
            options.Password.RequireLowercase       = _settingProvider.Get(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase);
            options.Password.RequireUppercase       = _settingProvider.Get(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase);
            options.Password.RequireDigit           = _settingProvider.Get(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit);

            options.Lockout.AllowedForNewUsers      = _settingProvider.Get(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers);
            options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromSeconds(_settingProvider.Get(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To <int>()));
            options.Lockout.MaxFailedAccessAttempts = _settingProvider.Get(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts);

            options.SignIn.RequireConfirmedEmail       = _settingProvider.Get(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail);
            options.SignIn.RequireConfirmedPhoneNumber = _settingProvider.Get(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber);
        }