System.Xml.Xsl.Runtime.XsltFunctions.EXslObjectType C# (CSharp) Method

EXslObjectType() public static method

public static EXslObjectType ( IList value ) : string
value IList
return string
        public static string EXslObjectType(IList<XPathItem> value)
        {
            if (value.Count != 1)
            {
                XsltLibrary.CheckXsltValue(value);
                return "node-set";
            }

            XPathItem item = value[0];
            if (item is RtfNavigator)
            {
                return "RTF";
            }
            else if (item.IsNode)
            {
                Debug.Assert(item is XPathNavigator);
                return "node-set";
            }

            object o = item.TypedValue;
            if (o is string)
            {
                return "string";
            }
            else if (o is double)
            {
                return "number";
            }
            else if (o is bool)
            {
                return "boolean";
            }
            else
            {
                Debug.Fail("Unexpected type: " + o.GetType().ToString());
                return "external";
            }
        }

Usage Example

Exemplo n.º 1
0
        internal static void CheckXsltValue(IList <XPathItem> val)
        {
            // IsDocOrderDistinct is not always set to true even if the node-set is ordered
            // Debug.Assert(val.Count <= 1 || val.IsDocOrderDistinct, "All node-sets must be ordered");

            if (val.Count == 1)
            {
                XsltFunctions.EXslObjectType(val);
            }
            else
            {
                // Every item must be a node, but for performance reasons we check only
                // the first two and the last two items
                int count = val.Count;
                for (int idx = 0; idx < count; idx++)
                {
                    if (!val[idx].IsNode)
                    {
                        Debug.Fail("Invalid XSLT value");
                        break;
                    }
                    if (idx == 1)
                    {
                        idx += Math.Max(count - 4, 0);
                    }
                }
            }
        }