public UsersController(ILoggerFactory factory, ILogger <UsersController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IConfiguration configuration , IUserService userService) { this._Factory = factory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; this._ITestServiceC = testServiceC; this._ITestServiceD = testServiceD; this._IUserService = userService; this._iConfiguration = configuration; this._iUserService = userService; this._userList = this._iUserService.Query <Zhaoxi.EntityFrameworkCore31.Model.User>(u => u.Id > 1) .OrderBy(u => u.Id) .Skip(1) .Take(5) .Select(u => new Users() { UserID = u.Id, UserEmail = u.Email, UserName = u.Name }).ToList(); }
public FourthController(ILogger <FourthController> logger, ILoggerFactory loggerFactory , ITestServiceA testServiceA , ITestServiceB testServiceB , ITestServiceC testServiceC , ITestServiceD testServiceD , ITestServiceE testServiceE , IServiceProvider serviceProvider , IConfiguration configuration , IUserService userService , DbContext dbContext ) //, DbContext dbContext) { this._logger = logger; this._loggerFactory = loggerFactory; this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; this._iServiceProvider = serviceProvider; this._iConfiguration = configuration; this._dbContext = dbContext; this._iUserService = userService; }
public TestObjectA(ITestServiceA testServiceA, TestObjectB object2, DateTime date, int number) { TestServiceA = testServiceA; TestObjectB = object2; Date = date; Number = number; }
static void Main(string[] args) { Console.WriteLine("Hello World!"); IServiceContainer serviceContainer = new ServiceContainer(); { serviceContainer.Register <ITestServiceA, TestServiceA>(); serviceContainer.Register <ITestServiceA, TestServiceA1>("A1"); serviceContainer.Register <ITestServiceA, TestServiceA2>("A2"); ITestServiceA testServiceA = serviceContainer.Resolve <ITestServiceA>(); ITestServiceA testServiceA1 = serviceContainer.Resolve <ITestServiceA>("A1"); ITestServiceA testServiceA2 = serviceContainer.Resolve <ITestServiceA>("A2"); testServiceA.Show(); testServiceA1.Show(); testServiceA2.Show(); } { serviceContainer.Register <ITestServiceB, TestServiceB>(); serviceContainer.Register <ITestServiceC, TestServiceC>(); serviceContainer.Register <ITestServiceD, TestServiceD>(); serviceContainer.Register <ITestServiceE, TestServiceE>(); ITestServiceB testServiceB = serviceContainer.Resolve <ITestServiceB>(); testServiceB.Show(); } Console.ReadLine(); }
public UserDAL(ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, ITestServiceE testServiceE) { this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; }
public IocTest(ITestServiceA serviceA, ITestServiceB serviceB, ITestServiceC serviceC) { _serviceA = serviceA; _serviceB = serviceB; _serviceC = serviceC; }
public UsersController(ILoggerFactory factory, ILogger <UsersController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IConfiguration configuration , IUserService userService) { this._Factory = factory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; this._ITestServiceC = testServiceC; this._ITestServiceD = testServiceD; this._IUserService = userService; this._iConfiguration = configuration; this._iUserService = userService; #region 为了测试方便,不从数据获取数据,使用内存 //this._userList = this._iUserService.Query<Zhaoxi.EntityFrameworkCore31.Model.User>(u => u.Id > 1) // .OrderBy(u => u.Id) // .Skip(1) // .Take(5) // .Select(u => new Users() // { // UserID = u.Id, // UserEmail = u.Email, // UserName = u.Name // }).ToList(); this._userList = new List <Users>() { new Users { UserID = 1, UserName = "******" }, new Users { UserID = 2, UserName = "******" }, new Users { UserID = 3, UserName = "******" }, new Users { UserID = 4, UserName = "******" }, new Users { UserID = 5, UserName = "******" }, new Users { UserID = 6, UserName = "******" }, }; #endregion }
public SecondController(ILoggerFactory loggerFactory, ILogger <SecondController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IA ia, IUserService userService) { this._Factory = loggerFactory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; this._ITestServiceC = testServiceC; this._ITestServiceD = testServiceD; this._IA = ia; this._IUserService = userService; }
public SecondController( ITestServiceA testServiceA , ITestServiceB testServiceB , ITestServiceC testServiceC , ITestServiceD testServiceD) { this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; }
public FirstController(ILogger <FirstController> logger, ILoggerFactory loggerFactory, ITestServiceA iTestServiceA, ITestServiceB iTestServiceB, ITestServiceC iTestServiceC) { _logger = logger; _loggerFactory = loggerFactory; _iTestServiceA = iTestServiceA; _iTestServiceB = iTestServiceB; _iTestServiceC = iTestServiceC; }
public FirstController(ILoggerFactory factory, ILogger <FirstController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, IA ia) { this._factory = factory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; _iA = ia; }
public FilterController(IConfiguration configuration, ILogger <FilterController> logger, ITestServiceA iTestServiceA, ITestServiceB iTestServiceB, ITestServiceC iTestServiceC) { _configuration = configuration; _logger = logger; _iTestServiceA = iTestServiceA; _iTestServiceB = iTestServiceB; _iTestServiceC = iTestServiceC; }
public FourthController(ILoggerFactory factory, ILogger <SecondController> ilogger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IA a) { _factory = factory; _ilogger = ilogger; _testServiceA = testServiceA; _testServiceB = testServiceB; _testServiceC = testServiceC; _testServiceD = testServiceD; _a = a; }
public SecondController(ILoggerFactory factory, ILogger <SecondController> ilogger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, IEnumerable <ITestServiceD> testServiceDs, IA a) { _factory = factory; _ilogger = ilogger; _testServiceA = testServiceA; _testServiceB = testServiceB; _testServiceC = testServiceC; _testServiceDs = testServiceDs; _a = a; }
public FourthController(ILogger <FourthController> logger , ITestServiceA testServiceA , ITestServiceB testServiceB , ITestServiceC testServiceC , ITestServiceD testServiceD , ITestServiceE testServiceE , IA a) { this._logger = logger; this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; this._ia = a; }
public UsersController(ILoggerFactory factory, ILogger <SecondController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IA a) { this._Factory = factory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; this._ITestServiceC = testServiceC; this._ITestServiceD = testServiceD; this._IA = a; }
public SecondController(ILoggerFactory loggerFactory, ILogger <SecondController> logger, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IA a) { _loggerFactory = loggerFactory; _logger = logger; _testServiceA = testServiceA; _testServiceB = testServiceB; _testServiceC = testServiceC; _testServiceD = testServiceD; _a = a; }
public SecondController(ILogger <SecondController> logger, ILoggerFactory loggerFactory, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, ITestServiceE testServiceE, IServiceProvider iServiceProvider ) { _logger = logger; this._loggerFactory = loggerFactory; this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; this._iServiceProvider = iServiceProvider; }
public ThirdController(ILogger <ThirdController> logger, ILoggerFactory loggerFactory , ITestServiceA testServiceA , ITestServiceB testServiceB , ITestServiceC testServiceC , ITestServiceD testServiceD , ITestServiceE testServiceE , IServiceProvider serviceProvider , IConfiguration configuration) { this._logger = logger; this._loggerFactory = loggerFactory; this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; this._iServiceProvider = serviceProvider; this._iConfiguration = configuration; }
public SecondController(ILoggerFactory factory, ILogger <SecondController> logger, CyfMYSQLContext mysqlcontext, CyfMSSQLContext mssqlcontext, ITestServiceA testServiceA, ITestServiceB testServiceB, ITestServiceC testServiceC, ITestServiceD testServiceD, IA a) { this._Factory = factory; this._logger = logger; this._ITestServiceA = testServiceA; this._ITestServiceB = testServiceB; this._ITestServiceC = testServiceC; this._ITestServiceD = testServiceD; this._IA = a; this._Mysqlcontext = mysqlcontext; this._Mssqlcontext = mssqlcontext; }
/// <summary> /// 来自DI依赖注入---构造函数注入---构造A对象依赖B对象,自动初始化B对象传入 /// /// 有个容器,负责构造SecondController(反射)--反射构造函数--需要B--再构造B---然后再构造A /// </summary> /// <param name="logger"></param> /// <param name="loggerFactory"></param> public SecondController(ILogger <SecondController> logger, ILoggerFactory loggerFactory , ITestServiceA testServiceA , ITestServiceB testServiceB , ITestServiceC testServiceC , ITestServiceD testServiceD , ITestServiceE testServiceE , IServiceProvider serviceProvider) //一次注入这么多,可能用不上,能不能我自己生成? 不建议, //1 大部分对象生成其实很快,且不占资源--特殊可以自己控制 //2 对象生命周期不同,注入的是跟controller的,action是跟方法的 { this._logger = logger; this._loggerFactory = loggerFactory; this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; this._iTestServiceC = testServiceC; this._iTestServiceD = testServiceD; this._iTestServiceE = testServiceE; this._iServiceProvider = serviceProvider; }
public UserDAL(ITestServiceA testServiceA, ITestServiceB testServiceB) { this._iTestServiceA = testServiceA; this._iTestServiceB = testServiceB; }
public RequiresDependencyInject(ITestServiceA serviceA) { ServiceA = serviceA; }
public HomeController(ITestServiceA testServiceA, IEnumerable <ITestServiceD> testServiceDs) { _testServiceA = testServiceA; _testServiceDs = testServiceDs; }
public TestServiceC(ITestServiceA serviceA, ITestServiceB serviceB) { _serviceA = serviceA; _serviceB = serviceB; }
public HomeController(ILogger <HomeController> factory, ITestServiceA testServiceA, ITestMathed a) { _logger = factory; _testServiceA = testServiceA; _a = a; }
public TestServiceB(ITestServiceA iTestService) { }
public TestServiceB(ITestServiceA iTestServiceA) { Console.WriteLine($"{this.GetType().Name}被构造。。。"); }
/// <summary> /// 构造函数参数顺序不同 /// </summary> /// <param name="iIndex"></param> /// <param name="testServiceA"></param> public TestServiceB([ZhaoxiParameterConstant] int iIndex, ITestServiceA testServiceA) { _iIndex = iIndex; Console.WriteLine($"{this.GetType().Name} 被构造。。。!参数是:{iIndex}"); }
private ILogger <TestServiceB> _logger = null;//logger是单独扩展的 public TestServiceB(ITestServiceA testServiceA, ILogger <TestServiceB> logger) { this._logger = logger; }
public UserDAL() { this._iTestServiceA = null; this._iTestServiceB = null; }