1

How can I force a class have a specified constructor signature without using abstract classes? I googled and found that we couldn't use interfaces to do it.

[Updated]

e.g, I have the the following Interface:

public interface IListView<TViewModel, TListQueryParameter, TSingleQueryParameter>
    where TListQueryParameter : IQueryParameter<IEnumerable<TViewModel>>, new()
    where TSingleQueryParameter : IQueryParameter<TViewModel>
{
    ...
    IQueryHandler<TListQueryParameter, IEnumerable<TViewModel>> FindListDataQueryHandler { get; }
    IQueryHandler<TSingleQueryParameter, TViewModel> FindSingleEntityQueryHandler { get; }
    ...
}

and I want to inject QueryHandlers using constructor of each Form that implement the IListView.

Masoud
  • 8,020
  • 12
  • 62
  • 123

2 Answers2

0

If you want to inject a dependency, then use a Dependency Injection system or a DI resolver. This is called property injection. Try UNITY or Ninject.

Aniket Inge
  • 25,375
  • 5
  • 50
  • 78
0

Looks like structuremap does supports property injection here and here, that's what you're looking for.

Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189