コード例 #1
0
        private static void Process(int input_options)
        {
            int memberShipType = 0;
            var paymentType    = (PaymentFor)Enum.Parse(typeof(PaymentFor), input_options.ToString());

            if (input_options == 3 || input_options == 6)
            {
                paymentType    = (PaymentFor)Enum.Parse(typeof(PaymentFor), "3".ToString());
                memberShipType = input_options == 3 ? 1 : 2;
                var result      = ProcessOrders.CreateMemberShipObject();
                var sampleInput = SampleInput.GetSampleDataMember(memberShipType);

                if (result != null)
                {
                    var data = result.ProcessPayment(sampleInput);

                    Console.WriteLine($"Order of the {paymentType.ToString()} and  {data.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
            else
            {
                IProcessOrder processor = ProcessOrders.GetPaymentMethod(paymentType);
                var           data      = SampleInput.GetSampleDataForOrder(paymentType);
                if (processor != null)
                {
                    var result = processor.ProcessPayment(data);

                    Console.WriteLine($"Order of {paymentType.ToString()} and  {result.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
        }