public void SetUp() { Page = new MockStylable { NameAndBases = new[] { "Page", "Layout", "VisualElement" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "StackLayout", "Layout", "VisualElement" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "Label", "VisualElement" }, Classes = new[] { "test" } }, //Label0 new MockStylable { NameAndBases = new[] { "CustomLabel", "Label", "VisualElement" } }, //CustomLabel0 new MockStylable { //AbsoluteLayout0 NameAndBases = new[] { "AbsoluteLayout", "Layout", "VisualElement" }, Classes = new[] { "test" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "Label", "VisualElement" }, Classes = new[] { "test" } }, //Label1 new MockStylable { NameAndBases = new[] { "CustomLabel", "Label", "VisualElement" }, Classes = new[] { "test" } }, //CustomLabel1 } } } } } }; SetParents(Page); }
public override bool Matches(IStyleSelectable styleable) { if (!Right.Matches(styleable)) { return(false); } if (styleable.Parent == null) { return(false); } IStyleSelectable prev = null; foreach (var elem in styleable.Parent.Children) { if (elem == styleable && prev != null) { return(Left.Matches(prev)); } prev = elem; } return(false); //var index = styleable.Parent.Children.IndexOf(styleable); //if (index == 0) // return false; //var adjacent = styleable.Parent.Children[index - 1]; //return Left.Matches(adjacent); }
public void SetUp() { Page = new MockStylable { NameAndBases = new[] { "Page", "Layout", "VisualElement" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "StackLayout", "Layout", "VisualElement" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "Label", "VisualElement" }, Classes = new[] { "test" } }, //Label0 new MockStylable { NameAndBases = new[] { "Label", "VisualElement" } }, //Label1 new MockStylable { //ContentView0 NameAndBases = new[] { "ContentView", "Layout", "VisualElement" }, Classes = new[] { "test" }, Children = new List <IStyleSelectable> { new MockStylable { NameAndBases = new[] { "Label", "VisualElement" }, Classes = new[] { "test" } }, //Label2 } }, new MockStylable { NameAndBases = new[] { "Label", "VisualElement" }, Id = "foo" }, //Label3 new MockStylable { NameAndBases = new[] { "Label", "VisualElement" } }, //Label4 } } } }; SetParents(Page); }
public override bool Matches(IStyleSelectable styleable) { if (!Right.Matches(styleable)) { return(false); } if (styleable.Parent == null) { return(false); } int selfIndex = 0; bool foundSelfInParent = false; foreach (var elem in styleable.Parent.Children) { if (elem == styleable) { foundSelfInParent = true; break; } ++selfIndex; } if (!foundSelfInParent) { return(false); } int index = 0; foreach (var elem in styleable.Parent.Children) { if (index >= selfIndex) { return(false); } if (Left.Matches(elem)) { return(true); } ++index; } return(false); //var index = styleable.Parent.Children.IndexOf(styleable); //if (index == 0) // return false; //int siblingIndex = -1; //for (var i = 0; i < index; i++) // if (Left.Matches(styleable.Parent.Children[i])) { // siblingIndex = i; // break; // } //return siblingIndex != -1; }
public override bool Matches(IStyleSelectable styleable) { for (var i = 0; i < styleable.NameAndBases.Length; i++) { if (string.Equals(styleable.NameAndBases[i], ElementName, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }
void SetParents(IStyleSelectable stylable, IStyleSelectable parent = null) { ((MockStylable)stylable).Parent = parent; if (stylable.Children == null) { return; } foreach (var s in stylable.Children) { SetParents(s, stylable); } }
public override bool Matches(IStyleSelectable styleable) { if (!Right.Matches(styleable)) { return(false); } var parent = styleable.Parent; while (parent != null) { if (Left.Matches(parent)) { return(true); } parent = parent.Parent; } return(false); }
public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) && styleable.Parent != null && Left.Matches(styleable.Parent);
public override bool Matches(IStyleSelectable styleable) => string.Equals(styleable.NameAndBases[0], ElementName, StringComparison.OrdinalIgnoreCase);
public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) && Left.Matches(styleable);
public override bool Matches(IStyleSelectable styleable) => styleable.Id == IdName;
public override bool Matches(IStyleSelectable styleable) => styleable.Classes != null && styleable.Classes.Contains(ClassName);
public override bool Matches(IStyleSelectable styleable) => func(styleable);
public abstract bool Matches(IStyleSelectable styleable);