覆盖nopCommerce控制器,ctor参数填充依赖注入

时间:2016-10-28 16:29:47

标签: c# asp.net-mvc nopcommerce

我想覆盖nopCommerce CheckoutController。 这是我的代码:

public class TwoStepCheckoutController  : Nop.Web.Controllers.CheckoutController
{

     public TwoStepCheckoutController(IWorkContext workContext,
        IStoreContext storeContext,
        IStoreMappingService storeMappingService,
        IShoppingCartService shoppingCartService,
        ILocalizationService localizationService,
        ITaxService taxService,
        ICurrencyService currencyService,
        IPriceFormatter priceFormatter,
        IOrderProcessingService orderProcessingService,
        ICustomerService customerService,
        IGenericAttributeService genericAttributeService,
        ICountryService countryService,
        IStateProvinceService stateProvinceService,
        IShippingService shippingService,
        IPaymentService paymentService,
        IPluginFinder pluginFinder,
        IOrderTotalCalculationService orderTotalCalculationService,
        IRewardPointService rewardPointService,
        ILogger logger,
        IOrderService orderService,
        IWebHelper webHelper,
        HttpContextBase httpContext,
        IAddressAttributeParser addressAttributeParser,
        IAddressAttributeService addressAttributeService,
        IAddressAttributeFormatter addressAttributeFormatter,
        OrderSettings orderSettings,
        RewardPointsSettings rewardPointsSettings,
        PaymentSettings paymentSettings,
        ShippingSettings shippingSettings,
        AddressSettings addressSettings,
        TaxSettings taxSettings,
        CustomerSettings customerSettings)
        :base(storeContext,storeMappingService,shoppingCartService,localizationService,taxService,currencyService,
                priceFormatter, orderProcessingService, customerService, genericAttributeService, countryService,
                stateProvinceService, shoppingCartService, paymentService, pluginFinder, orderTotalCalculationService,
                rewardPointService, logger, orderService, webHelper, httpContext, addressAttributeParser,
                addressAttributeService, addressAttributeFormatter, orderSettings, rewardPointsSettings, paymentSettings,
                shippingSettings, addressSettings, taxSettings, customerSettings
             )
    {

    }
}

我接下来了 bug

如果我写了public TwoStepCheckoutController(/*params*/):base(){} - 问题是next 也许有人知道如何解决这个问题。

P.S。对于那些不了解nopCommerce的人:所有构造函数参数都由autofac依赖注入填充。

1 个答案:

答案 0 :(得分:1)

罗马

base CheckoutController类没有无参数构造函数。这意味着您必须使用参数调用此类的构造函数:

public TwoStepCheckoutController(/*params*/):base(/*params*/){}