I have 1 class library which has some code to perform some operation.For instance it will perform 2 operation like:
- Add
- Multiply
In future may be I can have few more operation like division for eg.
Above are just an example because i have some long running operation with each of this Add,Multiply operation.
So idea of this library is to receive input and then execute long running code against those inputs.
This is what I am thinking:
public class Input
{
//input properties
}
public interface IOperations
{
public abstract void Process(Input obj);
}
public class Add : IOperations
{
Input obj;
public Add(Input obj)
{
this.obj = obj;
}
public override void Process(Input obj)
{
//Add method implementation
}
}
public class Multiply : IOperations
{
Input obj;
public Multiply(Input obj)
{
this.obj = obj;
}
public override void Process(Input obj)
{
//Multiply method implementation
}
}
Now suppose if I want to perform Add operation or multiply operation then how I will call respective methods based on below type:
string type;
if(type=="Add")
//perform add operation
else if(type=="Multiply")
//perform multiply operation
But I am not getting proper way to design code structure for above requirement.
Note : Reason for creating IOperations
as Interface
is for dependency injection