Configuring Castle Windsor

The first thing we need to do when configuring Castle Windsor is add a reference to the Miruken.Castle nuget package:

Install-Package Miruken.Castle

Note

Full documentation covering Miruken.Castle is here.

Installing Mediator

The MediatorInstaller lives in Miruken.Mediate.Castle so add a reference to its nuget package:

Install-Package Miruken.Mediate.Castle

In the Container.Install() method, add your feature assemblies, and then pass in an instance of MediatorInstaller.

namespace Example.Configuration
{
    using Castle.MicroKernel.Resolvers.SpecializedResolvers;
    using Castle.Windsor;
    using Miruken.Castle;
    using Miruken.Mediate.Castle;

    public class InstallingMediator
    {
        public IWindsorContainer Container { get; set; }

        public InstallingMediator()
        {
            Container = new WindsorContainer();
            Container.Kernel.Resolver.AddSubResolver(
                new CollectionResolver(Container.Kernel, true));

            Container.Install(new FeaturesInstaller(
                new MediateFeature().WithStandardMiddleware()));
        }
    }
}

Installing Validation Middleware

The ValidationInstalling lives in the Miruken.Validate.Castle so add a reference to its nuget package:

Install-Package Miruken.Validate.Castle

In the Container.Install() method, add your feature assemblies, and then pass in an instance of ValidationInstaller.

namespace Example.Configuration
{
    using Castle.MicroKernel.Registration;
    using Castle.MicroKernel.Resolvers.SpecializedResolvers;
    using Castle.Windsor;
    using League.Api.Team;
    using Miruken.Castle;
    using Miruken.Mediate.Castle;
    using Miruken.Validate.Castle;

    public class InstallingValidateMiddleware
    {
        public IWindsorContainer Container { get; set; }

        public InstallingValidateMiddleware()
        {
            Container = new WindsorContainer();
            Container.Kernel.Resolver.AddSubResolver(
                new CollectionResolver(Container.Kernel, true));

            Container.Install(new FeaturesInstaller(
                new MediateFeature().WithStandardMiddleware(),
                new ValidateFeature()).Use(
                    Classes.FromAssemblyContaining<CreateTeam>()));
        }
    }
}