using System.Reflection; namespace SHJX.Service.Library.Common { public class CommonUtil { /// /// 反射获取指定值 /// /// /// /// public static object GetPropertyValue(object obj, string path) { //Type type = obj.GetType(); //System.Reflection.PropertyInfo propertyInfo = type.GetProperty(path); //if(propertyInfo == null) //{ // return null; //} //return propertyInfo.GetValue(obj, null); if (obj == null) return string.Empty; bool flag = !string.IsNullOrEmpty(path); object result; if (flag) { PropertyInfo property = obj.GetType().GetProperty(path); bool flag2 = property != null; if (flag2) { result = property.GetValue(obj, null); return result; } } result = obj; return result; } } }