本文整理汇总了C#中XmlNamespaceScope类的典型用法代码示例。如果您正苦于以下问题:C# XmlNamespaceScope类的具体用法?C# XmlNamespaceScope怎么用?C# XmlNamespaceScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlNamespaceScope类属于命名空间,在下文中一共展示了XmlNamespaceScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNamespacesInScope
internal IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
if (this.reader is IXmlNamespaceResolver)
{
return ((IXmlNamespaceResolver) this.reader).GetNamespacesInScope(scope);
}
return null;
}
示例2: GetNamespacesInScope
public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope) {
switch(scope) {
case XmlNamespaceScope.All:
return GetNamespaceDecls(null, false);
case XmlNamespaceScope.Local:
return GetNamespaceDecls(element.Parent, false);
case XmlNamespaceScope.ExcludeXml:
return GetNamespaceDecls(null, true);
}
return null;
}
示例3:
IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
{
return ((IXmlNamespaceResolver) reader).GetNamespacesInScope (scope);
}
示例4:
///<summary>
///Gets a collection of defined prefix-namespace Mappings that are currently in scope.
///</summary>
///
///<returns>
///An <see cref="T:System.Collections.IDictionary"></see> that contains the current in-scope namespaces.
///</returns>
///
///<param name="scope">An <see cref="T:System.Xml.XmlNamespaceScope"></see> value that specifies the type of namespace nodes to return.</param>
IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope)
{
XmlNamespaceCollection namespaces = readingElements.Peek().Namespaces;
Dictionary<String, String> list = new Dictionary<string, string>();
foreach (XmlNamespace ns in namespaces)
{
list.Add(ns.Prefix, ns.Namespace);
}
return list;
}
示例5:
//
// IXmlNamespaceResolver implementation
//
IDictionary<string,string> IXmlNamespaceResolver.GetNamespacesInScope( XmlNamespaceScope scope ) {
if ( !InNamespaceActiveState ) {
return new Dictionary<string,string>();
}
return nsManager.GetNamespacesInScope( scope );
}
示例6:
IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope)
{
return _nav.GetNamespacesInScope(scope);
}
示例7: GetNamespacesInScope
public virtual IDictionary<string, string> GetNamespacesInScope (XmlNamespaceScope scope)
{
IDictionary<string, string> table = new Dictionary<string, string> ();
XPathNamespaceScope xpscope =
scope == XmlNamespaceScope.Local ?
XPathNamespaceScope.Local :
scope == XmlNamespaceScope.ExcludeXml ?
XPathNamespaceScope.ExcludeXml :
XPathNamespaceScope.All;
XPathNavigator nav = Clone ();
if (nav.NodeType != XPathNodeType.Element)
nav.MoveToParent ();
if (!nav.MoveToFirstNamespace (xpscope))
return table;
do {
table.Add (nav.Name, nav.Value);
} while (nav.MoveToNextNamespace (xpscope));
return table;
}
示例8: GetNamespacesInScope
// Internal IXmlNamespaceResolver methods
internal IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
return _namespaceManager.GetNamespacesInScope(scope);
}
示例9:
IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
{
return nsResolver != null ? nsResolver.GetNamespacesInScope (scope) :
new Dictionary<string, string> ();
}
示例10: GetNamespacesInScope
public System.Collections.Generic.IDictionary<string, string> GetNamespacesInScope (XmlNamespaceScope scope) {
throw new NotImplementedException ();
}
示例11: GetNamespacesInScope
// This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey.
#pragma warning disable 3002
public virtual IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
#pragma warning restore 3002
int i = 0;
switch (scope)
{
case XmlNamespaceScope.All:
i = 2;
break;
case XmlNamespaceScope.ExcludeXml:
i = 3;
break;
case XmlNamespaceScope.Local:
i = _lastDecl;
while (_nsdecls[i].scopeId == _scopeId)
{
i--;
Debug.Assert(i >= 2);
}
i++;
break;
}
Dictionary<string, string> dict = new Dictionary<string, string>(_lastDecl - i + 1);
for (; i <= _lastDecl; i++)
{
string prefix = _nsdecls[i].prefix;
string uri = _nsdecls[i].uri;
Debug.Assert(prefix != null);
if (uri != null)
{
if (uri.Length > 0 || prefix.Length > 0 || scope == XmlNamespaceScope.Local)
{
dict[prefix] = uri;
}
else
{
// default namespace redeclared to "" -> remove from list for all scopes other than local
dict.Remove(prefix);
}
}
}
return dict;
}
示例12: GetNamespacesInScope
public IDictionary<string, string> GetNamespacesInScope (XmlNamespaceScope scope)
{
IXmlNamespaceResolver resolver = reader as IXmlNamespaceResolver;
if (resolver == null)
throw new NotSupportedException ("The input XmlReader does not implement IXmlNamespaceResolver and thus this validating reader cannot collect in-scope namespaces.");
return resolver.GetNamespacesInScope (scope);
}
示例13: GetNamespacesInScope
internal IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
if (!this.bCreatedOnAttribute)
{
XmlNode curNode = this.curNode;
while (curNode != null)
{
if (curNode.NodeType == XmlNodeType.Element)
{
XmlElement element = (XmlElement) curNode;
if (element.HasAttributes)
{
XmlAttributeCollection attributes = element.Attributes;
for (int i = 0; i < attributes.Count; i++)
{
XmlAttribute attribute = attributes[i];
if ((attribute.LocalName == "xmlns") && (attribute.Prefix.Length == 0))
{
if (!dictionary.ContainsKey(string.Empty))
{
dictionary.Add(this.nameTable.Add(string.Empty), this.nameTable.Add(attribute.Value));
}
}
else if (attribute.Prefix == "xmlns")
{
string localName = attribute.LocalName;
if (!dictionary.ContainsKey(localName))
{
dictionary.Add(this.nameTable.Add(localName), this.nameTable.Add(attribute.Value));
}
}
}
}
if (scope == XmlNamespaceScope.Local)
{
break;
}
}
else if (curNode.NodeType == XmlNodeType.Attribute)
{
curNode = ((XmlAttribute) curNode).OwnerElement;
continue;
}
curNode = curNode.ParentNode;
}
if (scope != XmlNamespaceScope.Local)
{
if (dictionary.ContainsKey(string.Empty) && (dictionary[string.Empty] == string.Empty))
{
dictionary.Remove(string.Empty);
}
if (scope == XmlNamespaceScope.All)
{
dictionary.Add(this.nameTable.Add("xml"), this.nameTable.Add("http://www.w3.org/XML/1998/namespace"));
}
}
}
return dictionary;
}
示例14: Hashtable
IDictionary IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
{
return nsResolver != null ? nsResolver.GetNamespacesInScope (scope) : new Hashtable ();
}
示例15: GetNamespacesInScope
public virtual IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
XPathNodeType nt = NodeType;
if ((nt != XPathNodeType.Element && scope != XmlNamespaceScope.Local) || nt == XPathNodeType.Attribute || nt == XPathNodeType.Namespace)
{
XPathNavigator navSave = Clone();
// If current item is not an element, then try parent
if (navSave.MoveToParent())
return navSave.GetNamespacesInScope(scope);
}
Dictionary<string, string> dict = new Dictionary<string, string>();
// "xml" prefix always in scope
if (scope == XmlNamespaceScope.All)
dict["xml"] = XmlConst.ReservedNsXml;
// Now add all in-scope namespaces
if (MoveToFirstNamespace((XPathNamespaceScope)scope))
{
do
{
string prefix = LocalName;
string ns = Value;
// Exclude xmlns="" declarations unless scope = Local
if (prefix.Length != 0 || ns.Length != 0 || scope == XmlNamespaceScope.Local)
dict[prefix] = ns;
}
while (MoveToNextNamespace((XPathNamespaceScope)scope));
MoveToParent();
}
return dict;
}