Пример #1
0
 protected override string ProcessChange()
 {
     if (this.templateNode.Name.ToLower() == "person")
     {
         if (this.templateNode.InnerText.Length > 0)
         {
             // non atomic version of the node
             return(ApplySubstitutions.Substitute(this.Bot, this.Bot.PersonSubstitutions, this.templateNode.InnerText));
         }
         else
         {
             // atomic version of the node
             XmlNode starNode      = GetNode("<star/>");
             StarTag recursiveStar = new StarTag(this.Bot, this.User, this.Request, this.Result, starNode);
             this.templateNode.InnerText = recursiveStar.Transform();
             if (this.templateNode.InnerText.Length > 0)
             {
                 return(this.ProcessChange());
             }
             else
             {
                 return(string.Empty);
             }
         }
     }
     return(string.Empty);
 }
Пример #2
0
        protected override string ProcessChange()
        {
            if (this.templateNode.Name.ToLower() == "sentence")
            {
                if (this.templateNode.InnerText.Length > 0)
                {
                    StringBuilder result   = new StringBuilder();
                    char[]        letters  = this.templateNode.InnerText.Trim().ToCharArray();
                    bool          doChange = true;
                    for (int i = 0; i < letters.Length; i++)
                    {
                        string letterAsString = Convert.ToString(letters[i]);
                        if (this.Bot.Splitters.Contains(letterAsString))
                        {
                            doChange = true;
                        }

                        Regex lowercaseLetter = new Regex("[a-zA-Z]");

                        if (lowercaseLetter.IsMatch(letterAsString))
                        {
                            if (doChange)
                            {
                                result.Append(letterAsString.ToUpper(this.Bot.Locale));
                                doChange = false;
                            }
                            else
                            {
                                result.Append(letterAsString.ToLower(this.Bot.Locale));
                            }
                        }
                        else
                        {
                            result.Append(letterAsString);
                        }
                    }
                    return(result.ToString());
                }
                else
                {
                    // atomic version of the node
                    XmlNode starNode      = GetNode("<star/>");
                    StarTag recursiveStar = new StarTag(this.Bot, this.User, this.Request, this.Result, starNode);
                    this.templateNode.InnerText = recursiveStar.Transform();
                    if (this.templateNode.InnerText.Length > 0)
                    {
                        return(this.ProcessChange());
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
            }

            return(string.Empty);
        }
Пример #3
0
        protected override string ProcessChange()
        {
            if (this.templateNode.Name.ToLower() == "sr")
            {
                XmlNode starNode = GetNode("<star/>");
                StarTag recursiveStar = new StarTag(this.Bot, this.User, this.Request, this.Result, starNode);
                string starContent = recursiveStar.Transform();

                XmlNode sraiNode = GetNode("<srai>"+starContent+"</srai>");
                SraiTag sraiHandler = new SraiTag(this.Bot, this.User, this.Request, this.Result, sraiNode);
                return sraiHandler.Transform();
            }
            return string.Empty;
        }