private void Register(InitializationTaskContext context, Type matchingType)
 {
     var registration = context.Builder.RegisterType(matchingType);
     foreach (var policy in conventions.Where(p => p.IsMatch(matchingType)))
     {
         policy.Apply(registration, matchingType);
     }
 }
        public void Execute(InitializationTaskContext context)
        {
            var matchingTypes = locator.GetDependencies(conventions);

            foreach (var matchingType in matchingTypes)
            {
                Register(context, matchingType);
            }
        }
Exemple #3
0
        private static void ConfigureApis(InitializationTaskContext context)
        {
            var configuration = GlobalConfiguration.Configuration;
            configuration.MessageHandlers.Insert(0, new WebApiUnitOfWorkHandler());

            configuration.Routes.MapHttpRoute("contacts", "api/contacts", new {controller = "Contacts"});

            context.Builder.RegisterApiControllers(typeof (ContactsController).Assembly);
            context.Builder.RegisterWebApiFilterProvider(configuration);
        }
Exemple #4
0
        public IContainer Initialize()
        {
            var builder = new ContainerBuilder();

            var context = new InitializationTaskContext(builder);

            foreach (var task in Tasks)
            {
                task.Execute(context);
            }

            return container = builder.Build();
        }
        public void Execute(InitializationTaskContext context)
        {
            var builder = context.Builder;

            // register session factory as singleton
            builder.Register(CreateSessionFactory).As<ISessionFactory>().SingleInstance().OnActivated(
                handler => Trace.TraceInformation("Session factory activated")).OnRelease(
                    release => Trace.TraceInformation("Session factory released."));

            builder.Register(GetStatelessSession).As<IStatelessSession>().InstancePerLifetimeScope().OnActivated(
                handler => Trace.TraceInformation("Stateless session factory activated")).OnRelease(
                    release => Trace.TraceInformation("Stateless session released."));
        }
Exemple #6
0
        public void Execute(InitializationTaskContext context)
        {
            // register session so that each lifetime scope will have their own instance
            var registration =
                context.Builder.Register(GetSession).As<ISession>().InstancePerLifetimeScope().OnActivated(
                    handler => Trace.TraceInformation("Session activated")).OnRelease(
                        release => Trace.TraceInformation("Session released."));

            // allow modification of the session registration
            if (modifySessionRegistration != null)
            {
                modifySessionRegistration(registration);
            }
        }
Exemple #7
0
 public void Execute(InitializationTaskContext context)
 {
     context.Builder.RegisterType<ResolveSessionFactoryOnce>().AsImplementedInterfaces();
 }
Exemple #8
0
        private static void ConfigureRoutes(InitializationTaskContext context)
        {
            var routes = RouteTable.Routes;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new {controller = "Home", action = "Index", id = UrlParameter.Optional});

            context.Builder.RegisterControllers(typeof (ContactsController).Assembly);
            context.Builder.RegisterFilterProvider();
        }