// PUBLIC CONSTRUCTORS //////////////////////////////////////////////
        #region Constructors
        public DocumentWriter(IServiceModel serviceModel)
        {
            Contract.Requires(serviceModel != null);

            this.ServiceModel = serviceModel;

            var domDocument = DomDocument.Create(serviceModel);

            this.DomDocument = domDocument;
        }
Exemple #2
0
        private Lazy <DomDocument> CreateLazyDomDocument()
        {
            var lazyDomDocument = new Lazy <DomDocument>(() =>
            {
                var serviceModel = this.GetServiceModel();
                var domDocument  = DomDocument.Create(serviceModel);
                return(domDocument);
            });

            return(lazyDomDocument);
        }
Exemple #3
0
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML in a specific HTML tag context.
        /// </summary>
        ///
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        protected void CreateNew(CQ target,
                                 Stream html,
                                 Encoding encoding,
                                 HtmlParsingMode parsingMode,
                                 HtmlParsingOptions parsingOptions,
                                 DocType docType)
        {
            target.Document = DomDocument.Create(html, encoding, parsingMode, parsingOptions, docType);

            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document.

            target.SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending);
        }
Exemple #4
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 = DomDocument.Create(elements.Clone(), HtmlParsingMode.Fragment);
            AddSelection(Document.ChildNodes);
        }