/// <summary> /// 构建 HtmlDomChangedEventArgs 对象 /// </summary> /// <param name="attribute">发生变化的属性</param> /// <param name="element">属性所属的元素</param> /// <param name="action">属性所发生的操作</param> public HtmlDomChangedEventArgs(IHtmlAttribute attribute, IHtmlElement element, HtmlDomChangedAction action) { IsAttributeChanged = true; Attribute = attribute; Container = element; Action = action; }
/// <summary> /// 构建 HtmlDomChangedEventArgs 对象 /// </summary> /// <param name="node">发生变化的节点</param> /// <param name="container">节点所属的容器</param> /// <param name="action">节点所发生的操作</param> public HtmlDomChangedEventArgs(IHtmlNode node, IHtmlContainer container, HtmlDomChangedAction action) { IsAttributeChanged = false; Node = node; Container = container; Action = action; }
/// <summary> /// 当属性被修改 /// </summary> /// <param name="sender">引发事件的对象</param> /// <param name="action">引发事件的操作</param> /// <param name="attribute">被修改的属性</param> /// <param name="element">属性所属的元素</param> protected virtual void OnAttributeChanged(object sender, HtmlDomChangedAction action, IHtmlAttribute attribute, IHtmlElement element) { switch (action) { case HtmlDomChangedAction.Add: AddAttribute(element, attribute); break; case HtmlDomChangedAction.Remove: RemoveAttribute(element, attribute); break; default: throw new InvalidOperationException("未知的 DOM 结构变化"); } }
/// <summary> /// 构建 HtmlDomChangedEventArgs 对象 /// </summary> /// <param name="attribute">发生变化的属性</param> /// <param name="element">属性所属的元素</param> /// <param name="action">属性所发生的操作</param> public HtmlDomChangedEventArgs( IHtmlAttribute attribute, IHtmlElement element, HtmlDomChangedAction action ) { IsAttributeChanged = true; Attribute = attribute; Container = element; Action = action; }
/// <summary> /// 构建 HtmlDomChangedEventArgs 对象 /// </summary> /// <param name="node">发生变化的节点</param> /// <param name="container">节点所属的容器</param> /// <param name="action">节点所发生的操作</param> public HtmlDomChangedEventArgs( IHtmlNode node, IHtmlContainer container, HtmlDomChangedAction action ) { IsAttributeChanged = false; Node = node; Container = container; Action = action; }