Пример #1
0
 public static string[] Split(string s, string separator, MyStringSplitOptions options)
 {
     if (!IsEmpty(s))
     {
         return(s.Split(separator, options));
     }
     else
     {
         return new string[] { }
     };
 }
Пример #2
0
 public static string[] Split(string s, char ch, MyStringSplitOptions options)
 {
     if (!IsEmpty(s))
     {
         return(s.Split(ch, options));
     }
     else
     {
         return new string[] { }
     };
 }
Пример #3
0
        public static string[] Split(this string s, char ch, MyStringSplitOptions options)
        {
            var result = new string[] { };

            switch (options)
            {
            case MyStringSplitOptions.None:
                result = s.Split(new char[] { ch }, StringSplitOptions.None);
                break;

            case MyStringSplitOptions.RemoveEmptyEntries:
                result = s.Split(new char[] { ch }, StringSplitOptions.RemoveEmptyEntries);
                break;

            case MyStringSplitOptions.TrimEntries:
                result = s.Split(ch, x => x.Trim());
                break;

            case MyStringSplitOptions.TrimAndRemoveEmptyEntries:
                result = s.Split(ch, x => x.Trim(), true);
                break;

            case MyStringSplitOptions.ToLowerEntries:
                result = s.Split(ch, x => x.ToLower());
                break;

            case MyStringSplitOptions.ToUpperEntries:
                result = s.Split(ch, x => x.ToUpper());
                break;

            case MyStringSplitOptions.TrimToLowerAndRemoveEmptyEntries:
                result = s.Split(ch, x => x.Trim().ToLower(), true);
                break;

            case MyStringSplitOptions.TrimToUpperAndRemoveEmptyEntries:
                result = s.Split(ch, x => x.Trim().ToUpper(), true);
                break;

            case MyStringSplitOptions.ToLowerAndRemoveEmptyEntries:
                result = s.Split(ch, x => x.ToLower(), true);
                break;

            case MyStringSplitOptions.ToUpperAndRemoveEmptyEntries:
                result = s.Split(ch, x => x.ToUpper(), true);
                break;
            }

            return(result);
        }
Пример #4
0
        public static bool NotIn(this string s, string values, CultureInfo culture, CompareOptions compareOptions, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
        {
            var arr = values?.Split(separator, options) ?? new string[] { };

            return(s.NotIn(arr, culture, compareOptions));
        }
Пример #5
0
        public static bool NotIn(this string s, string values, bool ignoreCase, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
        {
            var arr = values?.Split(separator, options) ?? new string[] { };

            return(s.NotIn(arr, ignoreCase));
        }
Пример #6
0
 public static string SelectOf(this string s, string values, string defaultValue, CultureInfo culture, CompareOptions compareOptions, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
 {
     return(s.In(values, culture, compareOptions, separator, options) ? s : defaultValue);
 }
Пример #7
0
 public static string SelectOf(this string s, string values, string defaultValue, bool ignoreCase, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
 {
     return(s.In(values, ignoreCase, separator, options) ? s : defaultValue);
 }
Пример #8
0
 public static string SelectOf(this string s, string values, string defaultValue, StringComparison comparisonType, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
 {
     return(s.In(values, comparisonType, separator, options) ? s : defaultValue);
 }
Пример #9
0
        public static bool In(this string s, string values, StringComparison comparisonType, char separator, MyStringSplitOptions options = MyStringSplitOptions.TrimAndRemoveEmptyEntries)
        {
            var arr = values?.Split(separator, options) ?? new string[] { };

            return(s.In(arr, comparisonType));
        }