You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the wonderful project. I have more of a question than an issue...I'm trying to get the sample project to work with Autofac, I've gone about doing that by converting the .net core DI code to Autofac, here is my startup.cs:
public class Startup
{
public IContainer ApplicationContainer { get; private set; }
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMemoryCache();
var builder = new ContainerBuilder();
services.AddMvc();
// services.AddSingleton<InProcessBus>(new InProcessBus());
builder.Register<InProcessBus>(x => new InProcessBus()).AsSelf().SingleInstance();
builder.Register<ICommandSender>(c => c.Resolve<InProcessBus>()).SingleInstance();
builder.Register<IEventPublisher>(c => c.Resolve<InProcessBus>()).SingleInstance();
builder.RegisterType<Session>().As<ISession>().InstancePerLifetimeScope();
builder.RegisterType<InMemoryEventStore>().As<IEventStore>().SingleInstance();
builder.RegisterType<MemoryCache>().As<ICache>().InstancePerLifetimeScope();
builder.Register<IRepository>(x =>
new CacheRepository(new Repository(x.Resolve<IEventStore>()),
x.Resolve<IEventStore>(), x.Resolve<ICache>())).InstancePerLifetimeScope();
builder.RegisterType<ReadModelFacade>().As<IReadModelFacade>().InstancePerDependency();
var targetAssembly = typeof(InventoryCommandHandlers).GetTypeInfo().Assembly;
builder.RegisterAssemblyTypes(targetAssembly)
.Where(type => type.GetInterfaces().Any(y => y.IsAssignableFrom(typeof(CQRSlite.Commands.ICommandHandler<>))))
.AsImplementedInterfaces()
.InstancePerDependency();
builder.Populate(services);
this.ApplicationContainer = builder.Build();
var sp= new AutofacServiceProvider(ApplicationContainer);
var registrar = new BusRegistrar(new DependencyResolver(sp));
registrar.Register(typeof(InventoryCommandHandlers));
return sp;
}
}
However when i step through this, the GetService Method in DependecyResolver.cs can not resolve IHandlerRegistrar.
Any guidance would be appreciated.
The text was updated successfully, but these errors were encountered:
Hi @gautema,
Thanks for the wonderful project. I have more of a question than an issue...I'm trying to get the sample project to work with Autofac, I've gone about doing that by converting the .net core DI code to Autofac, here is my startup.cs:
}
However when i step through this, the GetService Method in DependecyResolver.cs can not resolve IHandlerRegistrar.
Any guidance would be appreciated.
The text was updated successfully, but these errors were encountered: