c# 4.0 - ASP.Net MVC 3 session management when using IOC pattern -
i trying use ioc pattern , not find perfect way of implementing state management using same. great if can me same. thank you.
what first create interface containing properties need store in session (i.e.: context):
using projectname.core.domain; namespace projectname.core.interfaces { public interface iprojectnamesessioncontext { string stringproperty1 { get; set; } bool boolproperty1 { get; set; } projectname.core.domain.entity1 domainentity1 { get; set; } } } then create class implements interface, mark serializable:
using projectname.core.interfaces; namespace projectname.front.sessiondata { [serializable] public class projectnamesessioncontext : iprojectnamesessioncontext { public string stringproperty1 { get; set; } public bool boolproperty1 { get; set; } public projectname.core.domain.entity1 domainentity1 { get; set; } } } and tell ioc bind interface class @ runtime instantiate object in httpsession context.
it looks strucuremap:
for<core.interfaces.iprojectnamesessioncontext>().lifecycleis(new httpsessionlifecycle()).use<projectnamesessioncontext>(); hope helps!
Comments
Post a Comment