Пример #1
0
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();

            UnityConfigurationSection configSection =
                (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

            configSection.Configure(container);

            container.RegisterInstance <IServiceLocator>(
                new UnityServiceLocatorAdapter(container));

            //app.config 사용안할때 코드로 하는 방법
            //Calculator calc = new Calculator();
            //container.RegisterInstance<ICalculator>(calc);

            //container.RegisterType<ICalculator, Calculator>();
            //container.RegisterType<IInputService, ConsoleInputService>();
            //container.RegisterType<IOutputService, ConsoleOutputService>();
            //container.RegisterType<IInputParserService, InputParserService>();
            //container.RegisterType<ICalculatorReplLoop, CalculatorReplLoop>();

            ICalculatorReplLoop loop = container.Resolve <ICalculatorReplLoop>();

            loop.Run();
        }
Пример #2
0
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();

            UnityConfigurationSection configSection = ConfigurationManager.GetSection("unity") as UnityConfigurationSection;

            configSection.Containers.Default.Configure(container);

            ICalculatorReplLoop loop = container.Resolve <ICalculatorReplLoop>();

            loop.Run();
        }
Пример #3
0
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();

            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

            section.Configure(container, string.Empty);



            ICalculatorReplLoop loop = container.Resolve <ICalculatorReplLoop>();

            loop.Run();
        }
Пример #4
0
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();

            container.RegisterType <ICalculator, Calculator>();
            container.RegisterType <IInputService, InputService>();
            container.RegisterType <IOutputService, ConsoleOutputService>();
            container.RegisterType <IInputParserService, CommandInputParserService>();
            container.RegisterType <ICalculatorReplLoop, CalculatorReplLoop>();

            ICalculatorReplLoop loop = container.Resolve <ICalculatorReplLoop>();

            loop.Run();
        }
Пример #5
0
        public void Initialize()
        {
            ICalculatorReplLoop loop = serviceLocator.GetInstance <ICalculatorReplLoop>();

            loop.Run();
        }