2020-03-24 17:31:34 +01:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using MediatR;
|
|
|
|
|
using ModernKeePass.Application.Common.Mappings;
|
|
|
|
|
using Module = Autofac.Module;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application
|
|
|
|
|
{
|
|
|
|
|
public class ApplicationModule: Module
|
|
|
|
|
{
|
|
|
|
|
protected override void Load(ContainerBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
// Register Automapper profiles
|
2020-03-26 19:04:51 +01:00
|
|
|
|
builder.RegisterType<MappingProfile>().As<Profile>();
|
2020-03-24 17:31:34 +01:00
|
|
|
|
|
|
|
|
|
// Register Mediatr
|
|
|
|
|
builder
|
|
|
|
|
.RegisterType<Mediator>()
|
|
|
|
|
.As<IMediator>()
|
|
|
|
|
.InstancePerLifetimeScope();
|
|
|
|
|
|
|
|
|
|
// request & notification handlers
|
|
|
|
|
builder.Register<SingleInstanceFactory>(context =>
|
|
|
|
|
{
|
|
|
|
|
var c = context.Resolve<IComponentContext>();
|
|
|
|
|
return t => c.Resolve(t);
|
|
|
|
|
});
|
|
|
|
|
builder.RegisterAssemblyTypes(typeof(ApplicationModule).GetTypeInfo().Assembly).AsImplementedInterfaces();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|