public static string Format <T>(this object obj, string format) { string result = string.Empty; if (obj != null && !Convert.IsDBNull(obj)) { result = SString.Format( $"{{0:{format}}}", (obj is T ? obj : ConvertAs <T>(obj)) ); } return(result); }
public static bool Equals <T>(this T value, T otherValue) { if (value is string) { return(SString.Equals(value as string, otherValue as string)); } if (IsNullInList(value, otherValue)) { return(false); } return(value.Equals(otherValue)); }
public static bool IsValueInListParallel <T>(this T value, IEnumerable <T> checkList) { if (value is string) { return(SString.IsStringInListParallel(value as string, checkList as IEnumerable <string>)); } if (IsNullInList(value, checkList)) { return(false); } return(checkList.AsParallel().Contains(value)); }
public static bool IsValueInAllEqualParallel <T>(this T value, IEnumerable <T> checkList) { if (value is string) { return(SString.IsStringInAllEqualParallel(value as string, checkList as IEnumerable <string>)); } if (IsNullInList(value, checkList)) { return(false); } return(checkList.AsParallel().All((checkListItem) => Equals <T>(value, checkListItem))); }
public static bool IsValueInList <T>(this T value, IEnumerable <T> checkList) { if (value is string) { return(SString.IsStringInList(value as string, checkList as IEnumerable <string>)); } if (IsNullInList(value, checkList)) { return(false); } foreach (T item in checkList) { if (Equals(value, item)) { return(true); } } return(false); }
public static bool IsValueInList <T>(this T value, params T[] checkList) { if (value is string) { return(SString.IsStringInList(value as string, checkList as string[])); } if (IsNullInList(value, checkList)) { return(false); } foreach (T item in checkList) { if (Equals(value, item)) { return(true); } } return(false); }