Пример #1
0
 public ApplicationContext GetAppContext()
 {
     Container.Configure(c => c.AddRegistry<DefaultRegistry>());
     var smServiceLocator = new StructureMapServiceLocator(Container);
     ServiceLocator.SetLocatorProvider(() => smServiceLocator);
     Container.Inject(ServiceLocator.Current);
     Database.SetInitializer(new LessonsLearnedDbContextInitializer());
     return Container.GetInstance<ApplicationContext>();
 }
Пример #2
0
        public void Setup()
        {
            this.Container = new Container();
            this.Container.Configure(c => c.ForSingletonOf<IDomainEventService>().Use<DomainEventService>());
            Container.Configure(x => x.Scan(scanner =>
            {
                scanner.AssembliesFromApplicationBaseDirectory();
                scanner.ConnectImplementationsToTypesClosing(typeof(IRuleCollection<>));
                scanner.WithDefaultConventions();
            }));

            var structureMapServiceLocator = new StructureMapServiceLocator(Container);
            ServiceLocator.SetLocatorProvider(() => structureMapServiceLocator);
        }
Пример #3
0
        private static void LoadStructureMap()
        {
            //structuremap
            Log.Infrastructure.Info("waking structuremap");

            ObjectFactory.Initialize(x =>
            {
                //x.ForRequestedType<IValidator>().TheDefaultIsConcreteType<Validator>();
            });

            ObjectFactory.AssertConfigurationIsValid();
            var locator = new StructureMapServiceLocator(ObjectFactory.Container);
            ServiceLocator.SetLocatorProvider(() => locator);

            Log.Infrastructure.Info("structuremap up");
        }
        public static void Initialize()
        {
            var configuration = NHibernateInitializer.Initialize();
            _container = new Container(x =>
            {
                x.For<ISessionFactory>()
                    .Singleton()
                    .Use(() => configuration.BuildSessionFactory());
                x.For<IEntityDuplicateChecker>().Use<EntityDuplicateChecker>();
                x.For(typeof(IRepository<>)).Use(typeof(Repository<>));
                x.For(typeof(IRepositoryWithTypedId<,>)).Use(typeof(RepositoryWithTypedId<,>));
                x.For(typeof(Configuration)).Use(configuration);
            });

            IDependencyResolver drStructureMap = new StructureMapDependencyResolver(_container);
            DependencyResolver.SetResolver(drStructureMap);
            var smServiceLocator = new StructureMapServiceLocator(_container);
            ServiceLocator.SetLocatorProvider(() => smServiceLocator);
        }
 public void Execute()
 {
     var container = GetStructuremapContainer();
     var smServiceLocator = new StructureMapServiceLocator(container);
     ServiceLocator.SetLocatorProvider(() => smServiceLocator);
 }