- ago
Previously for WL6 I used Model-View-Controller (MVC) frameworks in order to separate concerns.

With WL7 I have started to migrate to Model-View-Presenter (MVP) framework. Initial testing suggests this is better.

CODE:
using System.Drawing; using WealthLab.Backtest; using WealthLab.Core; namespace WealthLabStrategies { public class MyStrategyView : UserStrategyBase, IMyStrategyView { public MyStrategyView() { Presenter = new MyStrategyPresenter(this); } public MyStrategyPresenter Presenter { get; set; } public override void Initialize(BarHistory bars) { } public override void Execute(BarHistory bars, int idx) { } public void HeaderText(string text, Color color) { DrawHeaderText(text, color, 14); } } public interface IMyStrategyView { MyStrategyPresenter Presenter { get; set; } void HeaderText(string text, Color color); //IAsyncResult BeginInvoke(Delegate method); //object Invoke(Delegate method); } public class MyStrategyPresenter : PresenterBase { public MyStrategyPresenter(IMyStrategyView view) : base(view) { _view = view; ShowDrawHeaderText($"Test1", Color.Yellow); ShowDrawHeaderText($"Test2", Color.Yellow); ShowDrawHeaderText($"Test3", Color.Yellow); } private readonly IMyStrategyView _view; } public class PresenterBase { public PresenterBase(IMyStrategyView view) { _view = view; } private readonly IMyStrategyView _view; public void ShowDrawHeaderText(string text, Color color) { _view.HeaderText(text, color); } } }


I haven't found a need for Thread-safe invoke's yet, but could not find a way to do this if it is needed.

I don't have an issue today, but am looking for input on better ways to implement an architectural framework for WL7 before I get too far.
0
817
0 Replies

Reply

Bookmark

Sort
Currently there are no replies yet. Please check back later.