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


C# IXmlNamespaceResolver.LookupPrefix方法代码示例

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


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

示例1: QNameToString

        private static string QNameToString(XmlQualifiedName qname, IXmlNamespaceResolver nsResolver)
        {
            string prefix;

            if (nsResolver == null)
                return string.Concat("{", qname.Namespace, "}", qname.Name);

            prefix = nsResolver.LookupPrefix(qname.Namespace);
            if (prefix == null)
                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoPrefix, qname.ToString(), qname.Namespace));

            return (prefix.Length != 0) ? string.Concat(prefix, ":", qname.Name) : qname.Name;
        }
开发者ID:svcgany1,项目名称:corefx,代码行数:13,代码来源:XmlUntypedConverter.cs

示例2: XmlAtomicValue

        internal XmlAtomicValue(XmlSchemaType xmlType, object value, IXmlNamespaceResolver nsResolver)
        {
            if (value == null) throw new ArgumentNullException(nameof(value));
            if (xmlType == null) throw new ArgumentNullException(nameof(xmlType));
            _xmlType = xmlType;
            _objVal = value;

            if (nsResolver != null && (_xmlType.TypeCode == XmlTypeCode.QName || _xmlType.TypeCode == XmlTypeCode.Notation))
            { //Its a qualifiedName
                XmlQualifiedName qname = _objVal as XmlQualifiedName;
                Debug.Assert(qname != null); //string representation is handled in a different overload
                string ns = qname.Namespace;
                _nsPrefix = new NamespacePrefixForQName(nsResolver.LookupPrefix(ns), ns);
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:15,代码来源:XmlAtomicValue.cs

示例3: QNameToString

 protected static string QNameToString(XmlQualifiedName qname, IXmlNamespaceResolver nsResolver)
 {
     if (nsResolver == null)
     {
         return ("{" + qname.Namespace + "}" + qname.Name);
     }
     string prefix = nsResolver.LookupPrefix(qname.Namespace);
     if (prefix == null)
     {
         throw new InvalidCastException(Res.GetString("XmlConvert_TypeNoPrefix", new object[] { qname.ToString(), qname.Namespace }));
     }
     if (prefix.Length == 0)
     {
         return qname.Name;
     }
     return (prefix + ":" + qname.Name);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:XmlBaseConverter.cs

示例4: XmlAtomicValue

 internal XmlAtomicValue(XmlSchemaType xmlType, object value, IXmlNamespaceResolver nsResolver)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (xmlType == null)
     {
         throw new ArgumentNullException("xmlType");
     }
     this.xmlType = xmlType;
     this.objVal = value;
     if ((nsResolver != null) && ((this.xmlType.TypeCode == XmlTypeCode.QName) || (this.xmlType.TypeCode == XmlTypeCode.Notation)))
     {
         XmlQualifiedName objVal = this.objVal as XmlQualifiedName;
         string ns = objVal.Namespace;
         this.nsPrefix = new NamespacePrefixForQName(nsResolver.LookupPrefix(ns), ns);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:XmlAtomicValue.cs

示例5: CreateXSITypeName

        /// <summary>
        /// Creates an XSI:TYPE attribute that is friendly for RMIM structures
        /// </summary>
        private string CreateXSITypeName(Type type, Type interactionContextType, IXmlNamespaceResolver namespaceResolver)
        {

            StringBuilder xsiType = new StringBuilder();

            // Scan the registered xsi:types first before creating a type
            lock(this.m_syncRoot)
                foreach (var itm in this.s_typeNameMaps)
                    if (itm.Value == type)
                        return itm.Key;

            // First, does the type acutally have a model name?
            Object[] saList = type.GetCustomAttributes(typeof(StructureAttribute), true);
            if (saList.Length == 0)
                xsiType.Append(type.FullName);
            else
            {
                StructureAttribute sa = saList[0] as StructureAttribute;
                
                // Namespace prefix?
                if (!String.IsNullOrEmpty(sa.NamespaceUri) && namespaceResolver != null)
                {
                    string prefix = namespaceResolver.LookupPrefix(sa.NamespaceUri);
                    if (!String.IsNullOrEmpty(prefix))
                        xsiType.AppendFormat("{0}:", prefix);
                }
                // Is the type generic?
                if (type.IsGenericType) // yes, then first we output the interaction 
                {
                    if (interactionContextType == null)
                        throw new FormatterException("Cannot emit xsi:type when no interaction context is provided!");
                    Object[] inSaList = interactionContextType.GetCustomAttributes(typeof(StructureAttribute), true);
                    if (inSaList.Length == 0)
                        throw new FormatterException("Invalid interaction context. Interaction context type must carry a StructureAttribute");
                    xsiType.AppendFormat("{0}.", (inSaList[0] as StructureAttribute).Name);
                }

                // Output the model and class name
                if(sa.Model != null)
                    xsiType.AppendFormat("{0}.{1}", sa.Model, sa.Name);
                else
                    xsiType.Append(sa.Name);
            }

            return xsiType.ToString();
        }
开发者ID:oneminot,项目名称:everest,代码行数:49,代码来源:XmlIts1Formatter.cs


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