logo
  • 教程列表
  • SO官方文檔
  • 依賴注入
    • setter 注入(C)
    • 建構函式注入(C)
  1. StackOverflow 文件
  2. Design patterns 教程
  3. 依賴注入
  4. setter 注入(C)

setter 注入(C)

Created: November-22, 2018

public class Foo
{
    private IBar _iBar;
    public IBar iBar { set { _iBar = value; } }

    public void DoStuff()
    {
        _iBar.DoSomething();
    }
}

public interface IBar
{
    void DoSomething();
}
  • 建構函式注入(C)
  • 依賴注入

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明