Exemple #1
0
        public static DebaterPattern Parse(string s)
        {
            if (s == null)
            {
                throw new ArgumentNullException();
            }


            var parts = s.Split(';');
            var ret   = new DebaterPattern();

            foreach (string p in parts)
            {
                var tmp = p.Trim();
                if (tmp.StartsWith("@", StringComparison.Ordinal))
                {
                    Club.Parse(tmp.Substring(1)).Do(
                        club => ret.AddClub(club.Name));
                }
                else if (tmp != "")
                {
                    Name.Parse(tmp).Do(ret.AddDebater);
                }
                // TODO The above swallows errors if Club.Parse() or
                // Name.Parse() fail.
            }

            return(ret);
        }
Exemple #2
0
        public void ParsePattern(string s)
        {
            if (s == null)
            {
                throw new ArgumentNullException();
            }
            string[]      parts        = s.Split(';');
            List <string> tmpClubNames = new List <string>();
            List <Name>   tmpDebaters  = new List <Name>();

            foreach (string p in parts)
            {
                string tmp = p.Trim();
                if (tmp.StartsWith("@"))
                {
                    string   club = tmp.Substring(1);
                    string[] c    = Club.Parse(club);
                    if (!tmpClubNames.Contains(c[0]))
                    {
                        tmpClubNames.Add(c[0]);
                    }
                }
                else if (tmp != "")
                {
                    string[] n    = Name.Parse(tmp);
                    Name     name = new Name(n[0], n[1]);
                    if (!tmpDebaters.Contains(name))
                    {
                        tmpDebaters.Add(name);
                    }
                }
            }

            clubNames = tmpClubNames;
            debaters  = tmpDebaters;
        }