public PseudoFunction(PseudoTypes type) : base(type) { }
private NthChildSelector GetChildSelector(PseudoTypes type) { var selector = new NthChildSelector(type); if (_attributeValue.Equals(PseudoSelectorPrefix.NthChildOdd, StringComparison.OrdinalIgnoreCase)) { selector.Step = 2; selector.Offset = 1; } else if (_attributeValue.Equals(PseudoSelectorPrefix.NthChildEven, StringComparison.OrdinalIgnoreCase)) { selector.Step = 2; selector.Offset = 0; } else if (!int.TryParse(_attributeValue, out selector.Offset)) { var index = _attributeValue.IndexOf(PseudoSelectorPrefix.NthChildN, StringComparison.OrdinalIgnoreCase); if (_attributeValue.Length <= 0 || index == -1) { return selector; } var first = _attributeValue.Substring(0, index).Replace(" ", ""); var second = ""; if (_attributeValue.Length > index + 1) { second = _attributeValue.Substring(index + 1).Replace(" ", ""); } if (first == string.Empty || (first.Length == 1 && first[0] == Specification.PlusSign)) { selector.Step = 1; } else if (first.Length == 1 && first[0] == Specification.MinusSign) { selector.Step = -1; } else { int step; if (int.TryParse(first, out step)) { selector.Step = step; } } if (second == string.Empty) { selector.Offset = 0; } else { int offset; if (int.TryParse(second, out offset)) { selector.Offset = offset; } } } return selector; }
public NthChildSelector(PseudoTypes type) : base(type) { }
public PseudoSelector(PseudoTypes type) { this.Type = type; }