Esempio n. 1
0
        private static IControlBlock ParseDFGBreaker(XmlNode node, DFG <Block> dfg, ParserInfo parserInfo)
        {
            string id        = node.GetAttributeValue(Block.ID_FIELD_NAME);
            string blockType = node.Attributes[Block.TYPE_FIELD_NAME].Value;

            switch (blockType)
            {
            case If.XML_TYPE_NAME:
                return(new If(node, dfg, parserInfo));

            case Repeat.XML_TYPE_NAME:
                return(new Repeat(node, dfg, parserInfo));

            case While.XML_TYPE_NAME:
                return(new While(node, dfg, parserInfo));

            case InlineProgram.XML_TYPE_NAME:
                InlineProgram program = ProgramCache.GetProgram(node, id, parserInfo);
                if (!program.IsValidProgram)
                {
                    parserInfo.ParseExceptions.Add(new ParseException(id, "There is program errors in the program: " + program.ProgramName));
                    return(null);
                }
                return(program.GetProgram(node, parserInfo));

            default:
                throw new UnknownBlockException(id);
            }
        }