Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var container = ContainerConfig.Configure();

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <IApplication>();
                app.Run();
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 internal ContainerConfig(ContainerConfig parent)
 {
     dependencies = new DependencyContainer(parent.dependencies);
 }