/// <summary> /// Function responsible to check whether the client object is Null /// </summary> /// <param name="clientObject"></param> /// <returns></returns> public static bool IsNull(this SP.ClientObject clientObject) { if (clientObject == null) { return(true); } return(clientObject.ServerObjectIsNull.HasValue && clientObject.ServerObjectIsNull.Value); }
/// <summary> /// Get value for a given property /// </summary> /// <param name="clientObject"></param> /// <param name="prop"></param> /// <returns></returns> public static string GetFieldValueAsString(this SP.ClientObject clientObject, PropertyInfo prop) { string fieldValue = string.Empty; if (clientObject?.ServerObjectIsNull == null || prop == null) { return(fieldValue); } try { return(prop.GetValue(clientObject) as string); } catch (TargetInvocationException) { return(fieldValue); } }
public static string GetFieldValueAsString(this SP.ClientObject clientObject, string fieldName) { PropertyInfo prop = clientObject.GetType().GetProperties().FirstOrDefault(s => s.Name == fieldName); return(clientObject.GetFieldValueAsString(prop)); }