/// <summary>Creates a new element in this document. You'll need to parent it to something.
        /// E.g. with thisDocument.body.appendChild(...). Alternative to innerHTML and appendInnerHTML.</summary>
        /// <param name='tag'>The tag, e.g. <div id='myNewElement' .. ></param>
        public Element createElement(string tag)
        {
            // Note that we ignore a namespace declaration here.

            // Create the element and call its startup methods:
            Element result = TagHandlers.Create(Namespace, tag) as Element;

            result.document_ = this;
            result.OnTagLoaded();
            result.OnChildrenLoaded();

            return(result);
        }
        /// <summary>Creates a new element in this document with the given namespace.
        /// You'll need to parent it to something.</summary>
        public Element createElementNS(string namespaceName, string tag)
        {
            // Get the namespace by its URL:
            MLNamespace ns = MLNamespaces.Get(namespaceName);

            if (ns == null)
            {
                ns = Namespace;
            }

            // Create the element and call its startup methods:
            Element result = TagHandlers.Create(ns, tag) as Element;

            result.document_ = this;
            result.OnTagLoaded();
            result.OnChildrenLoaded();

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Adds all the type checkers to the given scanner.
        /// They basically automatically find elements etc in assemblies.
        /// </summary>
        public static void AddToScanner(Modular.AssemblyScanner scanner)
        {
            // Element:
            scanner.FindAllSubTypes(typeof(Dom.Element), delegate(Type type){
                // Add it:
                TagHandlers.Add(type);
            });

            // TextNode:
            scanner.FindAllSubTypes(typeof(Dom.TextNode), delegate(Type type){
                // Add it:
                TagHandlers.Add(type);
            });

            // ILangNode:
            scanner.FindAllSubTypes(typeof(Dom.ILangNode), delegate(Type type){
                // Add it:
                TagHandlers.Add(type);
            });
        }