protected virtual WikiElement AppendChild(WikiNode node) { node.SetParent (this); _children.Add (node); if (node as WikiElement == null) return this; return node as WikiElement; }
public virtual WikiElement Add(WikiNode node) { if (CanContain (node)) { return AppendChild (node); } else { return _parent.Add (node); } }
protected override WikiElement AppendChild(WikiNode node) { if (!(node is WikiListItemElement)) throw new Exception (); node.SetParent (this); _children.Add (node); return this; }
public override WikiElement Add(WikiNode node) { if (node is WikiTextNode) return base.Add (node); if (node is WikiListItemElement || (node is WikiListContainer && (node as WikiListContainer).Indent <= this.Indent)) return _parent.Add (node); if (node is WikiListContainer) return base.Add (node); throw new Exception (); }
public override WikiElement Add(WikiNode node) { if (node is WikiListItemElement || node is WikiListContainer) { WikiIndentedElement other = node as WikiIndentedElement; if (other.Indent < this.Indent) return _parent.Add (node); if (node is WikiListItemElement) { if (other.Indent == this.Indent) return this.AppendChild (node); throw new Exception (); } if (node is WikiListContainer && other.Indent == this.Indent) return _parent.Add (node); if (other.Indent != this.Indent + 1) throw new Exception (); } if (_children.Count == 0) AppendChild (new WikiListItemElement (_indent, _isRel)); return (_children[_children.Count - 1] as WikiListItemElement).Add (node); }
/// <summary> /// 引数に指定されたノードを子供に含められるかどうか判定します /// </summary> public virtual bool CanContain(WikiNode node) { return true; }