public void FindComponentsSingleRootDirect() { TestNode tree = CreateSimpleTestTree(); IEnumerable <TestComponent> findComponentsResult2 = tree.FindComponents <TestNode, TestComponent>(comp => comp.Num % 2 == 0); Assert.Equal(3, findComponentsResult2.Count()); IEnumerable <TestComponent> findComponentsResult3 = tree.FindComponents <TestNode, TestComponent>(comp => comp.Num % 3 == 0); Assert.Equal(2, findComponentsResult3.Count()); }
public void FindComponentsByTypeSingleRootExtension() { TestNode tree = CreateSimpleTestTree(); IEnumerable <SpecialTestComponent> findComponentsResult2 = tree.FindComponents <SpecialTestComponent>(comp => comp.SpecialId.Contains("special")); Assert.Equal(2, findComponentsResult2.Count()); IEnumerable <SomeOtherTestComponent> findComponentsResult3 = tree.FindComponents <SomeOtherTestComponent>(comp => comp.SomeOtherValue == 42); Assert.Single(findComponentsResult3); }
// Find Components by type (and predicate) public static IEnumerable <TComponentToFind> FindComponents <TComponentToFind>(this TestNode root, Predicate <TComponentToFind> match) where TComponentToFind : TestComponent => root.FindComponents <TComponentToFind, TestNode, TestComponent>(match);
// Find Components by predicate only public static IEnumerable <TestComponent> FindComponents(this TestNode root, Predicate <TestComponent> match) => root.FindComponents <TestNode, TestComponent>(match);