예제 #1
0
        internal SettingInfo(PropertyInfo info, ApplicationSettingCollection settingCollection, SettingAttribute settingAttribute)
        {
            this.PropertyInfo = info;
            this.Info         = settingAttribute;
            this.Name         = info.Name;
            this.FriendlyName = StringLoader.GetString(this.Name);

            this.ValueRepresent = info.GetCustomAttribute <ValueRepresentAttribute>();

            var pType = info.PropertyType;

            if (this.ValueRepresent is null)
            {
                if (!typeDic.TryGetValue(pType, out this.type))
                {
                    if (pType == typeof(bool))
                    {
                        this.ValueRepresent = ToggleSwitchRepresentAttribute.Default;
                    }
                    else if (pType.GetTypeInfo().IsEnum)
                    {
                        this.ValueRepresent = EnumRepresentAttribute.Default;
                    }
                    else
                    {
                        throw new InvalidOperationException($"Unsupported property type: {{{pType}}}");
                    }
                }
            }
            settingCollection.PropertyChanged += this.settingsChanged;
            this.settingCollection             = settingCollection;
        }
예제 #2
0
 public string GetFriendlyNameOf(string name)
 {
     if (ReferenceEquals(this, Default))
     {
         return(name);
     }
     return(StringLoader.GetString($"{this.ResourcePrefix}/{name}"));
 }
예제 #3
0
 public ToggleSwitchRepresentAttribute(string trueStringKey, string falseStringKey)
 {
     this.TrueString  = StringLoader.GetString(trueStringKey);
     this.FalseString = StringLoader.GetString(falseStringKey);
 }