开发者

structuremap Buildup() a user control

开发者 https://www.devze.com 2022-12-16 19:57 出处:网络
2 questions here.I have a page that I already use setter DI to insert a service layer using the following snippet from another post.

2 questions here. I have a page that I already use setter DI to insert a service layer using the following snippet from another post.

var application = (HttpApplication)sender;
var page = application.Context.CurrentHandler as Page;
if (page == null) return;
    ObjectFactory.BuildUp(page);

How would I do the same for a user control that sits on the same page and also needs a service layer inject开发者_如何学JAVAed?

Also it seems redundant/inefficent to have multiple instances of the service layer existing for just one call to a page, is there a better design?

Thanks


I figured it out, I was asking the question poorly.

protected override void OnInit (System.EventArgs e)
  {
    base.OnInit (e);
    IoC.BuildUp (this);
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消