Esempio n. 1
0
        // Injects all services.
        private void Compose()
        {
            IocContainer container = new IocContainer();
            ServiceLocator.SetLocatorProvider(() => container);

            container.RegisterAssembly<ICalculator>(Assembly.GetExecutingAssembly());
            container.Register<ICalculatorResolver>(c => new CalculatorResolver(c.GetAllInstances<ICalculator>()));
            container.Register<ITaxService>(c => new TaxService(c.Resolve<ICalculatorResolver>()));
            container.Register<Cashier>(c => new Cashier(c.Resolve<ITaxService>()));
        }