ConvertToType() public method

public ConvertToType ( XmlTypeCode requiredType, QilNode n ) : QilNode
requiredType XmlTypeCode
n QilNode
return QilNode
Exemplo n.º 1
0
        private QilNode CompareValues(XPathOperator op, QilNode left, QilNode right, XmlTypeCode compType)
        {
            Debug.Assert(compType == XmlTypeCode.Boolean || compType == XmlTypeCode.Double || compType == XmlTypeCode.String);
            Debug.Assert(compType == XmlTypeCode.Boolean || left.XmlType !.IsSingleton && right.XmlType !.IsSingleton, "Both comparison operands must be singletons");
            left  = _f.ConvertToType(compType, left);
            right = _f.ConvertToType(compType, right);

            switch (op)
            {
            case XPathOperator.Eq: return(_f.Eq(left, right));

            case XPathOperator.Ne: return(_f.Ne(left, right));

            case XPathOperator.Lt: return(_f.Lt(left, right));

            case XPathOperator.Le: return(_f.Le(left, right));

            case XPathOperator.Gt: return(_f.Gt(left, right));

            case XPathOperator.Ge: return(_f.Ge(left, right));

            default:
                Debug.Fail("Wrong operator type");
                return(null);
            }
        }
Exemplo n.º 2
0
            public void CastArguments(IList <QilNode> args, string name, XPathQilFactory f)
            {
                CheckArity(this.minArgs, this.maxArgs, name, args.Count);

                // Convert arguments to the appropriate types
                if (maxArgs == Infinity)
                {
                    // Special case for concat() function
                    for (int i = 0; i < args.Count; i++)
                    {
                        args[i] = f.ConvertToType(XmlTypeCode.String, args[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < args.Count; i++)
                    {
                        if (argTypes[i] == XmlTypeCode.Node && f.CannotBeNodeSet(args[i]))
                        {
                            throw new XPathCompileException(SR.XPath_NodeSetArgumentExpected, name, (i + 1).ToString(CultureInfo.InvariantCulture));
                        }
                        args[i] = f.ConvertToType(argTypes[i], args[i]);
                    }
                }
            }
Exemplo n.º 3
0
            public void CastArguments(IList <QilNode> args, string name, XPathQilFactory f)
            {
                CheckArity(this.minArgs, this.maxArgs, name, args.Count);

                // Convert arguments to the appropriate types
                if (maxArgs == Infinity)
                {
                    // Special case for concat() function
                    for (int i = 0; i < args.Count; i++)
                    {
                        args[i] = f.ConvertToType(XmlTypeCode.String, args[i]);
                    }
                }
                else
                {
                    Debug.Assert(args.Count == 0 || argTypes != null);
                    for (int i = 0; i < args.Count; i++)
                    {
                        if (argTypes ![i] == XmlTypeCode.Node && f.CannotBeNodeSet(args[i]))