using System.Reflection; namespace BS.Shared.Extensions { public static class ObjectExtensions { public static bool EqualsNullCheck(this object pObject, object otherObject) { return pObject == null ? otherObject == null : pObject.Equals(otherObject); } public static object GetPropertyValue(this object pObject, string pPropertyName) { PropertyInfo pPropInfo = pObject.GetType().GetProperty(pPropertyName); return pPropInfo == null ? null : pPropInfo.GetValue(pObject, null); } public static void SetPropertyValue(this object pObject, string pPropertyName, object value) { PropertyInfo pPropInfo = pObject.GetType().GetProperty(pPropertyName); pPropInfo?.SetValue(pObject, value, null); } public static string ToStringNullCheck(this object pObject) { return pObject == null ? string.Empty : pObject.ToString(); } } }