Esempio n. 1
0
                public T parse <T>(string[] lines, ParserDefinition.Base ParserDefinition, Factory.Base Factory) where T : Model.Base
                {
                    T Model = Factory.getModel <T>();

                    bool hasOpenTag  = false;
                    bool hasCloseTag = false;

                    for (int i = 0; !hasCloseTag && i < lines.Length; i++)
                    {
                        string line = lines[i];
                        if (hasOpenTag && ParserDefinition.isCommentTag(line))
                        {
                            parseCommentTag <T>(ref Model, ParserDefinition.getMatchesCommentTag(line));
                        }
                        else if (!hasOpenTag && ParserDefinition.isOpenTag(line))
                        {
                            parseOpenTag <T>(ref Model, ParserDefinition.getMatchesOpenTag(line));
                            hasOpenTag = true;
                        }
                        else if (hasOpenTag && ParserDefinition.isLineTag(line))
                        {
                            parseLineTag <T>(ref Model, ParserDefinition.getMatchesLineTag(line));
                        }
                        else if (hasOpenTag && ParserDefinition.isCloseTag(line))
                        {
                            parseCloseTag <T>(ref Model, ParserDefinition.getMatchesCloseTag(line));
                            hasCloseTag = true;
                        }
                        else
                        {
                            throw new ArgumentException("unable to parse line " + i.ToString(), "string[] line");
                        }
                    }

                    return(Model as T);
                }
Esempio n. 2
0
 public T parse <T>(string line, ParserDefinition.Base ParserDefinition, Factory.Base Factory) where T : Model.Base
 {
     string[] lines = ParserDefinition.getLines(line);
     return(parse <T>(lines, ParserDefinition, Factory));
 }