我对 MVP 模式有一些问题,特别是在哪里创建我的所有类的实例。目前这些都是在program.cs文件中创建的。虽然这可行,但我了解到这是糟糕的设计。如果有人能给我一些关于如何构建的指示,我将不胜感激。
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var browser = new BrowserWindow();
var helper = new MainPresenterHelper();
var userInterface = new MainForm();
var entity = new UserInputEntity();
var readerWriter = new ReaderWriter();
var manager = new IOManager(readerWriter);
var verif = new VerificationManager(manager);
var entityVerification = new EntityVerification(verif);
var logger = new Logger(entity, readerWriter, true);
var verifyRow = new VerifyRow(entity, logger);
var verification = new VerificationOfDataTypes(entity, logger, verifyRow, new Status(), readerWriter);
var verify = new CsvFileVerification(entityVerification, verification, logger);
var cts = new CancellationTokenSource();
var source = new CancellationTokenSourceWrapper(cts);
var presenter = new MainPresenter(userInterface, browser, helper, entity, verify, source);
Application.Run(userInterface);
}
}