/// <summary> /// Method for getting an DateTime value from a property holder. /// </summary> /// <param name="holder">The property holder.</param> /// <param name="key">The key of the property.</param> /// <returns>The value of the property.</returns> public static DateTime GetCustomPropertyDateTime(this ICustomPropertyHolder holder, String key) { String value = holder.GetCustomPropertyString(key); DateTime output; if (DateTime.TryParse(value, out output)) { return(new DateTime(output.Year, output.Month, output.Day, output.Hour, output.Minute, output.Second, output.Millisecond, DateTimeKind.Utc)); } return(default(DateTime)); }
/// <summary> /// Method for getting an Int32 value from a property holder. /// </summary> /// <param name="holder">The property holder.</param> /// <param name="key">The key of the property.</param> /// <returns>The value of the property.</returns> public static Int32 GetCustomPropertyInt32(this ICustomPropertyHolder holder, String key) { String value = holder.GetCustomPropertyString(key); Int32 output; if (Int32.TryParse(value, out output)) { return(output); } return(default(Int32)); }
public static Boolean GetCustomPropertyBoolean(this ICustomPropertyHolder holder, String key) { String value = holder.GetCustomPropertyString(key); Boolean output; if (Boolean.TryParse(value, out output)) { return(output); } return(default(Boolean)); }
/// <summary> /// Method for trying to get an DateTime value from the custom properties. /// </summary> /// <param name="holder">The property holder.</param> /// <param name="key">The key of the property.</param> /// <param name="value">The value of the property.</param> /// <returns>True if an DateTime value with the given key was found.</returns> public static Boolean TryGetCustomPropertyDateTime(this ICustomPropertyHolder holder, String key, out DateTime value) { String v = holder.GetCustomPropertyString(key); DateTime output; if (DateTime.TryParse(v, out value)) { value = new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second, value.Millisecond, DateTimeKind.Utc); return(true); } return(false); }
/// <summary> /// Method for trying to get an Int32 value from the custom properties. /// </summary> /// <param name="holder">The property holder.</param> /// <param name="key">The key of the property.</param> /// <param name="value">The value of the property.</param> /// <returns>True if an Int32 value with the given key was found.</returns> public static Boolean TryGetCustomPropertyInt32(this ICustomPropertyHolder holder, String key, out Int32 value) { String v = holder.GetCustomPropertyString(key); return(Int32.TryParse(v, out value)); }