0

I'm still groping around a bit with Castle Windsor. At the moment all my pages which need an IWindsorContainer instantiate one themselves through a property:

private IWindsorContainer WindsorContainer
  {
    get
    {
      if (_windsorContainer == null)
      {
        _windsorContainer = new WindsorContainer(new XmlInterpreter(Server.MapPath("~/CastleWindsorConfiguration.xml")));
      }
      return _windsorContainer;
    }
  }

I'm getting a little tired of copying and pasting this property and the backing field from page to page! Also I don't really understand the life cycle of the IWindsorContainer.

I'd much rather get one of these through a static property of some class, but does anyone know if I can consider it threadsafe? How do you guys work with IWindsorContainer?

David
  • 15,750
  • 22
  • 90
  • 150

1 Answers1

1

The standard and recommended practice is to have one instance of the container per application.

See these related questions for further information:

And yes, Windsor is thread-safe.

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275