public RuleTreeNode <T> AddChildCascading(string selector) { var directParent = selector[0] == '>'; var directSibling = selector[0] == '+'; var sibling = selector[0] == '~'; var important = selector[0] == '!'; var hasRelative = directParent || directSibling || sibling || important; var selfIndex = hasRelative ? 1 : 0; var selectorSplit = RuleHelpers.SplitSelectorRegex.Split(selector.Trim(), selfIndex + 2); var selectorSelf = selectorSplit.Length > selfIndex ? selectorSplit[selfIndex] : null; var selectorOther = selectorSplit.Length > selfIndex + 1 ? selectorSplit[selfIndex + 1] : null; var hasChild = !string.IsNullOrWhiteSpace(selectorOther); if (hasRelative) { RelationType = directParent ? RuleRelationType.DirectParent : directSibling ? RuleRelationType.DirectSibling : sibling ? RuleRelationType.Sibling : important ? RuleRelationType.Self : RuleRelationType.Parent; } if (!(string.IsNullOrWhiteSpace(selectorSelf) || selectorSelf == "**")) { Selector = selectorSelf; ParsedSelector = RuleHelpers.ParseSelector(selectorSelf); } if (!hasChild) { return(this); } else { if (Children == null) { Children = new LinkedList <RuleTreeNode <T> >(); } var child = new RuleTreeNode <T>(); Children.AddLast(child); child.Parent = this; return(child.AddChildCascading(selectorOther)); } }
public int CompareTo(RuleTreeNode <T> other) { return(other.Specifity.CompareTo(Specifity)); }