public IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope) { IEnumerable <DomElement> elements; if (scope == DomScope.TargetAndAncestors) { elements = _element.AncestorsAndSelf; } else { // We don't do descendant search even if was requested elements = new [] { _element }; } var result = new Dictionary <string, DomNamespace>(); foreach (var e in elements) { foreach (var attr in e.Attributes) { if (TryExtractXmlnsPrefixMapping(attr, out string prefix)) { result[prefix] = attr.Value; } } } return(result); }
public DomNamespace GetNamespace(string prefix, DomScope scope) { if (string.IsNullOrEmpty(prefix)) { throw Failure.NullOrEmptyString(nameof(prefix)); } if (prefix == "xmlns") { return(null); } string ns; if (scope == DomScope.TargetAndAncestors) { ns = GetNamespaceAncestors(_element, prefix); } else { // We don't do descendant search even if was requested ns = GetNamespaceCore(_element, prefix); } if (ns == null) { return(null); } return(DomNamespace.Create(ns)); }
public IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope) { if (ns is null) { throw new ArgumentNullException(nameof(ns)); } IEnumerable <DomElement> elements; if (scope == DomScope.TargetAndAncestors) { elements = _element.AncestorsAndSelf; } else { // We don't do descendant search even if was requested elements = new [] { _element }; } return(elements.SelectMany( e => e.Attributes.TrySelect <DomAttribute, string>(TryExtractXmlnsPrefixMapping) )); }
public string GetPrefix(DomNamespace ns, DomScope scope) { return(null); }
public void RegisterObserver(DomObserver observer, DomNode target, DomScope scope, DomObserverEventScope events) { var list = GetItemsForScope(events); list.Add(new ScopedDomObserverTarget(observer, target, scope)); }
public string GetPrefix(DomNamespace ns, DomScope scope) { return(Resolver.GetPrefix(ns, scope)); }
public DomObserver ObserveAttributes(DomNode target, DomName attribute, Action <DomAttributeEvent> handler, DomScope scope) { if (target is null) { throw new ArgumentNullException(nameof(target)); } if (attribute is null) { throw new ArgumentNullException(nameof(attribute)); } if (handler is null) { throw new ArgumentNullException(nameof(handler)); } var result = DomObserver.Attributes(handler); _observers.RegisterObserver( result, target, scope, DomObserverEventScope.AnyAttribute ); return(result); }
public ScopedDomObserverTarget(DomObserver observer, DomNode target, DomScope scope) : base(observer) { Target = target; Scope = scope; }
public IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope) { return(Enumerable.Empty <string>()); }
public DomObserver ObserveChildNodes(DomNode target, Action <DomMutationEvent> handler, DomScope scope) { if (target is null) { throw new ArgumentNullException(nameof(target)); } if (handler is null) { throw new ArgumentNullException(nameof(handler)); } var result = DomObserver.ChildNodes(handler); _observers.RegisterObserver( result, target, scope, DomObserverEventScope.ChildNodes ); return(result); }
public string GetPrefix(DomNamespace ns, DomScope scope) { return(GetPrefixes(ns, scope).FirstOrDefault()); }
public IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope) { return(Resolver.GetPrefixes(ns, scope)); }
public DomNamespace GetNamespace(string prefix, DomScope scope) { return(null); }
public abstract IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope);
public abstract IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope);
public abstract DomNamespace GetNamespace(string prefix, DomScope scope);
public IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope) { return(Resolver.GetPrefixBindings(scope)); }
public IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope) { return(Empty <string, DomNamespace> .ReadOnlyDictionary); }
public DomNamespace GetNamespace(string prefix, DomScope scope) { return(Resolver.GetNamespace(prefix, scope)); }