XPathResultType定义错误?定义、错误、XPathResultType

2023-09-06 14:04:03 作者:她与星河皆失

XPathResultType 枚举在.NET框架的定义给出了相同的值(1)以字符串,因为它没有导航。当然,这不可能是正确的?是什么给了?

我实施一些自定义的XPath函数,而且我想写一个方法来验证我的功能基础上每个参数的声明XPathResultType的参数。不过,我很为难,如何我应该迎合这种重叠...

 #地区大会system.xml.dll的,v4.0.30319
// C:\ Program Files文件\参考大会\微软\框架\ .NETFramework \ V4.0 \档案\客户端\ system.xml.dll的
#endregion

使用系统;

命名空间System.Xml.XPath
{
    // 概要:
    //指定的XPath的前pression的返回类型。
    公共枚举XPathResultType
    {
        // 概要:
        //一个数值。
        号= 0,
        //
        // 概要:
        //以System.String值。
        串= 1,
        //
        // 概要:
        //一个树片段。
        导航= 1,
        //
        // 概要:
        //一个System.Booleantrue或假值。
        布尔= 2,
        //
        // 概要:
        //一个节点集合。
        NodeSet中= 3,
        //
        // 概要:
        //任何的XPath的节点类型。
        任何= 5,
        //
        // 概要:
        //这位前pression不计算为正确的XPath类型。
        错误= 6,
    }
}
 

解决方案

目前在Microsoft Connect上一个封闭的问题:https://connect.microsoft.com/VisualStudio/feedback/details/97578/both-xpathresulttype-string-and-xpathresulttype-navigator-are-1

这是微软答:

  

重叠枚举值是一个已知的问题。解决方法是   从来不使用 XPathResultType.Navigator 的价值和总是使用    XPathResultType.NodeSet

运行时错误 1004 应用程序定义或对象定义错误

The definition of the XPathResultType enumeration in the .NET framework gives the same value (1) to "String" as it does to "Navigator". Surely that can't be right? What gives?

I'm implementing some custom XPath function, and I'm trying to write a single method to validate the arguments of my functions based on the declared XPathResultType of each argument. However, I'm stumped as to how I'm supposed to cater for this overlap...

#region Assembly System.Xml.dll, v4.0.30319
// C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Xml.dll
#endregion

using System;

namespace System.Xml.XPath
{
    // Summary:
    //     Specifies the return type of the XPath expression.
    public enum XPathResultType
    {
        // Summary:
        //     A numeric value.
        Number = 0,
        //
        // Summary:
        //     A System.String value.
        String = 1,
        //
        // Summary:
        //     A tree fragment.
        Navigator = 1,
        //
        // Summary:
        //     A System.Booleantrue or false value.
        Boolean = 2,
        //
        // Summary:
        //     A node collection.
        NodeSet = 3,
        //
        // Summary:
        //     Any of the XPath node types.
        Any = 5,
        //
        // Summary:
        //     The expression does not evaluate to the correct XPath type.
        Error = 6,
    }
}

解决方案

There is a closed issue on Microsoft Connect: https://connect.microsoft.com/VisualStudio/feedback/details/97578/both-xpathresulttype-string-and-xpathresulttype-navigator-are-1

Answer from Microsoft:

The overlapping enum values is a known issue. The workaround is to never use the XPathResultType.Navigator value and to always use XPathResultType.NodeSet.