WPF and Inversion of Control: Listing 4.

Windsor implementation.

public class WindsorViewFactory : IViewFactory
{
  private readonly IWindsorContainer container;
 
  public WindsorViewFactory(IWindsorContainer container)
  {
    this.container = container;
  }
 
  public T CreateView<T>() where T : IView
  {
    return container.Resolve<T>();
  }
 
  public T CreateView<T>(object argumentsAsAnonymousType)
    where T : IView
  {
    return container.Resolve<T>(argumentsAsAnonymousType);
  }
}

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