Exemple #1
0
        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);
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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)
                       ));
        }
Exemple #4
0
 public string GetPrefix(DomNamespace ns, DomScope scope)
 {
     return(null);
 }
Exemple #5
0
        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));
 }
Exemple #7
0
        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);
        }
Exemple #8
0
 public ScopedDomObserverTarget(DomObserver observer, DomNode target, DomScope scope) : base(observer)
 {
     Target = target;
     Scope  = scope;
 }
Exemple #9
0
 public IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope)
 {
     return(Enumerable.Empty <string>());
 }
Exemple #10
0
        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);
        }
Exemple #11
0
 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));
 }
Exemple #13
0
 public DomNamespace GetNamespace(string prefix, DomScope scope)
 {
     return(null);
 }
Exemple #14
0
 public abstract IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope);
Exemple #15
0
 public abstract IEnumerable <string> GetPrefixes(DomNamespace ns, DomScope scope);
Exemple #16
0
 public abstract DomNamespace GetNamespace(string prefix, DomScope scope);
 public IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope)
 {
     return(Resolver.GetPrefixBindings(scope));
 }
Exemple #18
0
 public IReadOnlyDictionary <string, DomNamespace> GetPrefixBindings(DomScope scope)
 {
     return(Empty <string, DomNamespace> .ReadOnlyDictionary);
 }
 public DomNamespace GetNamespace(string prefix, DomScope scope)
 {
     return(Resolver.GetNamespace(prefix, scope));
 }