System.Xml.Xsl.Runtime.XsltLibrary.CheckXsltValue C# (CSharp) Method

CheckXsltValue() private method

private CheckXsltValue ( IList val ) : void
val IList
return void
        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);
                    }
                }
            }
        }

Same methods

XsltLibrary::CheckXsltValue ( XPathItem item ) : void

Usage Example

Beispiel #1
0
        public static double ToDouble(XPathItem item)
        {
            XsltLibrary.CheckXsltValue(item);

            if (item.IsNode)
            {
                return(XPathConvert.StringToDouble(item.Value));
            }

            Type itemType = item.ValueType;

            if (itemType == StringType)
            {
                return(XPathConvert.StringToDouble(item.Value));
            }
            else if (itemType == DoubleType)
            {
                return(item.ValueAsDouble);
            }
            else
            {
                Debug.Assert(itemType == BooleanType, $"Unexpected type of atomic sequence {itemType}");
                return(item.ValueAsBoolean ? 1d : 0d);
            }
        }
All Usage Examples Of System.Xml.Xsl.Runtime.XsltLibrary::CheckXsltValue