So, I need to be able to execute a specific interface implementation based on the interface being used on the newly instantiated object.
This would allow us to change the implementation by changing the interface.
Probably standard stuff but here's my code to get it working;
Example:
Interface Definition:
public interface IThisInterface
{
void DoAThing();
}
public interface IThatInterface
{
void DoAThing();
}
Class Definition:
public class ThisClass : IThisInterface, IThatInterface
{
void IThisInterface.DoAThing()
{
MessageBox.Show("Do THIS thing");
}
void IThatInterface.DoAThing()
{
MessageBox.Show("Do THAT thing");
}
}
Execution:
IThisInterface thisClass = new ThisClass();
thisClass.DoAThing();
//Executes the DoAThing method on the IThisInterface
IThatInterface thatClass = new ThisClass();
thatClass.DoAThing();
//Executes the DoAThing method on the IThatInterface