114 lines
2.8 KiB
C#
114 lines
2.8 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using Unosquare.Swan.Attributes;
|
|
|
|
namespace Unosquare.Swan.Reflection {
|
|
/// <summary>
|
|
/// Represents a Property object from a Object Reflection Property with extended values.
|
|
/// </summary>
|
|
public class ExtendedPropertyInfo {
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExtendedPropertyInfo"/> class.
|
|
/// </summary>
|
|
/// <param name="propertyInfo">The property information.</param>
|
|
public ExtendedPropertyInfo(PropertyInfo propertyInfo) {
|
|
if(propertyInfo == null) {
|
|
throw new ArgumentNullException(nameof(propertyInfo));
|
|
}
|
|
|
|
this.Property = propertyInfo.Name;
|
|
this.DataType = propertyInfo.PropertyType.Name;
|
|
|
|
foreach(PropertyDisplayAttribute display in Runtime.AttributeCache.Retrieve<PropertyDisplayAttribute>(propertyInfo, true)) {
|
|
this.Name = display.Name;
|
|
this.Description = display.Description;
|
|
this.GroupName = display.GroupName;
|
|
this.DefaultValue = display.DefaultValue;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the property.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The property.
|
|
/// </value>
|
|
public String Property {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the type of the data.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The type of the data.
|
|
/// </value>
|
|
public String DataType {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the value.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The value.
|
|
/// </value>
|
|
public Object Value {
|
|
get; set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the default value.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The default value.
|
|
/// </value>
|
|
public Object DefaultValue {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the name.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The name.
|
|
/// </value>
|
|
public String Name {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the description.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The description.
|
|
/// </value>
|
|
public String Description {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the name of the group.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The name of the group.
|
|
/// </value>
|
|
public String GroupName {
|
|
get;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents a Property object from a Object Reflection Property with extended values.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the object.</typeparam>
|
|
public class ExtendedPropertyInfo<T> : ExtendedPropertyInfo {
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExtendedPropertyInfo{T}"/> class.
|
|
/// </summary>
|
|
/// <param name="property">The property.</param>
|
|
public ExtendedPropertyInfo(String property)
|
|
: base(typeof(T).GetProperty(property)) {
|
|
}
|
|
}
|
|
} |