public void NameAndValue2() { var model = new TestModel { List1 = new[] { 1 }, List2 = new[] { 2 }, List3 = new List <int> { 3 }, List4 = new HashSet <int> { 4 } }; var sumBag = new SumBag(); var visitor = model.V() .WithExtendObject(sumBag) .ForEach <TestModel, SumBag, IEnumerable <int> >(x => Sum(x.ExtendObject, x.Value), x => x.IsOrImplOf <IEnumerable <int> >()) .Cache(); visitor.Run(model, sumBag); sumBag.Sum.Should().Be(10); }
private static void Sum(SumBag bag, IEnumerable <int> data) { bag.Sum += data.Sum(); }