public void ProcessPayment(string orderData) { var paymentProvider = new PayPalPaymentProvider(); var result = paymentProvider.Execute(orderData); MessageBox.Show(result.ToString()); }
static void Main(string[] args) { // Define strategies which have to concrete implementation of the run method IPaymentProvider googlePay = new GooglePayPaymentProvider(); IPaymentProvider applePay = new ApplePayPaymentProvider(); IPaymentProvider paypal = new PayPalPaymentProvider(); // Call the context with different concrete implementations Console.WriteLine(PaymentProcessor.ProcessPayment(googlePay)); Console.WriteLine(PaymentProcessor.ProcessPayment(applePay)); Console.WriteLine(PaymentProcessor.ProcessPayment(paypal)); Console.ReadLine(); }