예제 #1
0
 /// <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);
 }
예제 #2
0
        /// <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);
            }
        }
예제 #3
0
        public static string GetFieldValueAsString(this SP.ClientObject clientObject, string fieldName)
        {
            PropertyInfo prop = clientObject.GetType().GetProperties().FirstOrDefault(s => s.Name == fieldName);

            return(clientObject.GetFieldValueAsString(prop));
        }