I am sure someone may have already asked this type of questions before, but I can't seem to find a similar question.
I have something like this:
client = Client.GetInstance(type.objectA));
if (client != null)
{
result += client.SaveObjectA(object);
}
client = Client.GetInstance(type.objectB));
if (client != null)
{
result += client.SaveObjectB(object);
}
client = Client.GetInstance(type.objectC));
if (client != null)
{
result += client.SaveObjectC(object);
}
client = Client.GetInstance(type.objectD));
if (client != null)
{
result += client.SaveObjectD(object);
}
I wanna find a good way to reduce this repetitive code.
Please let me know your good thoughts.
Thank you
*** Additional to what i put in previously Forgot to mention a very important part Those methods were generated from a webservice. Here is the interface.
public interface Client
{
string SaveObjectA(object);
string SaveObjectB(object);
string SaveObjectC(object);
string SaveObjectD(object);
}