One thing I never really liked is component registration via XML. If you were to remove a class, and forgot to remove the class from your configuration, you would find out at runtime. I'd much rather find out at build time and get the benefits from the refactoring tools.
You can do this by registering your components in code. Typically, you would register your components during application startup.
container.AddComponent<IPlayerService, PlayerService>();
container.AddComponent<IBallparkService, BallparkService>();
You have several different options when adding components. In my example, I'm just specifying a service (the interface) and the concrete class (BallParkService) that will be used. When my application needs a IBallParkService, Windsor will pass along the BallparkService. Since I didn't specify a lifestyle, the default transient lifestyle will be used. The transient lifestyle will create a new instance for every call. There are other options, though, that you can use depending on your needs.
Currently rated 1.0 by 1 people
- Currently 1/5 Stars.
- 1
- 2
- 3
- 4
- 5