using System; using System.Reflection; using Unosquare.Swan.Attributes; namespace Unosquare.Swan.Reflection { /// /// Represents a Property object from a Object Reflection Property with extended values. /// public class ExtendedPropertyInfo { /// /// Initializes a new instance of the class. /// /// The property information. 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(propertyInfo, true)) { this.Name = display.Name; this.Description = display.Description; this.GroupName = display.GroupName; this.DefaultValue = display.DefaultValue; } } /// /// Gets or sets the property. /// /// /// The property. /// public String Property { get; } /// /// Gets or sets the type of the data. /// /// /// The type of the data. /// public String DataType { get; } /// /// Gets or sets the value. /// /// /// The value. /// public Object Value { get; set; } /// /// Gets or sets the default value. /// /// /// The default value. /// public Object DefaultValue { get; } /// /// Gets or sets the name. /// /// /// The name. /// public String Name { get; } /// /// Gets or sets the description. /// /// /// The description. /// public String Description { get; } /// /// Gets or sets the name of the group. /// /// /// The name of the group. /// public String GroupName { get; } } /// /// Represents a Property object from a Object Reflection Property with extended values. /// /// The type of the object. public class ExtendedPropertyInfo : ExtendedPropertyInfo { /// /// Initializes a new instance of the class. /// /// The property. public ExtendedPropertyInfo(String property) : base(typeof(T).GetProperty(property)) { } } }