1、此方法为PaymentMethod ,实现iPaymentMethodpublic string PostProcessPayment(Order order)
{
//already paid or order.OrderTotal == decimal.Zero
if (order.PaymentStatus == PaymentStatusEnum.Paid)
return string.Empty; var paymentMethod = GetPaymentMethodById(order.PaymentMethodId);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
return iPaymentMethod.PostProcessPayment(order);
}这个方法中的以下这句话不是很理解 ,为什么还要把结果返回给它自己呢 ,这种写法叫什么 , 这样写有什么好处 。 var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
return iPaymentMethod.PostProcessPayment(order);
{
//already paid or order.OrderTotal == decimal.Zero
if (order.PaymentStatus == PaymentStatusEnum.Paid)
return string.Empty; var paymentMethod = GetPaymentMethodById(order.PaymentMethodId);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
return iPaymentMethod.PostProcessPayment(order);
}这个方法中的以下这句话不是很理解 ,为什么还要把结果返回给它自己呢 ,这种写法叫什么 , 这样写有什么好处 。 var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
return iPaymentMethod.PostProcessPayment(order);
这种写法也不懂 请赐教
var paymentMethod = GetPaymentMethodById(order.PaymentMethodId);
//如果paymentMethod不为空的话 取得接口类型IPaymentMethod iPaymentMethod(具体实现类的实例化)
var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
//然后在调用iPaymentMethod.PostProcessPayment方法
return iPaymentMethod.PostProcessPayment(order);
//注意这里的PostProcessPayment不是这里的方法 而是另外的继承了IPaymentMethod的类的具体实现方法