Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Program
- {
- // Container udostępniam w kodzie jako publiczną właściwość, ale to jest zła praktyka z tego co orientowałem się
- public static IContainer Container { get; set; }
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- // Ustawiam DI
- var builder = new ContainerBuilder();
- builder.RegisterType<PresenterManager>().As<IPresenterManager>(); // PresenterManager służy do nawigacji
- builder.RegisterType<DepartmentsPresenter>().As<IDepartmentsPresenter>(); // Mój presenter dla DepartmentsView
- builder.RegisterType<DepartmentsView>().As<IDepartmentsView>(); // Mój widok wyświetlający listę wydziałów uczelni
- builder.RegisterType<ShellView>().As<IShellView>().SingleInstance(); // Główne okno, zawsze zwraca tą samą instancję
- using (Container = builder.Build())
- {
- Application.Run((Form)Container.Resolve<IShellView>());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment