Exemplo n.º 1
0
        public static QNode Normalizator3(QNode typedNode, Func <QNode, QNode> normalize)
        {
            var s = typedNode.AsString();

            switch (s)
            {
            case "not":
            {
                var childType = typedNode.C(1).C(0).P("type").QValue().AsString();
                if (childType != null)
                {
                    return(q.Q(typedNode.RawValue(), MetaType(childType, interType: childType), typedNode.C_s(1).OrEmpty().Select(child => normalize(child) ?? child)));
                }
            }
            break;

            case "::query":
            {
                var childType = typedNode.Nodes().LastOrDefault().C(0).P("type").QValue().AsString();
                if (childType != null)
                {
                    return(q.Q(typedNode.RawValue(), MetaType(childType, interType: childType), typedNode.C_s(1).OrEmpty().Select(child => normalize(child) ?? child)));
                }
            }
            break;

            case "and":
            {
                var childs = typedNode.C_s(1).OrEmpty().Select(child => normalize(child) ?? child).ToArray();
                if (childs.All(n => Is("set", n.C(0).P("type").QValue().AsString())))
                {
                    return(q.Q(typedNode.RawValue(), MetaType("set", interType: "set"), childs));
                }
            }
            break;
            }
            return(null);
        }