using System; using System.ComponentModel; using System.Linq; using System.Reflection; namespace FormulaEnginePoC.FormulaEngine.Mapping { public class PropertyMapping { [DisplayName("名称")] public string Display { get; } [DisplayName("字段")] public string Name { get; } [DisplayName("数据类型")] public Type DataType { get; } public PropertyMapping(PropertyInfo prop) { Name = prop.Name; Display = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true) .OfType() .FirstOrDefault()?.DisplayName ?? Name; DataType = prop.PropertyType; } } }