Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果 service 需要依赖注入 仓储 ,该怎么 new #56

Open
wqj1991 opened this issue Nov 11, 2019 · 3 comments
Open

如果 service 需要依赖注入 仓储 ,该怎么 new #56

wqj1991 opened this issue Nov 11, 2019 · 3 comments

Comments

@wqj1991
Copy link

wqj1991 commented Nov 11, 2019

 private IRepository<TSinglePipeline, string> _repository;

public TestAppService(IRepository<TSinglePipeline, string> repository)
{
     _repository = repository;
}
HttpListener server = new HttpListener();
server.Prefixes.Add("http://127.0.0.1:8080/");
server.Start();
var service = new Service();
service.AddInstanceMethods(new TestAppService()).Bind(server);
@andot
Copy link
Member

andot commented Nov 11, 2019

依赖注入的对象该怎么生成就怎么生成。是不是 new 出来的并不重要。

@wqj1991
Copy link
Author

wqj1991 commented Nov 16, 2019

service.AddInstanceMethods(new TestAppService()).Bind(server);

具体要怎么写

@andot
Copy link
Member

andot commented Nov 18, 2019

你依赖注入的对象应该怎么生成?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants