public ProveedorMediator(Proveedores componentProveedores, FormularioProveedores formularioProveedores)
 {
     this.componentProveedores = componentProveedores;
     FormularioProveedores     = formularioProveedores;
     this.componentProveedores.SetMediator(this);
     this.FormularioProveedores.SetMediator(this);
 }
Beispiel #2
0
        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();
                FormularioProveedores formularioProveedores = serviceProvider.GetRequiredService <FormularioProveedores>();
                Proveedores           proveedores           = serviceProvider.GetRequiredService <Proveedores>();

                ProveedorMediator proveedorMediator = new(proveedores, formularioProveedores);
                Application.Run(proveedores);
            }
        }