Пример #1
0
        public static void ConfigureDependencies()
        {
            // Context
            var context = new MalweeContext();

            Container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            Container.Register <MalweeContext>(Lifestyle.Scoped);
            Container.Register <IRepositoryEscope, MalweeEscope>(Lifestyle.Scoped);
            Container.Register <IClientService, ClientService>(Lifestyle.Scoped);
            Container.Register <ISupplierService, SupplierService>(Lifestyle.Scoped);
            Container.Register <IServiceProvidedService>(() => new ServiceProvidedService(context, new MalweeEscope(context)));

            Container.Verify();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(Container));
        }
Пример #2
0
 public ServiceProvidedService(MalweeContext context, IRepositoryEscope escope)
 {
     _context            = context;
     _escope             = escope;
     _supplierRepository = _escope.GetRepository <ServiceProvided>();
 }