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,212
  • 20
  • 86
  • 148

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
  • 97,551
  • 22
  • 191
  • 275