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; }
public string GetFriendlyNameOf(string name) { if (ReferenceEquals(this, Default)) { return(name); } return(StringLoader.GetString($"{this.ResourcePrefix}/{name}")); }
public ToggleSwitchRepresentAttribute(string trueStringKey, string falseStringKey) { this.TrueString = StringLoader.GetString(trueStringKey); this.FalseString = StringLoader.GetString(falseStringKey); }