static void Main(string[] args) { var container = ContainerConfig.Configure(); using (var scope = container.BeginLifetimeScope()) { var app = scope.Resolve <IApplication>(); app.Run(); } }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Green; //BusinessLogic businessLogic = new BusinessLogic(); //businessLogic.ProcessData(); var container = ContainerConfig.Configure(); using (var scope = container.BeginLifetimeScope()) { var app = scope.Resolve <IApplication>(); // In this moment, the method try to generate an instance of Application app.Run(); } Console.ReadKey(); }
private static void Main(string[] args) { //Инверсия контроля используя Dependency Injection. var container = ContainerConfig.Configure(); var textGen = container.Resolve <IEnumerable <ITextGenerator> >(); foreach (var gen in textGen) { var speaker = new Speaker(gen); speaker.Speak(); } Console.ReadKey(); }
static void Main(string[] args) { /* var builder = new ContainerBuilder(); * builder.RegisterType<SMSService>().As<IMobileServive>(); * builder.RegisterType<EmailService>().As<IMailService>(); * var container = builder.Build(); * * container.Resolve<IMobileServive>().Execute(); * container.Resolve<IMailService>().Execute(); * Console.ReadLine(); * } */ var container = ContainerConfig.Configure(); using (var scope = container.BeginLifetimeScope()) { var app = scope.Resolve <IApplication>(); app.Run(); } Console.ReadLine(); }
internal ContainerConfig(ContainerConfig parent) { dependencies = new DependencyContainer(parent.dependencies); }