Monorail Services w/ Windsor Integration (on trunk)

17 views
Skip to first unread message

Mike Thomas

unread,
Mar 13, 2008, 3:04:06 AM3/13/08
to Castle Project Users
(background: I'm learning MonoRail the hard way - building a plugable
CMS system - it like learning to swim by being tossed into an ocean)

I just want to clarify my understanding on something and see if it is
working how it should :) In my project I need to interact dynamically
with some MonoRail services. Specifically the IViewSourceLoader.
What confuses me is what the *best way* to get that is. For example
Container.Resolve<IControllerTree>() -> works and returns the
IControllerTree service/implenentation
Container.Resolve<IViewSourceLoader>() -> fails... I can only access
the IViewSourceLoader directly through the MonoRailContainer or
through IMonoRailContainerEvents.Initialized...

So, the question is, why can some services be found in the Container
but not others?

Hamilton Verissimo

unread,
Mar 13, 2008, 9:53:03 AM3/13/08
to castle-pro...@googlegroups.com
On 3/13/08, Mike Thomas <mbth...@gmail.com> wrote:
>
> (background: I'm learning MonoRail the hard way - building a plugable
> CMS system - it like learning to swim by being tossed into an ocean)

Agreed.

> I just want to clarify my understanding on something and see if it is
> working how it should :) In my project I need to interact dynamically
> with some MonoRail services. Specifically the IViewSourceLoader.
> What confuses me is what the *best way* to get that is. For example
> Container.Resolve<IControllerTree>() -> works and returns the
> IControllerTree service/implenentation
> Container.Resolve<IViewSourceLoader>() -> fails... I can only access
> the IViewSourceLoader directly through the MonoRailContainer or
> through IMonoRailContainerEvents.Initialized...
>
> So, the question is, why can some services be found in the Container
> but not others?

Because the Windsor Integration replaces some of MonoRail default
services. You're requesting one of them (IControllerTree).
IViewSourceLoader is not one of them.

What I do is:

public class Global : HttpApplication, IContainerAccessor,
IMonoRailContainerEvents
{
.......

public void Initialized(IMonoRailContainer mrContainer)
{
container.Register(
Component.For<IViewSourceLoader>().Instance(mrContainer.ViewSourceLoader));
}

--
Cheers,
hamilton verissimo
ham...@castlestronghold.com
http://www.castlestronghold.com/

Mike Thomas

unread,
Mar 13, 2008, 11:06:05 AM3/13/08
to castle-pro...@googlegroups.com
Ahh... that makes sense.
Reply all
Reply to author
Forward
0 new messages