Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }