コード例 #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
ファイル: Attributes.cs プロジェクト: qratosone/ExViewer
 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);
 }