public ClienteMediator(FormularioCliente formularioClientes, Clientes componentCliente) { FormularioClientes = formularioClientes; this.componentCliente = componentCliente; formularioClientes.SetMediator(this); componentCliente.SetMediator(this); }
static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); bool isOpenProcess = false; IntPtr frameworkHandle; if (processes.Length > 1) { foreach (var process in processes) { frameworkHandle = process.MainWindowHandle; if (frameworkHandle != IntPtr.Zero) { isOpenProcess = true; } } } if (!isOpenProcess) { var services = new ServiceCollection(); CongifugreServices(services); using ServiceProvider serviceProvider = services.BuildServiceProvider(); Clientes clientes = serviceProvider.GetRequiredService <Clientes>(); FormularioCliente formularioCliente = serviceProvider.GetRequiredService <FormularioCliente>(); ClienteMediator clienteMediator = new ClienteMediator(formularioCliente, clientes); Application.Run(clientes); } }