Using the BoundTo Lifestyle in Windsor in conjunction with the TypedFactoryFacility

22 views
Skip to first unread message

Tim Escott

unread,
Apr 18, 2012, 5:13:45 AM4/18/12
to castle-pro...@googlegroups.com
Hi

I would like to use the BoundTo Lifestyle in Windsor in conjunction with the TypedFactoryFacility where the factories maintain their scoped context. However I note that this is currently not supported (https://groups.google.com/forum/?fromgroups#!topic/castle-project-users/txDi3dZ8veQ). Can someone explain how I can achieve this, perhaps there is a different way to do the same thing in Windsor?

I have a scenario similar to the following. In which I am using a Command to add new Panels to a Workspace where I want the same instance of ISomeScopedViewModel to be injected into each Panel I add (created by the factory IWorkspacePanelViewModelFactory).

Scenario:

_container = new WindsorContainer();

_container.Kernel.AddFacility<TypedFactoryFacility>();

_container.Register(
Component.For<IWorkspaceViewModel>().ImplementedBy<WorkspaceViewModel>().LifeStyle.Is(LifestyleType.Transient),
Component.For<ISomeScopedViewModel>().ImplementedBy<SomeScopedViewModel>().LifeStyle.BoundTo<IWorkspaceViewModel>(),
Component.For<IWorkspacePanelViewModel>().ImplementedBy<WorkspacePanelViewModel>().LifeStyle.Is(LifestyleType.Transient),
Component.For<IWorkspacePanelViewModelFactory>().AsFactory()
...
);

Original question on Stackoverflow: http://stackoverflow.com/questions/10195895/using-the-boundto-lifestyle-in-windsor-in-conjunction-with-the-typedfactoryfacil

Reply all
Reply to author
Forward
0 new messages