public UserMediator(FormUsuario formUsuario, Usuarios componentUsers) { _formUsuario = formUsuario; _componentUsers = componentUsers; _formUsuario.SetMediator(this); _componentUsers.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(); ConfigureServices(services); using ServiceProvider serviceProvider = services.BuildServiceProvider(); FormUsuario formUsuario = serviceProvider.GetRequiredService <FormUsuario>(); Usuarios usuarios = serviceProvider.GetRequiredService <Usuarios>(); UserMediator mediator = new UserMediator(formUsuario, usuarios); Application.Run(usuarios); } }