asp.net - Using Structuremap how do i inject a property of an MVC Controller into the Constructor of a Service the Controller uses -


i'm new using structuremap ioc container asp.mvc. 1 of controllers takes istreamservice interface in constructor.

this linked concrete class implementation of streamservice so

for<istreamservice>().httpcontextscoped().use<streamservice>(); 

the problem i'm facing concrete class constuctor takes iprincipal parameter, needs injected. want pass user property of instantiating controller concrete service. please point me in right direction?

no problem, add line configuration:

for<iprincipal>().use(() => httpcontext.current.user); 

the use of lambda causes evaluated every time dependency requested (as opposed being single instance @ configuration time.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -