internal static void Accept(ISelectable selectable, StylesheetStatement statement) { if (selectable == null) { return; } switch (statement) { case AssignmentStatement assignment: if (selectable is IStyleable styleable) { styleable.Set(assignment.Key, assignment.Value); } break; case StyleDeclaration style: SelectorHelper.Visit(selectable, style.Selector, (current, discard1, discard2) => { foreach (var localStatement in style.Statements) { Accept(current, localStatement); } }); break; default: throw new NotSupportedException(); } }
public void VisitScript(object root, string selector, object callback, params object[] predicates) { if (predicates == null) { predicates = Empty; } var selectable = asSelectable(root); if (selectable != null) { SelectorHelper.Visit( selectable, selector, (current, parent, root1) => dynamicInvoker.Invoke(callback, current), (i, s) => i >= 0 && i < predicates.Length && dynamicInvoker.Invoke(predicates[i], s) is true); } }