1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace wispro.sp.share.Utility
- {
- public class ObjectHelper
- {
- public static dynamic GetPropertyValue(string propertyName, object obj)
- {
- Type type = obj.GetType();
- PropertyInfo property = type.GetProperty(propertyName);
- dynamic value = property.GetValue(obj);
- return value;
- }
- public static string GetPropertyDescription(string propertyName, string bindObjectType)
- {
- Type type = Type.GetType(bindObjectType);
- PropertyInfo property = type.GetProperty(propertyName);
- DescriptionAttribute att =
- property.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute;
- if (att == null)
- {
- return propertyName.ToString();
- }
- else
- {
- return att.Description;
- }
- }
- }
- }
|