示例#1
0
    public static TextTable Parse(TextReader reader)
    {
        TextTable table = new TextTable();

        if (regularExpressionParser == null)
        {
            loadRegEx();
        }

        string tableString = reader.ReadToEnd();

        MatchCollection matches = regularExpressionParser.Matches(tableString);

        foreach (Match m in matches)
        {
            if (!m.Success)
            {
                string logError = "Error: Could not parse string in file matching \"" + m.Value + "\"";
                Debug.LogError(logError);
                return(null);
            }

            string key   = m.Groups["tag"].Value;
            Group  group = m.Groups["text"];

            string s = "";
            foreach (Capture c in group.Captures)
            {
                s += c.Value + "\n";
            }

            if (s.Length > 0)
            {
                s = s.Substring(0, s.Length - 1);
            }

            table.AddEntry(key, s);
        }

        return(table);
    }
示例#2
0
    public static TextTable Parse(TextReader reader)
    {
        TextTable table = new TextTable();

        if (regularExpressionParser == null)
            loadRegEx ();

        string tableString = reader.ReadToEnd ();

        MatchCollection matches = regularExpressionParser.Matches (tableString);

        foreach (Match m in matches)
        {
            if(!m.Success)
            {
                string logError = "Error: Could not parse string in file matching \"" + m.Value + "\"";
                Debug.LogError(logError);
                return null;
            }

            string key = m.Groups["tag"].Value;
            Group group = m.Groups["text"];

            string s = "";
            foreach(Capture c in group.Captures)
            {
                s += c.Value + "\n";
            }

            if(s.Length > 0)
                s = s.Substring(0, s.Length - 1);

            table.AddEntry(key, s);
        }

        return table;
    }