public static void GetCallFromAllAutoServices() { using (var scope = Container.BeginLifetimeScope()) { var bmw = scope.Resolve <BMWAutoService>(); var ford = scope.Resolve <FordAutoService>(); var honda = scope.Resolve <HondaAutoService>(); AutoServiceCallerImp serviceCaller = new AutoServiceCallerImp(bmw, ford, honda); serviceCaller.CallAutoService(); } }
public static void Resolution() { using (var scope = Container.BeginLifetimeScope()) //genera scope del contenedor { var bmw = scope.Resolve <BmwAutoService>(); // resuelve todas las dependencias var honda = scope.Resolve <HondaAutoService>(); // como no tiene atributos no se pasa nada var ford = scope.Resolve <FordAutoService>(); AutoServiceCallerImp serviceCaller = new AutoServiceCallerImp(bmw, honda, ford); // se pasan lso 3 parĂ¡metros serviceCaller.callAutoService(); } }
public static void Resolution() { using (var scope = Container.BeginLifetimeScope()) { var bmw = scope.Resolve <BMWAutoService>(); //aqui se esta injectando (DI) var ford = scope.Resolve <FordAutoService>(); var honda = scope.Resolve <HondaAutoService>(); AutoServiceCallerImp serviceCaller = new AutoServiceCallerImp(bmw, ford, honda); serviceCaller.callAutoService(); } }
static void Main(string[] args) { AddConfiguration(); BMWAutoService bmw = Container.Resolve <BMWAutoService>(); FordAutoService ford = Container.Resolve <FordAutoService>(); HondaAutoService honda = Container.Resolve <HondaAutoService>(); AutoServiceCallerImp serviceCaller = new AutoServiceCallerImp(bmw, ford, honda); serviceCaller.CallAutoService(); }