Add description property to property adapter.

This commit is contained in:
2023-11-11 11:42:05 +08:00
parent 9db2ded366
commit c05b771425
2 changed files with 5 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ namespace Cryville.Crtr.Config {
public interface IPropertyAdapter {
string Category { get; }
string Name { get; }
string Description { get; }
PropertyType Type { get; }
object[] Range { get; }
object GetValue();
@@ -31,6 +32,7 @@ namespace Cryville.Crtr.Config {
readonly PropertyInfo _prop;
public string Category { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public PropertyType Type { get; private set; }
public object[] Range { get; private set; }
public object GetValue() { return _prop.GetValue(_target, null); }
@@ -68,6 +70,8 @@ namespace Cryville.Crtr.Config {
var attrs = prop.GetCustomAttributes(typeof(CategoryAttribute), true);
if (attrs.Length > 0) Category = ((CategoryAttribute)attrs.Single()).Category;
Name = prop.Name;
var attrs2 = prop.GetCustomAttributes(typeof(DescriptionAttribute), true);
if (attrs2.Length > 0) Description = ((DescriptionAttribute)attrs2.Single()).Description;
if (prop.PropertyType == typeof(bool)) Type = PropertyType.Boolean;
else if (prop.PropertyType == typeof(char)) throw new NotSupportedException();
else if (prop.PropertyType.IsPrimitive) {

View File

@@ -54,8 +54,8 @@ namespace Cryville.Crtr.Config {
}
public string Category { get { return _def.category; } }
public string Name { get; private set; }
public string Description { get { return null; } }
public PropertyType Type { get; private set; }