Skip to content

openrasta/openrasta-castle-windsor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openrasta-castle-windsor

Build status

Integrates Castle Windsor with OpenRasta.

Currently built against Castle Windsor 4.1.0 and OpenRasta-core 2.5.2000

To configure OpenRasta that is been used with Asp.Net hosting the configuration for Castle-Windsor is:

using System.Web;

using Castle.MicroKernel.Registration;
using Castle.Windsor;

using OpenRasta.Configuration;
using OpenRasta.DI;
using OpenRasta.DI.Windsor;
using OpenRasta.Hosting.AspNet;

using TestOpenRastaWeb.Handlers;
using TestOpenRastaWeb.Resources;

namespace TestOpenRastaWeb
{
    public class Configuration : IConfigurationSource, IDependencyResolverAccessor
    {
        private WindsorContainer _windsorContainer;

        public void Configure()
        {
            using (OpenRastaConfiguration.Manual)
            {
                ResourceSpace.Has.ResourcesOfType<HelloWorld>().AtUri("/helloworld").HandledBy<HelloWorldHandler>().AsXmlDataContract();
            }
        }

        public IDependencyResolver Resolver
        {
            get
            {
                _windsorContainer = new WindsorContainer();

                //Register stubs to stop Windsor complaining 
                _windsorContainer.Register(
                    Component.For<HttpContext>().UsingFactoryMethod(() => (HttpContext)null),
                    Component.For<AspNetRequest>().UsingFactoryMethod(() => (AspNetRequest)null),
                    Component.For<AspNetResponse>().UsingFactoryMethod(() => (AspNetResponse)null));

                return new WindsorDependencyResolver(_windsorContainer);
            }
        }
    }
}

About

Integrates Castle Windsor with OpenRasta.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages