Service locator for generics

Posted by vittore on Stack Overflow See other posts from Stack Overflow or by vittore
Published on 2010-04-16T20:56:29Z Indexed on 2010/04/16 21:33 UTC
Read the original article Hit count: 280

Filed under:
|
|
|

Hi everyone,

I have say a dozen types T which inherit from EntityObject and IDataObject. I have generic the following interface

IDataManager<T> where T : EntityObject, IDataObject ...

I have also base class for data managers

BaseDataManager<T> : IDataManager<T> where T : EntityObject, IDataObject ....

And i have particular classes

public class Result : EntityObject, IDataObject ....

public class ResultDataManager : BaseDataManager<Result> ...

I want to implement service locator, which will return instance of IDataManager<T> for T

But I stucked how to implement it in a neat way without a lot of castings.

Any ideas?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET