Dependency injection - am I missing something?
I am using structuremap in an asp.net (mvc) project and I am fairly happy with the functionality. One thing just came to me where I am not sure if I a开发者_StackOverflow社区m too blind to see. I get several services instantiated in my controller class by structure map, but I want them to share methods that are base (hint) to all services. How can I achieve this? Using a base class does not really work (or do I have to reflect on the type?) because the base class methods will not be available in the interface description that defines the service. Do I have to add the method signature into every interface? I want to have all Service classes return their availability (e.g. bool upandrunning).
Any hints?
Interfaces can extend other interfaces in .Net right? In Java it would be:
interface BaseService {
boolean upAndRunning();
}
interface OtherService extends BaseService { ... }
noah that is it! I knew I was blind outch
interface BaseService{
bool upAndRunning();
}
interface OtherService : BaseService { ... }
is the C# syntax.
Thanks!
精彩评论