本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}