|
@@ -0,0 +1,40 @@
|
|
|
|
+/* ==============================================================================
|
|
|
|
+ * 功能描述:PropertyInfoExtend
|
|
|
|
+ * 创 建 者:Garrett
|
|
|
|
+ * 创建日期:2019/4/19 15:48:48
|
|
|
|
+ * ==============================================================================*/
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.ComponentModel;
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Reflection;
|
|
|
|
+using System.Text;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
+
|
|
|
|
+namespace SAGA.DotNetUtils.Extend
|
|
|
|
+{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// PropertyInfoExtend
|
|
|
|
+ /// </summary>
|
|
|
|
+ public static class PropertyInfoExtend
|
|
|
|
+ {
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取DescriptionAttribute
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="propertyInfo"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static string GetDescriptionValue(this PropertyInfo propertyInfo)
|
|
|
|
+ {
|
|
|
|
+ string description = "";
|
|
|
|
+ var attributes = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute));
|
|
|
|
+ var att = attributes.FirstOrDefault();
|
|
|
|
+
|
|
|
|
+ if (att is DescriptionAttribute descriptionAttribute)
|
|
|
|
+ {
|
|
|
|
+ description = descriptionAttribute.Description;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return description;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|