0

I have problem in creating modular analysis architecture for C# application.

Aim:

It is basically like a dynamic plug and play calculator. Start with one input (A), build multiple operation process in GUI

e.g, A² (square) -> B (multiply) A -> C (divide by) B -> D

By clicking one execute button in GUI with one input A, how to arrive at D?

In the GUI one list box with necessary inputs as double values and another list box will load type of particular interface using reflection say square, multiply, etc.. Then user will build up new process by plugging in existing processes and inputs say with A as input -> square -> gives B as output -> using A, B as input -> multiply -> gives C as output -> using C / A -> gives output D During instantiation of particular process their output will be loaded dynamically using constructor.

Example problem:

public interface IProcess
{ 
 double ExecuteProcess()
}

Base process class:

public abstract class Process
{
  public double Output {get; set;}
}

Process class example:

public class Square : Process, IProcess
{
   public double Input {get; set;}
   public double ExecuteProcess()
}

Question

I hope I have explained my problem correctly. I have searched some example pattern but unable to find one to tackle this problem. Can anyone guide how to approach this problem?

Suresh
  • 219
  • 4
  • 15

1 Answers1

1

Consider MEF, this linked MSDN topic even has a walkthough which looks like it might be similar to your problem.

Sounds to me that you need two separate plugin classes, though, one for the operation itself and one that provides operation meta-data at runtime so you can compose the UI correctly (e.g. does an operation take more than one input or produce more than one output). There might even be a case for having similar extensibility for specific UI for certain operations that require special UI.

Andras Zoltan
  • 41,961
  • 13
  • 104
  • 160
  • Thanks. I will look into this. But it seems it wont work with .NET 3.5 which is what I am working with :-( – Suresh Jan 16 '12 at 13:30
  • @Suresh it's a part of .Net 4 but there is a way to get it to work with .Net 3.5 - although it probably involves downloading one of the original MEF preview sources and compiling against .Net 3.5. See http://stackoverflow.com/a/2811906/157701. Might be a bit too ad-hoc for your liking, though :) – Andras Zoltan Jan 16 '12 at 13:47
  • Thanks again for pointing me in right direction. Once I tried and make it work, I will accept your answer. Thanks for your efforts – Suresh Jan 16 '12 at 13:49