I have an existing project written in C#. I would like to move part of its business logic to F#. MyObjectX is a C# class that runs scientific algorithms. For MyObjectX to run it needs to implement a couple of interfaces, and some dependencies that are injected via methods (not constructor). Example:
public class MyObjectX(): IMathSolver, IBusinessSolver
{
//private fields
private int operationMode;
private ISignalProvider signal;
//Inject dependcy via method
public void SetSignalProvider(ISignalProvider signal)
{
this.signal = signal;
}
//implemention of above interfaces
public double MethodMathSolver()
{
this.signal.GetThreshold();
//...
}
public double Method1BusinessSolver()
{
}
public double Method2MathSolver(IResultProvider provider)
{
var x = provider.GetValueAtTime(0.1);
//...
}
}
So now I would like to implement MyObjectX in F#. What is the best way to do that so i can be as functional as possible in my code?
Make the existing C# MyObjectX behave as a wrapper/facade between the rest of C# classes and the F# library were the algorithms are implemented in F# modules.
Write a F# class of MyObjectX class that implements the interfaces, and probably call other F# modules.
Or non of them. please advise.
Also what is the best way to pass the dependencies of C# to F# like 'IResultProvider/ISignalProvider'? Do i need to use mutable variables that will get populated with the dependencies via functions in F#?
Please advise. if you can share a code sample i would be thankful.