An incomplete document fragment
Inheritance: DomDocument, IDomFragment
Exemplo n.º 1
0
        private IDomDocument CreateNew(Type t)
        {
            IDomDocument newDoc;

            if (t == typeof(IDomDocument))
            {
                newDoc = new DomDocument();
            }
            else if (t == typeof(IDomFragment))
            {
                newDoc = new DomFragment();
            }

            else
            {
                throw new ArgumentException(String.Format("I don't know about an IDomDocument subclass \"{1}\"",
                                                          t.ToString()));
            }

            return(newDoc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an IDomDocument that is derived from this one. The new type can also be a derived
        /// type, such as IDomFragment. The new object will inherit DomRenderingOptions from this one.
        /// </summary>
        ///
        /// <exception cref="ArgumentException">
        /// Thrown when one or more arguments have unsupported or illegal values.
        /// </exception>
        ///
        /// <typeparam name="T">
        /// The type of object to create that is IDomDocument.
        /// </typeparam>
        /// <param name="elements">
        /// The elements that are the source for the new document.
        /// </param>
        ///
        /// <returns>
        /// A new, empty concrete class that is represented by the interface T, configured with the same
        /// options as the current object.
        /// </returns>

        public IDomDocument CreateNew <T>(IEnumerable <IDomObject> elements) where T : IDomDocument
        {
            IDomDocument newDoc;

            if (typeof(T) == typeof(IDomDocument))
            {
                newDoc = new DomDocument(elements);
            }
            else if (typeof(T) == typeof(IDomFragment))
            {
                newDoc = new DomFragment(elements);
            }

            else
            {
                throw new ArgumentException(String.Format("I don't know about an IDomDocument subclass \"{1}\"",
                                                          typeof(T).ToString()));
            }

            FinishConfiguringNew(newDoc);
            return(newDoc);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an IDomDocument that is derived from this one. The new type can also be a derived type,
        /// such as IDomFragment. The new object will inherit DomRenderingOptions from this one.
        /// </summary>
        ///
        /// <exception cref="ArgumentException">
        /// Thrown when one or more arguments have unsupported or illegal values.
        /// </exception>
        ///
        /// <typeparam name="T">
        /// The type of object to create that is IDomDocument.
        /// </typeparam>
        /// <param name="html">
        /// The HTML source for the new document.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>
        ///
        /// <returns>
        /// A new, empty concrete class that is represented by the interface T, configured with the same
        /// options as the current object.
        /// </returns>

        public IDomDocument CreateNew <T>(char[] html, HtmlParsingMode htmlParsingMode) where T : IDomDocument
        {
            IDomDocument newDoc;

            if (typeof(T) == typeof(IDomDocument))
            {
                newDoc = new DomDocument(html, htmlParsingMode);
            }
            else if (typeof(T) == typeof(IDomFragment))
            {
                newDoc = new DomFragment(html, htmlParsingMode);
            }

            else
            {
                throw new ArgumentException(String.Format("I don't know about an IDomDocument subclass \"{1}\"",
                                                          typeof(T).ToString()));
            }

            FinishConfiguringNew(newDoc);
            return(newDoc);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Bind this instance to a new empty DomFragment configured with the default options.
        /// </summary>

        protected void CreateNewFragment()
        {
            Document = new DomFragment();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewFragment(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomFragment(html,htmlParsingMode);
             
            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document. 
            
            SetSelection(Document.ChildNodes.ToList(),SelectionSetOrder.Ascending);
            FinishCreatingNewDocument();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Bind this instance to a new DomFragment created from a sequence of elements.
        /// </summary>
        ///
        /// <param name="elements">
        /// The elements to provide the source for this object's DOM.
        /// </param>

        protected void CreateNewFragment(IEnumerable<IDomObject> elements)
        {
            Document = new DomFragment(elements.Clone());
            AddSelection(Document.ChildNodes);
            FinishCreatingNewDocument();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Bind this instance to a new empty DomFragment configured with the default options.
        /// </summary>

        protected void CreateNewFragment()
        {
            Document = new DomFragment();
            FinishCreatingNewDocument();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewFragment(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomFragment(html,htmlParsingMode);
            SetSelection(Document.ChildNodes,SelectionSetOrder.Ascending);
            FinishCreatingNewDocument();
        }