public void SetUp() { iocProvider = new AutofacProvider($@"{ AppDomain.CurrentDomain.BaseDirectory}repoconfig\autofac.repo.reader.json", $@"{AppDomain.CurrentDomain.BaseDirectory}repoconfig\autofac.repo.writer.json"); iocProvider.Build(); agRepo = iocProvider.GetContainer().Resolve <IAgeGroupReaderRepositoryContract>(); pRepo = iocProvider.GetContainer().Resolve <IPersonReaderRepositoryContract>(); agWRepo = iocProvider.GetContainer().Resolve <IAgeGroupWriterRepositoryContract>(); pWRepo = iocProvider.GetContainer().Resolve <IPersonWriterRepositoryContract>(); Thread.Sleep(2000); }
public void SetUp() { iocProvider = new AutofacProvider($@"{ AppDomain.CurrentDomain.BaseDirectory}repoconfig\autofac.repo.reader.json", $@"{AppDomain.CurrentDomain.BaseDirectory}repoconfig\autofac.repo.writer.json", $@"{AppDomain.CurrentDomain.BaseDirectory}moduleconfig\autofac.modules.json"); //add the configues out of configue files in PreBuild iocProvider.PreBuild((builder) => { //Interceptor only can be configured by code //PersonCommandHandler dependents object that registered in config file builder.RegisterType <PersonCommandHandler>() .As <IPersonCommandHandler>() .EnableInterfaceInterceptors(); builder.Register(c => new CommandPropertyValidator()); //Application services builder.RegisterType <PersonQueryService>() .As <IPersonQueryServiceContract>() .EnableInterfaceInterceptors(); builder.RegisterType <PersonCommandService>() .As <IPersonCommandServiceContract>() .EnableInterfaceInterceptors(); //Register ErrorHandler builder.RegisterType <UnKnownErrorHandler>() .As <IUnKnownErrorHandler>(); builder.RegisterType <NegativeErrorHandler>() .As <INegativeErrorHandler>(); //Register LoggerController builder.RegisterType <LoggerFactory>() .As <ILoggerFactory>(); builder.RegisterType <LoggerController <VersionedEvent> >() .As <ILoggerController <VersionedEvent> >(); builder.RegisterType <LoggerController <ExceptionEvent> >() .As <ILoggerController <ExceptionEvent> >(); builder.RegisterType <LoggerController <UnKnownErrorEvent> >() .As <ILoggerController <UnKnownErrorEvent> >(); }); iocProvider.Build(); handler = iocProvider.GetContainer().Resolve <IPersonCommandServiceContract>(); }