Ejemplo n.º 1
0
        } //outputs2Class()

        private string OutputToCode(string text)
        {
            if (text == null)
                return "";

            var sb = new StringBuilder();
            string code;
            //break the text apart into text and code sections
            //test needs to be written to Console.Out
            //and code needs to be written as is
            while (text != "")
            {
                var openTagPos = text.IndexOf(openTag, StringComparison.Ordinal);
                while (openTagPos != -1 && TextToolbox.IsEscaped(text, openTagPos))
                {
                    text = text.Remove(openTagPos - 1, 1);
                    openTagPos = text.IndexOf(openTag, openTagPos, StringComparison.Ordinal);
                }

                if (openTagPos != 0) //we have uncode to process
                {
                    string uncode;
                    if (openTagPos == -1) //it's all uncode
                    {
                        uncode = text;
                        text = "";
                    }
                    else //it's uncode + code
                    {
                        uncode = text.Substring(0, openTagPos);
                        text = text.Substring(openTagPos);
                    }

                    sb.Append("Console.Write(\"");
                    sb.Append(escape(uncode));
                    sb.Append("\");\r\n");
                }
                else //we have code to process (open is at the beginning)
                {
                    var closeTagPos = text.IndexOf(closeTag, StringComparison.Ordinal);
                    while (closeTagPos != -1 && TextToolbox.IsEscaped(text, closeTagPos))
                    {
                        text = text.Remove(closeTagPos - 1, 1);
                        closeTagPos = text.IndexOf(closeTag, closeTagPos, StringComparison.Ordinal);
                    }

                    if (closeTagPos == -1)
                        closeTagPos = text.Length;
                    code = text.Substring(openTag.Length, closeTagPos - openTag.Length).Trim();
                    if (code != "")
                        sb.Append(code);
                    if (closeTagPos + closeTag.Length < text.Length)
                        text = text.Substring(closeTagPos + closeTag.Length);
                    else
                        text = "";
                }
            } //while(text != "")

            return sb.ToString();
        } //outputToCode(string text)
Ejemplo n.º 2
0
 public string GetNewRuleId()
 {
     return TextToolbox.GetNewId();
 }
Ejemplo n.º 3
0
        /*
         * Accessor Methods
         */

        public string GetNewSynoymId()
        {
            return TextToolbox.GetNewId();
        }