views:

93

answers:

2

Hi,

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 am 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?

+1  A: 

Interfaces can extend other interfaces in .Net right? In Java it would be:

interface BaseService {
    boolean upAndRunning();
}

interface OtherService extends BaseService { ... }
noah
+1  A: 

noah that is it! I knew I was blind outch

interface BaseService{  
   bool upAndRunning();
}

interface OtherService : BaseService { ... }

is the C# syntax.

Thanks!

mbr
Please don't add answers like this but rather add a comment to noah's answer.
Jan Jongboom