コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public virtual T Find <T>(IContract contract)
     where T : IContract
 {
     return(CompositeExtensions.SelectMany(contract).OfType <T>().FirstOrDefault());
 }