public void SelectMany_Helper() { IFoo castedFoo = (IFoo)foo; IEnumerable <IFoo> items = CompositeExtensions.SelectMany(castedFoo); Assert.Equal(5, items.Count()); Assert.Equal(2, items.OfType <Foo>().Count()); Assert.Equal(3, items.OfType <OtherFoo>().Count()); }
public IContract Add(IContract lhs, IContract rhs) { if (lhs == null) { return(rhs); } if (rhs == null) { return(lhs); } IEnumerable <IContract> lhsItems = CompositeExtensions.SelectMany(lhs); IEnumerable <IContract> rhsItems = CompositeExtensions.SelectMany(rhs); CompositeContract contract = new CompositeContract(lhsItems.Concat(rhsItems)); return(contract); }
public virtual T Find <T>(IContract contract) where T : IContract { return(CompositeExtensions.SelectMany(contract).OfType <T>().FirstOrDefault()); }