Dependency Injection discovery

Posts   
 
    
DarkRoast
User
Posts: 42
Joined: 14-Jul-2010
# Posted on: 19-Jan-2011 23:31:51   

In an ASP.net application, is there a way to delay the discovery of DI information? I'm using manual discovery by specifying an assembly name in my web.config.

For example, I want to do work with entity classes in an application_onstart event, however I don't want any of the authorization logic to apply yet.

What event triggers the DI information to be applied?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Jan-2011 05:58:07   

I don't know any method or event you can hang up in DI discovery. However I think you can do one of these two things: a. Let DI do its work and you set to null the AuditorToUse:

OrderEntity o = new OrderEntity(); // at this point DI already set the AuditorToUse
o.AuditorToUse = null; // revert the DI work and move on
...

b. Don't use DI at config file. Use DI Scopes when you need auditors.

David Elizondo | LLBLGen Support Team
DarkRoast
User
Posts: 42
Joined: 14-Jul-2010
# Posted on: 20-Jan-2011 23:25:53   

Using a scope worked perfectly. In the startup event, I was able to override the authorizer picked up by config based discovery with an empty authorizer.

Thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Jan-2011 23:35:08   

Always happy to help simple_smile

Matt