I would do this in a similar manner to how lazy loading is done within NH...
That is, create a proxy class generator (perhaps use the one already in
NH?) which would be used by a Windsor facility to provide the
implementation of the service you need. Then within the generated proxy
you would resolve the actual object when a member is accessed.
something like:
var container = CreateContainer();
container.AddFacility("lazyFacility", new LazyFacility());
container.Register(Component.For<IMyService>().ImplementedBy<MyServiceImpl>().Attribute("lazy").Eq(true));
var service = container.Resolve<IMyService>();
service.MyMethod(); //here service would resolve the actual service
Console.WriteLine(service.GetType()); //something like
"generated_IMyService_0959399204"
I don't know if such a thing already exists, but certainly it doesn't
sound too difficult to write (given that the implementation is likely
already mostly there in the NH codebase and is well tested there).
Lukasz Podolak wrote:
> Hello,
>
> I would like to ask, whether is it possible to configure Windsor so
> that one of my dependency for a component that is being injected
> through constructor, could be actually constructed only when accessed
> for the first time ?
>
> Is it possible to do this or do I need to implement for example my
> custom lifestyle ?
> thanks for any prompts.
>
> Łukasz
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---