Did you change the order in which it gets called? If yes, break point it, does it get hit?
It's crucial you change the order or else the original will get hit.
builder.RegisterType<PreciousMetalsPriceCalculationService>().As<IPriceCalculationService>().SingleInstance().PreserveExistingDefaults();
using Autofac;
using Autofac.Core;
using Autofac.Integration.Mvc;
using Nop.Core.Caching;
using Nop.Core.Data;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Data;
using Nop.Plugin.Pricing.PreciousMetals.Data;
using Nop.Plugin.Pricing.PreciousMetals.Domain;
using Nop.Plugin.Pricing.PreciousMetals.Services;
using Nop.Services.Catalog;
using Nop.Services.Orders;
using Nop.Web.Framework.Mvc;
namespace Nop.Plugin.Pricing.PreciousMetals
{
public class DependencyRegistrar : IDependencyRegistrar
{
const string objectContextName = "nop_object_context_preciousmetals_pricing";
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//data layer
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
const string objectContextName = "nop_object_context_preciousmetals_pricing";
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
//register named context
builder.Register<IDbContext>(c => new PreciousMetalsPricingObjectContext(dataProviderSettings.DataConnectionString))
.Named<IDbContext>(objectContextName)
.InstancePerLifetimeScope();
builder.Register(c => new PreciousMetalsPricingObjectContext(dataProviderSettings.DataConnectionString))
.InstancePerLifetimeScope();
}
else
{
//register named context
builder.Register<IDbContext>(c => new PreciousMetalsPricingObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.Named<IDbContext>(objectContextName)
.InstancePerLifetimeScope();
builder.Register(c => new PreciousMetalsPricingObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.InstancePerLifetimeScope();
}
// register custom objects
builder.RegisterType<EfRepository<PreciousMetalsDetail>>()
.As<IRepository<PreciousMetalsDetail>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(objectContextName))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PreciousMetalsQuote>>()
.As<IRepository<PreciousMetalsQuote>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(objectContextName))
.InstancePerLifetimeScope();
//Register services
builder.RegisterType<PreciousMetalsDetailService>().As<IPreciousMetalsDetailService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsQuoteService>().As<IPreciousMetalsQuoteService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsPriceCalculationService>().As<IPriceCalculationService>().SingleInstance().PreserveExistingDefaults();
builder.RegisterType<PreciousMetalsOrderTotalCalculationService>().As<IOrderTotalCalculationService>().SingleInstance().PreserveExistingDefaults();
builder.RegisterType<PreciousMetalsProductService>().As<IProductService>().SingleInstance().PreserveExistingDefaults();
//builder.RegisterType<PreciousMetalsPriceCalculationService>().As<IPriceCalculationService>().InstancePerLifetimeScope();
//builder.RegisterType<PreciousMetalsOrderTotalCalculationService>().As<IOrderTotalCalculationService>().InstancePerLifetimeScope();
//builder.RegisterType<PreciousMetalsProductService>().As<IProductService>().InstancePerLifetimeScope();
}
public int Order
{
get { return 100; }
}
}
}