예제 #1
0
        /// <summary>
        /// Performs post processing on all nodes in the document.
        /// </summary>
        /// <param name="dom">The HTML document.</param>
        /// <param name="context">The node within which to post process all nodes.</param>
        private void DoPostProcess(IHtmlDocument dom, INode context)
        {
            if (PostProcessNode != null)
            {
                dom.Normalize();
                var nodes = GetAllNodes(context).ToList();

                foreach (var node in nodes)
                {
                    var e = new PostProcessNodeEventArgs {
                        Document = dom, Node = node
                    };
                    OnPostProcessNode(e);
                    if (e.ReplacementNodes.Any())
                    {
                        ((IChildNode)node).Replace(e.ReplacementNodes.ToArray());
                    }
                }
            }

            if (PostProcessDom != null)
            {
                var e = new PostProcessDomEventArgs {
                    Document = dom
                };
                OnPostProcessDom(e);
            }
        }
예제 #2
0
 /// <summary>
 /// Raises the <see cref="E:PostProcessDom" /> event.
 /// </summary>
 /// <param name="e">The <see cref="PostProcessDomEventArgs"/> instance containing the event data.</param>
 protected virtual void OnPostProcessDom(PostProcessDomEventArgs e)
 {
     PostProcessDom?.Invoke(this, e);
 }