{"push_id":735452584,"size":2,"distinct_size":1,"ref":"refs/heads/master","head":"7b8413f148ed9caa2ab3e72525a34c3d7112fa75","before":"206d88fe82d31b852040cb33db426d9ee0d4e5b3","commits":[{"sha":"5274ee0b06206b2773314a5524eeb9bd2d639bf2","author":{"email":"ae5854593d679f121b35a1cabcbc05a0369d1860@USA.net","name":"JohnCastleman"},"message":"LINQ in GetCalculator\n\nFYI, OfType<>() method:\r\n\r\n    from c in candidates.OfType<IHandleShippingMethod>()\r\n    where c.CanHandle(shippingMethod)\r\n    select c\r\n\r\nAlso, the following approach might allow multiple selection strategies, depending on use case:\r\n\r\npublic IEnumerable<IBasketCalculator> GetAllCalculators(ShippingMethod shippingMethod)\r\n{\r\n    return from c in candidates.OfType<IHandleShippingMethod>()\r\n             where c.CanHandle(shippingMethod)\r\n             select c;\r\n}\r\n\r\npublic IBasketCalculator GetBestCalculator(ShippingMethod shippingMethod)\r\n{\r\n    return GetAllCalculators(shippingMethod)\r\n             .First();\r\n}\r\n\r\nLeading to the following possibilities (you have to imagine something other than cost calculations for some of these):\r\n\r\n// use case: the original application\r\nvar cost = factory.GetBestCalculator(shippingMethod).CalculatePrice();\r\n\r\n// use case: average of all results\r\nvar average = factory.GetAllCalculators(shippingMethod).Select(c => c.CalculatePrice()).Average();\r\n\r\n// use case: redundant calculators - all should return same result (ideally, each enum value would have two or more matching calculators)\r\nvar redundancyCheck = factory.GetAllCalculators(shippingMethod).Select(c => c.CalculatePrice()).Distinct().Count() == 1;","distinct":false,"url":"https://api.github.com/repos/JohnCastleman/ploeh.github.com/commits/5274ee0b06206b2773314a5524eeb9bd2d639bf2"},{"sha":"7b8413f148ed9caa2ab3e72525a34c3d7112fa75","author":{"email":"ae5854593d679f121b35a1cabcbc05a0369d1860@USA.net","name":"JohnCastleman"},"message":"Merge pull request #1 from JohnCastleman/JohnCastleman-LINQ-Ideas\n\nLINQ in GetCalculator","distinct":true,"url":"https://api.github.com/repos/JohnCastleman/ploeh.github.com/commits/7b8413f148ed9caa2ab3e72525a34c3d7112fa75"}]}