Ejemplo n.º 1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Container tContainer = new Container();

            //register command handlers, and generic command controller
            CommandControllerDescriptorProvider provider = new CommandControllerDescriptorProvider(typeof(ICommand).Assembly);

            tContainer.RegisterManyForOpenGeneric(typeof(ICommandHandler <>), typeof(ICommand).Assembly);
            tContainer.RegisterSingle <CommandControllerDescriptorProvider>(provider);
            tContainer.RegisterSingle <IHttpControllerSelector, CommandHttpControllerSelector>();
            tContainer.RegisterSingle <IHttpActionSelector, CommandHttpActionSelector>();

            //ensure command handlers all get properly verified by container
            foreach (var commandDescriptor in provider.GetDescriptors())
            {
                tContainer.Register(commandDescriptor.ControllerDescriptor.ControllerType);
            }

            tContainer.RegisterWebApiControllers(GlobalConfiguration.Configuration);
            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(tContainer);

            tContainer.Verify();

            GlobalConfiguration.Configuration.Routes.MapHttpRoute(
                name: "Command",
                routeTemplate: "api/{controller}/{action}"
                );
        }
Ejemplo n.º 2
0
 public CommandHttpActionSelector(CommandControllerDescriptorProvider aControllerDescriptorProvider)
 {
     this.mControllerDescriptorProvider = aControllerDescriptorProvider;
 }
Ejemplo n.º 3
0
 public CommandHttpControllerSelector(CommandControllerDescriptorProvider aCommandControllerDescriptorProvider) :
     base(System.Web.Http.GlobalConfiguration.Configuration)
 {
     this.mCommandControllerDescriptorProvider = aCommandControllerDescriptorProvider;
 }