Ejemplo n.º 1
0
        private static CancelAcion ReadCancelAction(FSMXmlReader reader)
        {
            CancelAcion cancelAction = new CancelAcion();

            cancelAction.Event = reader.ReadAttributeValue <string>("event");
            return(cancelAction);
        }
Ejemplo n.º 2
0
        private static LogAcion ReadLogAction(FSMXmlReader reader)
        {
            LogAcion logAction = new LogAcion();

            logAction.Type      = reader.ReadAttributeValue <string>("type", null);
            logAction.Message   = reader.ReadAttributeValue <string>("msg", null);
            logAction.Format    = reader.ReadAttributeValue <string>("format", null);
            logAction.Arguments = reader.ReadChildExpressions().ToArray();
            return(logAction);
        }
Ejemplo n.º 3
0
        private static AssignAction ReadAssignAction(FSMXmlReader reader)
        {
            AssignAction act = new AssignAction();

            act.Name = reader.ReadAttributeValue <string>("name");
            act.Expr = reader.ReadChildExpressions().FirstOrDefault();
            if (act.Expr == null)
            {
                act.Value = reader.ReadAttributeValue <string>("value");
            }
            return(act);
        }
Ejemplo n.º 4
0
        private static ExpressionAction ReadExpressionAction(FSMXmlReader reader)
        {
            ExpressionAction action = new ExpressionAction();

            if (reader.CurrentNode.ChildNodes.Count == 0)
            {
                action.Expr = reader.ReadExpressionByAttribute("expr", false);
            }
            else
            {
                action.Expr = reader.ReadExpression(true);
            }
            return(action);
        }
Ejemplo n.º 5
0
        //private void ReadIfAction(IfAcion ifAction)
        //{

        //}

        private static IfAcion ReadIfAction(FSMXmlReader reader)
        {
            IfAcion ifAction = new IfAcion();
            var     node     = reader.CurrentNode;
            var     condNode = node.SelectSingleNode("s:cond", reader.nsmgr);

            if (condNode != null)
            {
                reader.ReadStartNode(condNode);
                ifAction.Cond = reader.ReadFirstChildExpression();
                reader.ReadEndNode();
            }
            var thenNode = node.SelectSingleNode("s:then", reader.nsmgr);

            if (thenNode != null)
            {
                reader.ReadStartNode(thenNode);
                reader.ReadActions(reader.FilterChildNodeType(), ifAction);
                reader.ReadEndNode();
            }


            //ReadIfAction(ifAction);

            foreach (XmlNode elseIfNode in node.SelectNodes("s:elseIf", reader.nsmgr))
            {
                reader.ReadStartNode(elseIfNode);
                //IfAcion elseIfAction = new IfAcion();
                //ReadIfAction(elseIfAction);
                IfAcion elseIfAction = ReadIfAction(reader);
                ifAction.AddElseIf(elseIfAction);
                reader.ReadEndNode();
            }
            var elseNode = node.SelectSingleNode("s:else", reader.nsmgr);

            if (elseNode != null)
            {
                reader.ReadStartNode(elseNode);
                ActionsContainer elseAction = new ActionsContainer();
                reader.ReadActions(reader.FilterChildNodeType(), elseAction);
                ifAction.Else = elseAction;
                reader.ReadEndNode();
            }
            return(ifAction);
        }
Ejemplo n.º 6
0
        private static RaiseAction ReadRaiseAction(FSMXmlReader reader)
        {
            RaiseAction raise = new RaiseAction();

            raise.Event = reader.ReadAttributeValue <string>("event");

            foreach (var child in reader.FilterChildNodeType(FSMNamespace))
            {
                reader.ReadStartNode(child);
                switch (child.LocalName)
                {
                case "data":
                    raise.DataExpr = reader.ReadFirstChildExpression(null);
                    break;
                }
                reader.ReadEndNode();
            }

            return(raise);
        }
Ejemplo n.º 7
0
        private static ForeachAcion ReadForeachAction(FSMXmlReader reader)
        {
            ForeachAcion foreachAction = new ForeachAcion();

            var childs    = reader.FilterChildNodeType();
            var itemsNode = childs.FirstOrDefault();

            if (itemsNode.LocalName == "items")
            {
                reader.ReadStartNode(itemsNode);
                foreachAction.Items = reader.ReadFirstChildExpression();
                reader.ReadEndNode();
            }
            else
            {
                throw new FSMReadException("Not Child Node items", reader.CurrentNode);
            }
            reader.PushScope();
            reader.context.AddParameter(typeof(int), "index");
            reader.context.AddParameter(typeof(object), "item");
            reader.ReadActions(childs.Skip(1), foreachAction);
            reader.PopScope();
            return(foreachAction);
        }