WPF and Inversion of Control: Listing 5.

Adding two more component registration calls to the container.Register block.

private void ConfigureContainer()
{
  container.AddFacility<ViewActivatorFacility>();
  container.Register(
    Component.For<IWindsorContainer>().Instance(container),
    Component.For<IViewFactory>().ImplementedBy<WindsorViewFactory>(),
    AllTypes.FromThisAssembly().BasedOn<IView>()
    .WithService.FromInterface()
    .Configure(c => c.LifeStyle.Is(LifestyleType.Transient)),
		
  AllTypes.FromThisAssembly().BasedOn<IViewModel>()
    .Configure(c => c.LifeStyle.Is(LifestyleType.Transient))
    );
}

About the Author

Patrick Steele is a senior .NET developer with Billhighway in Troy, Mich. A recognized expert on the Microsoft .NET Framework, he’s a former Microsoft MVP award winner and a presenter at conferences and user group meetings.

comments powered by Disqus

Featured

Subscribe on YouTube