Hello. I'm using Structure map and want to inject instance (constructed by container) into controller's property. Instance should be named and stored in http session context container. In the previous version of my application I've used custom DI framework and it was easy enough to make such things:
public class MyController : Controller
{
[InjectSession("MySessionInstanceKey")]
public MyManager Manager {get; set;}
}
Is there any easy ways to do it with structuremap ?
Or maybe i can introduce my custom attributes and injection logic into SM framework (extend framework somehow) ?
Please help me to find a way to resolve this and Thanks a lot !
P.S. i've found temporary solution, but it increases cohesion of controller with IoC framework and contains a lot of code:
private const string ordersBulkManagerKey = "_OrdersBulkManager";
public BulkManager OrdersBulkManager
{
get
{
var manager = Session[ordersBulkManagerKey] as BulkManager;
if(manager == null)
Session[ordersBulkManagerKey] = manager
= ObjectFactory.GetInstance<BulkManager>();
return manager;
}
}
So, I don't want to use ObjectFactory.GetInstance there ...