internal static string ObjectToString(this object setting)
 {
     return setting?.ToString() ?? string.Empty;
 }
 /// <summary>
 /// Verfiy if DateTime is not null and converts the value of the current System.DateTime object to its equivalent short date string representation.
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns>A string that contains the short date string representation of the current</returns>
 public static string ToShortDateString(this DateTime? dateTime)
 {
     return dateTime?.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dateTime"></param>
 /// <param name="format"></param>
 /// <returns></returns>
 public static string ToString(this DateTime? dateTime, string format = null)
 {
     return dateTime?.ToString(format);
 }
 public static string ToStringOrNull(this Uri uri)
 {
     return uri?.ToString();
 }
Example #5
0
		/// <summary>
		///     Returns <paramref name="path" />.ToString() is path is null, else returns the empty string.
		/// </summary>
		/// <param name="path">The path reference.</param>
		public static string ToStringOrIfNullToEmptyString(this IPath path)
		{
			return path?.ToString() ?? string.Empty;
		}
 /// <exclude/>
 public static string ToLowerString(this object value)
     => value?.ToString().ToLower();
 public static string ToStringDef(this object obj, string nullValueString)
 {
     return obj?.ToString() ?? nullValueString;
 }
Example #8
0
 public static string ToStringCtx(this object o, IShellContext context)
 {
     var elem = o as ElementBase;
     if (elem != null) return elem.ToStringCtx(context);
     return o?.ToString();
 }
Example #9
0
 public static string Empty(this object data)
 {
     var s = data?.ToString();
     return string.IsNullOrWhiteSpace(s) ? string.Empty : s;
 }
Example #10
0
 public static string NaIfEmpty(this object data)
 {
     var s = data?.ToString();
     return string.IsNullOrWhiteSpace(s) ? Constants.No_Value : s;
 }
Example #11
0
 public static string DashIfEmpty(this object data)
 {
     var s = data?.ToString();
     return (string.IsNullOrWhiteSpace(s) || s == Constants.No_Value) ? Constants.No_Data : s;
 }
 public static string NullableDateTimeToString(this DateTime? dateTime)
 {
     return dateTime?.ToString("G") ?? string.Empty;
 }