Exemplo n.º 1
0
 public static string[] Split(string s, string separator, MyStringSplitOptions options)
 {
     if (!IsEmpty(s))
     {
         return(s.Split(separator, options));
     }
     else
     {
         return new string[] { }
     };
 }
Exemplo n.º 2
0
 public static string[] Split(string s, char ch, MyStringSplitOptions options)
 {
     if (!IsEmpty(s))
     {
         return(s.Split(ch, options));
     }
     else
     {
         return new string[] { }
     };
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
        }