
Originally Posted by
dee-u
Would using reflection acceptable?
I think dee-u has the right idea, just not the implementation.
Code:
public void AddAccount(AccountBase account)
{
Type accountType = account.GetType();
// assumes DoSomeThing is static if not mi will need to be changed appropriately and change the invoke to use an instance
MethodInfo mi = typeof(ThirdParty).GetMethod("DoSomeThing", BindingFlags.Static | BindingFlags.Public);
MethodInfo genMI = mi.MakeGenericMethod(accountType);
genMI.Invoke(null, new object[] { account });
}