private static Expression ReadIf(XmlExpressionReader reader)
        {
            Expression ifFalse = null;

            var elseNode = reader.Node.SelectSingleNode("x:else", reader.nsmgr);

            if (elseNode != null)
            {
                var child = FilterChildNodeTypes(elseNode).FirstOrDefault();
                if (child != null)
                {
                    reader.ReadStartExpression(child);
                    ifFalse = reader.ReadExpression();
                    reader.ReadEndExpression();
                }
            }

            return(ReadIf(reader, ifFalse));
        }
        private static Expression ReadSwitch(XmlExpressionReader reader)
        {
            var childs = reader.FilterChildNodeTypes();
            var first  = childs.FirstOrDefault();

            if (first == null)
            {
                throw new MissingNodeException(Resource1.Read_NotTestValueNode, reader.Node, null);
            }
            Expression testValue;

            Expression defaultBody = null;

            reader.ReadStartExpression(first);
            testValue = reader.ReadExpression();
            reader.ReadEndExpression();

            List <SwitchCase> cases = new List <SwitchCase>();

            foreach (XmlNode child in childs.Skip(1))
            {
                if (child.LocalName == "case")
                {
                    reader.ReadStartExpression(child);
                    var exprs = reader.ReadChildExpressions();

                    if (exprs == null || exprs.Length == 0)
                    {
                        throw new MissingNodeException(Resource1.Read_NotTestValueNode, child, null);
                    }
                    if (exprs.Length < 2)
                    {
                        throw new NotBodyNodeException(child);
                    }

                    var        testValues = exprs.Take(exprs.Length - 1);
                    var        body       = exprs.Last();
                    SwitchCase sc         = new SwitchCase(testValues, body);
                    cases.Add(sc);

                    reader.ReadEndExpression();
                }
                else if (child.LocalName == "default")
                {
                    reader.ReadStartExpression(child);
                    var exprs = reader.ReadChildExpressions();
                    if (exprs == null || exprs.Length == 0)
                    {
                        throw new NotBodyNodeException(child);
                    }
                    if (defaultBody != null)
                    {
                        throw new DuplicateNodeException(child);
                    }
                    defaultBody = exprs.First();
                    reader.ReadEndExpression();
                }
            }

            return(Switch(testValue, defaultBody, cases));
        }