Can you add custom refactorings ?
I'm finding that I have to implement the following pattern frequently
interface ISomeInterface
{
int SomeMethod();
int AnotherMethod();
}
public class MySomeImplementation : ISomeInterface
{
private ISomeInterface existing;
public MySomeImplementation( ISomeInterface existing )
{
this.existing = existing;
}
public int SomeMetthod()
{
return this.existing.SomeMethod();
}
public int AnotherMethod()
{
return this.existing.AnotherMethod();
}
}
Sometimes the interface is an abstract baseclass and then it's override and delegate.
A good example of this the IWebDriver and IWebElement interfaces from the Selenium system.
Can I create a refactor to create a class that implements the same interface and delegate all interface calls to an existing implementation. Similiar in concept to wrapping a property around a field.
Please sign in to leave a comment.
Hello Robert
You can achieve similar behavior by using ReSharper | Edit | Generate Code | Delegating members inside such class:
public class MySomeImplementation : ISomeInterface
{
private ISomeInterface existing;
public MySomeImplementation( ISomeInterface existing )
{
this.existing = existing;
}
}
however, you will need to manually create such class first. You can automate this process further by creating a custom ReSharper plug-in.
Thank you!
Andrey Serebryansky
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Thanks Andrey... i'll look at the SDK and have a go.
Cheers...