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

  • Get Good at DevOps: Feature Flag Deployments with ASP.NET WebAPI

    They provide developers with the ability to toggle features on and off without having to redeploy code, making it easier to manage risk, test features in production, and facilitate smoother releases.

  • Implementing k-NN Classification Using C#

    Dr. James McCaffrey of Microsoft Research presents a full demo of k-nearest neighbors classification on mixed numeric and categorical data. Compared to other classification techniques, k-NN is easy to implement, supports numeric and categorical predictor variables, and is highly interpretable.

  • Building Secure and Scalable APIs in .NET 8

    Tony Champion: "From giving you access to the entire lifecycle of a request, the ability to configure and extend authentication and authorization, .NET 8 gives you the power to create APIs to meet even the most demanding needs."

  • What's New for Java Tooling in VS Code, Azure Cloud

    Java on Visual Studio Code gets a new tool to its extension pack, while Java on Azure upgraded the Azure Toolkit for IntelliJ and more in new regular updates for both properties.

Subscribe on YouTube