I have a commerce application, asp.net mvc.
I want it to be extensible in the sense others can create other payment providers, as long as they adhere to the interfaces.
/blah.core
/blah.web
/blah.Authorize.net (Implementation of a payment provider using interfaces Ipaymentconfig and paymentdata class)
Now the problem is this:
/blah.core
- PaymentData
/blah.core.interfaces
- IPaymentConfig
where Payment Data looks like:
using blah.core;
public class PaymentData
{
public Order Order {get;set;}
}
IPayment data contains classes from blah.core like the Order class.
Now I want to use the actual Authorize.net implementation, so when I tried to reference it in the blah.core project I got a circular dependency
error.
How could I solve this problem? Many have said to break out the interfaces into their own project, but the problem is PaymentData r开发者_运维技巧eferences entities that are found in blah.core also, so there doesn't seem to be a way around this (in my head anyhow).
How can I redesign this?
Breaking out the interfaces alone will not help. The provider need to know some details about the order, but probably not all of it.
I suggest you introduce a PaymentOrder
which contains all information the provider need to know about an order. Break this one out to a new assembly together with the rest of the payment interfaces. Your payment assembly should not have any references to your application.
You will need to map your original Order
to a PaymentOrder
.
Your application will reference:
PaymentProviderInterfaces.dll
- All payment provider implementations
While any payment provider will reference
PaymentProviderInterfaces.dll
, but nothing else from your domain
精彩评论