c# - Implicit interface based on class -


i have lot of classes in business layer have interface must have same methods , properties public methods , properties of business class. common scenario, interface needed dependency injection , mocking while unit testing.

it optimal if somehow define interface same public methods , properties of class. way don't have copy paste method definitions implemented class interface time. don't see logical problem this, know it's not directly possible in c#.

perhaps can come reasonable way accomplish this?

here example. here interface.

public interface iaccountbusiness {     guid getaccountidbydomain(string domain);      void createaccount(string accounttype, string accountname); } 

here implementation:

public class accountbusiness : iaccountbusiness {     public guid getaccountidbydomain(string domain)     {         // implementation     }      public void createaccount(string accounttype, string accountname)     {          // implementation     } } 

if want add parameter more in createaccount, example "email", have add both interface , business class. in example it's minor nuisance in larger scale projects it's ... ... still minor nuisance, doesn't have be.

resharper's change signature refactoring allows easily:

enter image description here


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -