PropertyMapping.cs 755 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.ComponentModel;
  3. using System.Linq;
  4. using System.Reflection;
  5. namespace FormulaEnginePoC.FormulaEngine.Mapping
  6. {
  7. public class PropertyMapping
  8. {
  9. [DisplayName("名称")]
  10. public string Display { get; }
  11. [DisplayName("字段")]
  12. public string Name { get; }
  13. [DisplayName("数据类型")]
  14. public Type DataType { get; }
  15. public PropertyMapping(PropertyInfo prop)
  16. {
  17. Name = prop.Name;
  18. Display = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true)
  19. .OfType<DisplayNameAttribute>()
  20. .FirstOrDefault()?.DisplayName ?? Name;
  21. DataType = prop.PropertyType;
  22. }
  23. }
  24. }