当前位置: 首页>>代码示例>>C#>>正文


C# XPathNodeType.ToString方法代码示例

本文整理汇总了C#中XPathNodeType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNodeType.ToString方法的具体用法?C# XPathNodeType.ToString怎么用?C# XPathNodeType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XPathNodeType的用法示例。


在下文中一共展示了XPathNodeType.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateNameInternal

        /// <summary>
        /// Return false or throw if the specified name parts are not valid according to the rules of "nodeKind".  Check only rules
        /// that are specified by the Flags.
        /// NOTE: Namespaces should be passed using a prefix, ns pair.  "localName" is always string.Empty.
        /// </summary>
        private static bool ValidateNameInternal(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags, bool throwOnError)
        {
            Debug.Assert(prefix != null && localName != null && ns != null);

            if ((flags & Flags.NCNames) != 0)
            {
                // 1. Verify that each non-empty prefix and localName is a valid NCName
                if (prefix.Length != 0)
                    if (!ParseNCNameInternal(prefix, throwOnError))
                    {
                        return false;
                    }

                if (localName.Length != 0)
                    if (!ParseNCNameInternal(localName, throwOnError))
                    {
                        return false;
                    }
            }

            if ((flags & Flags.CheckLocalName) != 0)
            {
                // 2. Determine whether the local name is valid
                switch (nodeKind)
                {
                    case XPathNodeType.Element:
                        // Elements and attributes must have a non-empty local name
                        if (localName.Length == 0)
                        {
                            if (throwOnError) throw new XmlException(SR.Xdom_Empty_LocalName, string.Empty);
                            return false;
                        }
                        break;

                    case XPathNodeType.Attribute:
                        // Attribute local name cannot be "xmlns" if namespace is empty
                        if (ns.Length == 0 && localName.Equals("xmlns"))
                        {
                            if (throwOnError) throw new XmlException(SR.XmlBadName, new string[] { nodeKind.ToString(), localName });
                            return false;
                        }
                        goto case XPathNodeType.Element;

                    case XPathNodeType.ProcessingInstruction:
                        // PI's local-name must be non-empty and cannot be 'xml' (case-insensitive)
                        if (localName.Length == 0 || (localName.Length == 3 && StartsWithXml(localName)))
                        {
                            if (throwOnError) throw new XmlException(SR.Xml_InvalidPIName, localName);
                            return false;
                        }
                        break;

                    default:
                        // All other node types must have empty local-name
                        if (localName.Length != 0)
                        {
                            if (throwOnError) throw new XmlException(SR.XmlNoNameAllowed, nodeKind.ToString());
                            return false;
                        }
                        break;
                }
            }

            if ((flags & Flags.CheckPrefixMapping) != 0)
            {
                // 3. Determine whether the prefix is valid
                switch (nodeKind)
                {
                    case XPathNodeType.Element:
                    case XPathNodeType.Attribute:
                    case XPathNodeType.Namespace:
                        if (ns.Length == 0)
                        {
                            // If namespace is empty, then prefix must be empty
                            if (prefix.Length != 0)
                            {
                                if (throwOnError) throw new XmlException(SR.Xml_PrefixForEmptyNs, string.Empty);
                                return false;
                            }
                        }
                        else
                        {
                            // Don't allow empty attribute prefix since namespace is non-empty
                            if (prefix.Length == 0 && nodeKind == XPathNodeType.Attribute)
                            {
                                if (throwOnError) throw new XmlException(SR.XmlBadName, new string[] { nodeKind.ToString(), localName });
                                return false;
                            }

                            if (prefix.Equals("xml"))
                            {
                                // xml prefix must be mapped to the xml namespace
                                if (!ns.Equals(XmlReservedNs.NsXml))
                                {
                                    if (throwOnError) throw new XmlException(SR.Xml_XmlPrefix, string.Empty);
//.........这里部分代码省略.........
开发者ID:geoffkizer,项目名称:corefx,代码行数:101,代码来源:ValidateNames.cs

示例2: ToString

		private static String ToString (XPathNodeType type)
		{
			switch (type) {
			case XPathNodeType.Comment:
				return "comment";
			case XPathNodeType.Text:
				return "text";
			case XPathNodeType.ProcessingInstruction:
				return "processing-instruction";
			case XPathNodeType.All:
			case XPathNodeType.Attribute:
			case XPathNodeType.Element:
			case XPathNodeType.Namespace:
				return "node";
			default:
				return "node-type [" + type.ToString () + "]";
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:18,代码来源:Expression.cs

示例3: ThrowInvalidStateError

        /// <summary>
        /// Throw an invalid state transition error.
        /// </summary>
        private void ThrowInvalidStateError(XPathNodeType constructorType) {
            switch (constructorType) {
                case XPathNodeType.Element:
                case XPathNodeType.Root:
                case XPathNodeType.Text:
                case XPathNodeType.Comment:
                case XPathNodeType.ProcessingInstruction:
                    throw new XslTransformException(Res.XmlIl_BadXmlState, new string[] {constructorType.ToString(), XmlStateToNodeType(this.xstate).ToString()});

                case XPathNodeType.Attribute:
                case XPathNodeType.Namespace:
                    if (this.depth == 1)
                        throw new XslTransformException(Res.XmlIl_BadXmlState, new string[] {constructorType.ToString(), this.rootType.ToString()});

                    if (this.xstate == XmlState.WithinContent)
                        throw new XslTransformException(Res.XmlIl_BadXmlStateAttr, string.Empty);

                    goto case XPathNodeType.Element;

                default:
                    throw new XslTransformException(Res.XmlIl_BadXmlState, new string[] {"Unknown", XmlStateToNodeType(this.xstate).ToString()});
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:26,代码来源:XmlQueryOutput.cs

示例4: ValidateNameInternal

        private static bool ValidateNameInternal(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags, bool throwOnError)
        {
            if ((flags & Flags.NCNames) != ((Flags) 0))
            {
                if ((prefix.Length != 0) && !ParseNCNameInternal(prefix, throwOnError))
                {
                    return false;
                }
                if ((localName.Length != 0) && !ParseNCNameInternal(localName, throwOnError))
                {
                    return false;
                }
            }
            if ((flags & Flags.CheckLocalName) != ((Flags) 0))
            {
                switch (nodeKind)
                {
                    case XPathNodeType.Element:
                        break;

                    case XPathNodeType.Attribute:
                        if ((ns.Length == 0) && localName.Equals("xmlns"))
                        {
                            if (throwOnError)
                            {
                                throw new XmlException("XmlBadName", new string[] { nodeKind.ToString(), localName });
                            }
                            return false;
                        }
                        break;

                    case XPathNodeType.ProcessingInstruction:
                        if ((localName.Length != 0) && ((localName.Length != 3) || !StartsWithXml(localName)))
                        {
                            goto Label_0102;
                        }
                        if (throwOnError)
                        {
                            throw new XmlException("Xml_InvalidPIName", localName);
                        }
                        return false;

                    default:
                        if (localName.Length != 0)
                        {
                            if (throwOnError)
                            {
                                throw new XmlException("XmlNoNameAllowed", nodeKind.ToString());
                            }
                            return false;
                        }
                        goto Label_0102;
                }
                if (localName.Length == 0)
                {
                    if (throwOnError)
                    {
                        throw new XmlException("Xdom_Empty_LocalName", string.Empty);
                    }
                    return false;
                }
            }
        Label_0102:
            if ((flags & Flags.CheckPrefixMapping) != ((Flags) 0))
            {
                switch (nodeKind)
                {
                    case XPathNodeType.Element:
                    case XPathNodeType.Attribute:
                    case XPathNodeType.Namespace:
                        if (ns.Length == 0)
                        {
                            if (prefix.Length != 0)
                            {
                                if (throwOnError)
                                {
                                    throw new XmlException("Xml_PrefixForEmptyNs", string.Empty);
                                }
                                return false;
                            }
                            goto Label_025E;
                        }
                        if ((prefix.Length == 0) && (nodeKind == XPathNodeType.Attribute))
                        {
                            if (throwOnError)
                            {
                                throw new XmlException("XmlBadName", new string[] { nodeKind.ToString(), localName });
                            }
                            return false;
                        }
                        if (prefix.Equals("xml"))
                        {
                            if (!ns.Equals("http://www.w3.org/XML/1998/namespace"))
                            {
                                if (throwOnError)
                                {
                                    throw new XmlException("Xml_XmlPrefix", string.Empty);
                                }
                                return false;
                            }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ValidateNames.cs


注:本文中的XPathNodeType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。