예제 #1
0
        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;
        }
예제 #2
0
        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"]);
            }
        }
예제 #4
0
        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;
        }
예제 #5
0
 public RaceProvider(IDALService dalService)
     : base(dalService)
 {
 }
예제 #6
0
 public CService([MyShortname("Mongo")] IDALService dalService)
 {
     mongo = dalService;
 }
예제 #7
0
 public NewItemService(IDALService dataAccessService)
 {
     // _dataAccessService = new DataAccessService();
     _dataAccessService = dataAccessService;
 }
예제 #8
0
 public CategoryService(IDALService dalService)
 {
     // _DALService = new DALService();
     _DALService = dalService;
 }
예제 #9
0
 public AService(IDALService dalService)
 {
     DAL = dalService;
 }
예제 #10
0
 public BService(IDALService dalService, IAService aService)
 {
     DAL = dalService;
     A   = aService;
 }
 public EmployeeService(IDALService dataAccessService)
 {
     // _dataAccessService = new DataAccessService();
     _dataAccessService = dataAccessService;
 }