Skip to content

Instantly share code, notes, and snippets.

@dance2die
Last active March 26, 2018 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/5897ad07ed0411dfec9cc2c22b0d3fbc to your computer and use it in GitHub Desktop.
Save dance2die/5897ad07ed0411dfec9cc2c22b0d3fbc to your computer and use it in GitHub Desktop.
private static void ProcessPayments()
{
var paymentProviders = new[] {
"Paypal", "ApplePay", "GooglePay",
"Braintree", "PayPal", "ApplePay",
"ApplePay", "BadPaymentProvider" };
foreach (var paymentProvider in paymentProviders)
{
var paymentProcessor = PaymentStrategyFactory.Create(paymentProvider);
WriteLine($"===== Processing with '{paymentProvider}' Provider =====");
// There is no need to check if the payment processor is null here
// Reduced Cyclomatic Complexity.
var paymentStatus = paymentProcessor.Process(111);
WriteLine($"--> {paymentStatus}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment