Eclipse allows us to define a class as:
interface MyInterface {
void methodA();
int methodB();
}
class A : MyInterface {
MyInterface myInterface;
}
and then with this “Generate delegate methods”, it will implement all needed methods for the interface, redirecting their logic to myInterface’s methods:
class A : MyInterface {
MyInterface myInterface;
public void methodA() {
myInterface.methodA();
}
public int methodB() {
return myInterface.methodB();
}
}
Is it possible to accomplish the same with VS2010?
And with R#?
Thanks
With Resharper you can do this.
http://www.jetbrains.com/resharper/features/code_generation.html
This is a great feature that we use all the time. There are a few ways to access it but what I do is hit
ALT-INSwhich brings up theGeneratecontext menu. A few items down on the list isDelegating members. Then you get a tree from which you select the fields (objects) you want to delegate to and which delegating properties/methods you want to create. Very quick and easy and works great.