예제 #1
0
 Int32 Find(GString f, Int32 Position, CaseOption c)
 {
     if (c == G.GString.CaseOption.CASE_INSENSITIVE)
     {
         String temp = this._str;
         temp = temp.ToLower();
         String fin = f._str.ToLower();
         return(temp.IndexOf(fin, (Int32)Position));
     }
     return(this._str.IndexOf(f._str, (Int32)Position));
 }
예제 #2
0
        public Boolean      Contain(GString s, CaseOption op)
        {
            if (op == CaseOption.CASE_SENSITIVE)
            {
                return(this._str.Contains(s._str));
            }
            String news = this._str.ToLower();

            s = s._str.ToLower();
            return(this._str.Contains(s._str));
        }
예제 #3
0
        public static string GenerateRandomText(int wordCount, CaseOption caseOption,
                                                NumberOption numberOption)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < wordCount; i++)
            {
                string thisWord = GetRandomWord(caseOption, numberOption);
                builder.Append(thisWord);
                builder.Append(GetPunctuation());
            }

            return(builder.ToString());
        }
예제 #4
0
        private static string GetRandomWord(CaseOption caseOption, NumberOption numberOption)
        {
            string word = _WordList[random.Next(0, _WordList.Count)];

            switch (numberOption)
            {
            case NumberOption.AllNumbers:
                word = ReplaceAllWithNumbers(word);
                break;

            case NumberOption.NumbersAsWords:
                int threshold   = random.Next(1, 50);
                int probability = random.Next(1, 100);
                if (probability < threshold)
                {
                    word = ReplaceAllWithNumbers(word);
                }
                break;

            case NumberOption.NumbersInWords:
                word = ReplaceSomeWithNumbers(word);
                break;
            }

            switch (caseOption)
            {
            case CaseOption.AllCaps:
                word = word.ToUpper();
                break;

            case CaseOption.LowerCase:
                word = word.ToLower();
                break;

            case CaseOption.TitleCase:
                TextInfo ti = new CultureInfo("en-US", false).TextInfo;
                word = ti.ToTitleCase(word);
                break;

            case CaseOption.RandomCase:
                word = RandomCase(word);
                break;
            }

            return(word);
        }
예제 #5
0
        private void Reload()
        {
            CaseOption caseOption = CaseOption.LowerCase;

            if (UpperCaseChecked)
            {
                caseOption = CaseOption.AllCaps;
            }
            if (LowerCaseChecked)
            {
                caseOption = CaseOption.LowerCase;
            }
            if (TitleCaseChecked)
            {
                caseOption = CaseOption.TitleCase;
            }
            if (RandomCaseChecked)
            {
                caseOption = CaseOption.RandomCase;
            }

            NumberOption numberOption = NumberOption.NumbersAsWords;

            if (AllNumbersChecked)
            {
                numberOption = NumberOption.AllNumbers;
            }
            if (NoNumbersChecked)
            {
                numberOption = NumberOption.NoNumbers;
            }
            if (NumbersInsideChecked)
            {
                numberOption = NumberOption.NumbersInWords;
            }
            if (NumbersReplaceChecked)
            {
                numberOption = NumberOption.NumbersAsWords;
            }

            RandomText = RandomWordGenerator.GenerateRandomText
                             (WordCount, caseOption, numberOption);
        }
        public static string ToSnakeCase(this string input, CaseOption caseOption)
        {
            if (string.IsNullOrEmpty(input))
            {
                return(input);
            }
            var         startUnderscores = Regex.Match(input, @"^_+");
            CultureInfo cultureInfo      = new CultureInfo("en-US");
            var         replacedText     = Regex.Replace(input, @"([a-zA-Z0-9])([A-Z])", "$1_$2");

            replacedText = Regex.Replace(replacedText, @"([a-zA-Z])([0-9A-Z])", "$1_$2");
            replacedText = Regex.Replace(replacedText, @"([A-Z])([0-9])", "$1_$2");
            if (caseOption == CaseOption.LowerCase)
            {
                replacedText = replacedText.ToLower(cultureInfo);
            }
            else if (caseOption == CaseOption.UpperCase)
            {
                replacedText = replacedText.ToUpper(cultureInfo);
            }

            return(startUnderscores + replacedText);
        }
예제 #7
0
        public GStringList  Split(GString f, SplitOption splitop, CaseOption caseop)
        {
            GStringList vect = new GStringList();

            if (this.Find(f, caseop) == -1)
            {
                vect.PushBack(this);
                return(vect);
            }
            int pos = 0, pos1 = 0, pos2 = 0;

            while (true)
            {
                pos1 = pos;
                pos  = this.Find(f, pos, caseop);
                if (pos == -1)
                {
                    break;
                }
                pos2 = pos;
                GString ne = this.Substr(pos1, pos2);
                if ((splitop == GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS)
                {
                    vect.PushBack(ne);
                }
                pos += f.Size;
            }
            if (pos1 != 0)
            {
                GString ne = new GString(this.Substr(pos1, this.Size));
                if ((splitop == G.GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS)
                {
                    vect.PushBack(ne);
                }
            }
            return(vect);
        }
예제 #8
0
        private void Button_Users(object sender, RoutedEventArgs e) //Dras til UserOptions. Kallas CaseOption..
        {
            CaseOption userOptions = new CaseOption();

            this.NavigationService.Navigate(userOptions);
        }
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            CaseOption userOptions = new CaseOption();

            this.NavigationService.Navigate(userOptions);
        }
예제 #10
0
 public GStringList Explode(GString f, SplitOption splitop, CaseOption caseop)
 {
     return(this.Split(f, splitop, caseop));
 }
예제 #11
0
 public GString Replace(GString Find, GString Rep, CaseOption op)
 {
     return(this._str.Replace(Find._str, Rep._str));
 }
예제 #12
0
 Int32 Find(GString f, Int32 Position, CaseOption c)
 {
     if (c == G.GString.CaseOption.CASE_INSENSITIVE)
     {
         String temp = this._str;
         temp = temp.ToLower();
         String fin = f._str.ToLower();
         return (temp.IndexOf(fin, (Int32)Position));
     }
     return (this._str.IndexOf(f._str, (Int32)Position));
 }
예제 #13
0
 public GStringList Split(GString f, SplitOption splitop , CaseOption caseop)
 {
     GStringList	vect = new GStringList();
     if (this.Find(f, caseop) == -1)
     {
         vect.PushBack(this);
         return (vect);
     }
     int pos = 0, pos1 = 0, pos2 = 0;
     while (true)
     {
         pos1 = pos;
         pos = this.Find(f, pos, caseop);
         if (pos == -1)
             break;
         pos2 = pos;
         GString ne = this.Substr(pos1, pos2);
         if ((splitop == GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS)
             vect.PushBack(ne);
         pos += f.Size;
     }
     if (pos1 != 0)
     {
         GString ne = new GString (this.Substr(pos1, this.Size));
         if ((splitop == G.GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS)
                 vect.PushBack(ne);
     }
     return (vect);
 }
예제 #14
0
 public GString Replace(GString Find, GString Rep, CaseOption op)
 {
     return (this._str.Replace(Find._str, Rep._str));
 }
예제 #15
0
 public GStringList Explode(GString f, SplitOption splitop, CaseOption caseop)
 {
     return (this.Split(f, splitop, caseop));
 }
예제 #16
0
 public Boolean Contain(GString s, CaseOption op)
 {
     if (op == CaseOption.CASE_SENSITIVE)
         return (this._str.Contains(s._str));
     String news = this._str.ToLower();
     s = s._str.ToLower();
     return (this._str.Contains(s._str));
 }