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);
}
精彩评论