Guest User

Untitled

a guest
Jul 28th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. static class Program
  2.     {
  3.         // Container udostępniam w kodzie jako publiczną właściwość, ale to jest zła praktyka z tego co orientowałem się
  4.         public static IContainer Container { get; set; }
  5.         [STAThread]
  6.         static void Main()
  7.         {
  8.             Application.EnableVisualStyles();
  9.             Application.SetCompatibleTextRenderingDefault(false);
  10.             // Ustawiam DI
  11.             var builder = new ContainerBuilder();
  12.             builder.RegisterType<PresenterManager>().As<IPresenterManager>(); // PresenterManager służy do nawigacji
  13.             builder.RegisterType<DepartmentsPresenter>().As<IDepartmentsPresenter>(); // Mój presenter dla DepartmentsView
  14.             builder.RegisterType<DepartmentsView>().As<IDepartmentsView>(); // Mój widok wyświetlający listę wydziałów uczelni
  15.             builder.RegisterType<ShellView>().As<IShellView>().SingleInstance(); // Główne okno, zawsze zwraca tą samą instancję
  16.             using (Container = builder.Build())
  17.             {
  18.                 Application.Run((Form)Container.Resolve<IShellView>());
  19.             }
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment