I have several extensions methods over "IMyInterface builder" that do pretty much the same, but I would like to simplify code.
builder.Print(...) have 4 overloads.Here I just put 2 to simplifly
public static void ProcessOne(this IMyInterface builder, Source sourceid, Exception exception, string message, IList<string> myList)
{
DoStuff(myList);
builder.Print(sourceid, exception, message);
DoAnotherStuff(myList);
}
public static void ProcessTwo(this IMyInterface builder, Source sourceid, string message, IList<string> myList)
{
DoStuff(myList);
builder.Print(sourceid, message);
DoAnotherStuff(myList);
}
Is possible to write something like this pseudo code, to simplify ProcessOne and ProcessTwo?
public static void ProcessOne(this IMyInterface builder, Source sourceid, Exception exception, string message, IList<string> myList)
{
SpecialMethod(builder.Print(sourceid, exception, message), myList)
}
public static void ProcessTwo(this IMyInterface builder, Source sourceid, string message, IList<string> myList)
{
SpecialMethod(builder.Print(sourceid, message), myList)
}
private static void SpecialMethod(???builder.Print???, IList<string> myList)
{
DoStuffOne(myList);
???builder.Print???(with specific overloads)
DoAnotherStuff(myList);
}
Basically I want to be able to pass different overloads (builder.Print) as a parameter
What is the best technique we can apply here?
EDIT: question marked as duplicated, but different overloads is not addressed.