コード例 #1
0
 /// <summary>
 /// General purpous HasNext method that returns based on the Patten paramiter
 /// </summary>
 /// <param name="patten"></param>
 /// <returns></returns>
 private bool HasNext(Patten patten)
 {
     if (_current_active_patten.Equals(patten))
     {
         return(_next_match.Success);
     }
     else
     {
         return(new Regex(patten.ToString(),
                          RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(_working_string).Success);
     }
 }
コード例 #2
0
        // Constructors

        // Methods

        /// <summary>
        /// This method is used by the constructor in the set up phase and also
        /// when a next call is made for a different patten that the one
        /// currently in use
        /// </summary>
        /// <param name="inputString">
        /// Ether the inital string or a copy of the
        /// working string
        /// </param>
        /// <param name="patten">The desired patten to be used</param>
        protected void SetMatchs(string inputString, Patten patten)
        {
            Regex rx = new Regex(patten.ToString(),
                                 RegexOptions.Compiled | RegexOptions.IgnoreCase);

            _current_match = rx.Match(inputString);

            if (!_current_match.Success)
            {
                throw new NoMatchFoundException();
            }

            _next_match            = _current_match.NextMatch();
            _current_active_patten = patten;
        }
コード例 #3
0
 /// <summary>
 /// General perpous next method use to contain repeated code
 /// </summary>
 /// <param name="patten">Patten of what you would like returned</param>
 /// <param name="name">Name of the regex variable</param>
 /// <returns>String version of the match made by the regex</returns>
 private string Next(Patten patten, string name)
 {
     if (_current_active_patten.Equals(patten))
     {
         if (_current_match.Success == true)
         {
             return(GetMatch(name));
         }
         else
         {
             throw new NoMoreDataException("There is no more lines left to return");
         }
     }
     else
     {
         SwitchMatchs(patten);
         return(Next(patten, name));
     }
 }
コード例 #4
0
 /// <summary>
 /// Swaps the current match patten and updates the current match and
 /// next match. Should only be used when nessisary.
 /// </summary>
 /// <param name="patten">Desired patten</param>
 private void SwitchMatchs(Patten patten)
 {
     SetMatchs(_working_string, patten);
 }