public static void TestV1() { IMyContainerV1 container = new MyContainerV1(); // constructor DI container.Register <IWebService, WebServce>(); container.Register <IAService, AService>(); container.Register <IBService, BService>(); container.Register <ICService, CService>(); container.Register <IDService, DService>(); container.Register <IDALService, MySqlDALServce>(); // property DI container.Register <IPropertyService, PropertyService>(); // method DI container.Register <IMethodService, MethodService>(); IWebService w = container.Resolve <IWebService>(); w.PService.Show(); w.MService.Show(); // constuctor with constant parameters container.Register <IIntService, IntService>(constParams: new object[] { 1, 3 }); IIntService s = container.Resolve <IIntService>(); // s.GetI == 1; s.GetJ == 3 // 1 interface, more than 1 implementation string shortName = "Mongo"; container.Register <IDALService, MongoDALService>(shortName: shortName); IDALService mySql = container.Resolve <IDALService>(); IDALService mongo = container.Resolve <IDALService>(shortName); ICService cService = container.Resolve <ICService>(); // here the IDAL for cService should be MongoDALService var another = cService.AnotherMongo; }
public static void TestV0() { IMyContainerV0 container = new MyContainerV0(); container.Register <IAService, AService>(); container.Register <IDALService, MySqlDALServce>(); IAService a = container.Resolve <IAService>(); IDALService dal = container.Resolve <IDALService>(); }
public HomeController(IDALService dalService, IArrivalService arrivalService, IUnitOfWork unitOfWork) { this.dalService = dalService; this.arrivalService = arrivalService; this.unitOfWork = unitOfWork; if (ConfigurationManager.AppSettings["PageSize"] != null) { _pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } }
public ServerService(IConverterProvider converterProvider, IDALService dalService, AirportLoader airportLoader = AirportLoader.Load) { this.airportManager = new AirportManager(); this.converterProvider = converterProvider; this.dalService = dalService; if (airportLoader == AirportLoader.CreateAndLoad) { CreateAirports(); } ChangeInStateEvent += dalService.UpdateDatabase; ChangeInStateEvent += dalService.AddLogDatabase; }
public RaceProvider(IDALService dalService) : base(dalService) { }
public CService([MyShortname("Mongo")] IDALService dalService) { mongo = dalService; }
public NewItemService(IDALService dataAccessService) { // _dataAccessService = new DataAccessService(); _dataAccessService = dataAccessService; }
public CategoryService(IDALService dalService) { // _DALService = new DALService(); _DALService = dalService; }
public AService(IDALService dalService) { DAL = dalService; }
public BService(IDALService dalService, IAService aService) { DAL = dalService; A = aService; }
public EmployeeService(IDALService dataAccessService) { // _dataAccessService = new DataAccessService(); _dataAccessService = dataAccessService; }