you can register a SubDependencyResolver to supply the current context
to the service.
If you're familiar with Rhino.Tools take a look at Rhino.Igloo.
BaseController requires IContext. IContext is created by
IContextProvider.
By registering IContextProvider, and ContextResolver (implementation
of SubDependencyResolver ) to the container.
The container checks each dependency. if the dependency is IContext,
then ContextProvider is resovled from the kernel and the current
context is returned.
is lots similar to this.
interface IContext;
interface IContextProvider { IContext Current {get;}}
abstract class BaseController ctor (IContext);
class ContextResolver : ISubDependencyResolver
{
ctor (IKernel) {}
bool CanResolve(...)
{
return dependency.TargetType == typeof(IContext);
}
object Resolve(...)
{
return kernel.Resolve<IContextProvider>().Current;
}
}
Windsor Registration
container.Kernel.Resolvers.Add(new ContextResovler(container.Kernel);
container.AddComponent<IContextProvider, ImpOfContextProvider>();
container.Register([controllers]);
Jason
On Nov 13, 7:14 pm, "Victor Kornov" <[EMAIL PROTECTED]> wrote:
> IContext.CurrentUser => inject the context to service. At different
> times/projects I had that CurrentUser on IAuthenticationService,
> IAccountService etc.
>
> On Fri, Nov 14, 2008 at 3:05 AM, Colin Ramsay <[EMAIL PROTECTED]> wrote:
>
> > This is more of a general IoC question, but I'm using Windsor so it
> > made sense to ask here. Basically I have some services which need to
> > be aware of the current context - in particular the current user
> > session. What is the accepted way of supplying such context to a
> > service in this circumstance?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---