Exemplo n.º 1
0
        public async Task <T> GetAsync <T>(string name)
        {
            var setting   = _definitionManager.Get(name) as SettingDefinition <T>;
            var providers = _providerManager.Providers.Reverse();
            var value     = await GetValueFromProvidersAsync(providers, setting);

            return(value);
        }
    public async Task GetOrNullAsync()
    {
        var mySetting3 = _settingDefinitionManager.Get("MySetting3");

        var defaultValueSettingManagementProvider = new DefaultValueSettingManagementProvider();

        (await defaultValueSettingManagementProvider
         .GetOrNullAsync(mySetting3, DefaultValueSettingValueProvider.ProviderName)).ShouldBe("123");
    }
Exemplo n.º 3
0
        public void Definition_Localization_Test(string propName)
        {
            var settingType = typeof(ComplexSetting);
            var prop        = settingType.GetProperties().First(w => w.Name == propName);
            var sd          = _settingDefinitionManager.Get(prop.GetDefaultSettingName());

            sd.DisplayName.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
            sd.Description.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
            using (CultureHelper.Use("zh-Hans"))
            {
                sd.DisplayName.Localize(_stringLocalizerFactory).Value.ShouldNotBe(propName);
                sd.DisplayName.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
                sd.Description.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
            }
            using (CultureHelper.Use("zh-Hant"))
            {
                sd.DisplayName.Localize(_stringLocalizerFactory).Value.ShouldNotBe(propName);
                sd.DisplayName.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
                sd.Description.Localize(_stringLocalizerFactory).Value.ShouldNotBeNullOrWhiteSpace();
            }
        }
Exemplo n.º 4
0
 public void SettingDefinitionFirst()
 {
     _settingDefinitionManager.Get("Setting").ShouldBeOfType <SettingDefinition <string> >().Name.ShouldBe("Setting");
 }