Hi Tim,
Just had a look at your problem, and you are doing everything right.
It looks like is a bug in the order of initialisation of services (is service
is
overridden), so please do log a bug report in
http://issues.castleproject.org/issues/MR
So for now the only way I can see around it is something like this:
public class MyControllerFactory : IServiceEnabledComponent, IControllerFactory
{
private IControllerTree tree;
private IServiceProvider provider;
public IController CreateController(string area, string controller)
{
InitialiseTree();
Debug.Assert(tree != null);
throw new NotImplementedException();
}
public IController CreateController(Type controllerType)
{
InitialiseTree();
Debug.Assert(tree != null);
throw new NotImplementedException();
}
public void Release(IController controller)
{
InitialiseTree();
Debug.Assert(tree != null);
throw new NotImplementedException();
}
public void Service(IServiceProvider provider)
{
this.provider = provider;
}
private void InitialiseTree()
{
if (tree == null)
{
tree = (IControllerTree) provider.GetService(typeof
(IControllerTree));
}
}
}
I hope this helps.
Cheers
John
________________________________
From: Tim <[email protected]>
To: Castle Project Users <[email protected]>
Sent: Fri, 24 September, 2010 9:09:15 PM
Subject: Monorail: Custom ControllerFactory Initialisation
I've been trying to make a custom ControllerFactory and had issues
with finding an initialised IControllerTree to add controllers to.
I decided to copy the complete DefaultControllerFactory.cs into my
assembly and debug how it all worked. I was surprised to find that
DefaultControllerFactory doesn't work if its selected form the
web.config. When it starts to initialise, it too can't find an
initialised IControllerTree.
The services documentation does say that services shouldn't rely on
any initialisation order, but it appears that this essentially what
default services do. How should I be doing it?
My current 'work-around' is to include
"Castle.Monorail.Framework.Services.DefaultControllerTree" before my
ControllerFactory in the web.config as this ensures it is initialised
first!
--
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.
--
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.