Exemplo n.º 1
0
        public IElement CreateElement(String namespaceUri, String qualifiedName)
        {
            var localName = default(String);
            var prefix    = default(String);

            GetPrefixAndLocalName(qualifiedName, ref namespaceUri, out prefix, out localName);

            if (namespaceUri.Is(NamespaceNames.HtmlUri))
            {
                var factory = Options.GetFactory <IHtmlElementFactory>();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else if (namespaceUri.Is(NamespaceNames.SvgUri))
            {
                var factory = Options.GetFactory <ISvgElementFactory>();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else if (namespaceUri.Is(NamespaceNames.MathMlUri))
            {
                var factory = Options.GetFactory <IMathElementFactory>();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else
            {
                var element = new Element(this, localName, prefix, namespaceUri);
                element.SetupElement();
                return(element);
            }
        }
Exemplo n.º 2
0
        public IElement CreateElement(String namespaceUri, String qualifiedName)
        {
            GetPrefixAndLocalName(qualifiedName, ref namespaceUri, out var prefix, out var localName);

            if (namespaceUri.Is(NamespaceNames.HtmlUri))
            {
                var factory = _context.GetFactory <IElementFactory <Document, HtmlElement> >();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else if (namespaceUri.Is(NamespaceNames.SvgUri))
            {
                var factory = _context.GetFactory <IElementFactory <Document, SvgElement> >();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else if (namespaceUri.Is(NamespaceNames.MathMlUri))
            {
                var factory = _context.GetFactory <IElementFactory <Document, MathElement> >();
                var element = factory.Create(this, localName, prefix);
                element.SetupElement();
                return(element);
            }
            else
            {
                var element = new Element(this, localName, prefix, namespaceUri);
                element.SetupElement();
                return(element);
            }
        }
Exemplo n.º 3
0
        protected void CloneElement(Element element, Boolean deep)
        {
            CloneNode(element, deep);

            foreach (var attribute in _attributes)
            {
                var attr = new Attr(attribute.Prefix, attribute.LocalName, attribute.Value, attribute.NamespaceUri);
                element._attributes.FastAddItem(attr);
            }

            element.SetupElement();
        }
Exemplo n.º 4
0
 private void CloseNode(Element element)
 {
     element.SetupElement();
     _openElements.Remove(element);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new element with the given tag name and namespace URI.
        /// </summary>
        /// <param name="namespaceUri">
        /// Specifies the namespace URI to associate with the element.
        /// </param>
        /// <param name="qualifiedName">
        /// A string that specifies the type of element to be created.
        /// </param>
        /// <returns>The created element.</returns>
        public IElement CreateElement(String namespaceUri, String qualifiedName)
        {
            var localName = default(String);
            var prefix = default(String);
            GetPrefixAndLocalName(qualifiedName, ref namespaceUri, out prefix, out localName);

            if (namespaceUri.Is(NamespaceNames.HtmlUri))
            {
                var element = Factory.HtmlElements.Create(this, localName, prefix);
                element.SetupElement();
                return element;
            }
            else if (namespaceUri.Is(NamespaceNames.SvgUri))
            {
                var element = Factory.SvgElements.Create(this, localName, prefix);
                element.SetupElement();
                return element;
            }
            else if (namespaceUri.Is(NamespaceNames.MathMlUri))
            {
                var element = Factory.MathElements.Create(this, localName, prefix);
                element.SetupElement();
                return element;
            }
            else
            {
                var element = new Element(this, localName, prefix, namespaceUri);
                element.SetupElement();
                return element;
            }
        }