コード例 #1
0
        static void Main(string[] args)
        {
            int money;

            using (IUnityContainer container = new UnityContainer())
            {
                UnityConfigurationSection section =
                    (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

                section.Configure(container, "Employee");

                Salary ms1 = container.Resolve <Salary>();

                money = ms1.Calculate(80, 100, 1);
                Console.WriteLine("Unity =>" + money);

                section.Configure(container, "Boss");

                ms1 = container.Resolve <Salary>();

                money = ms1.Calculate(80, 100, 1);
                Console.WriteLine("Boss =>" + money);

                Console.ReadKey();
            }
        }