I want to be able to register controllers in a plug in fashion - so they
need to have their view files as embedded resources.

Like hammett suggested it (in 2007) in this blog entry, I try to get to the
IViewSourceLoader(s) on first request (hackety-hack).
But my container always return null for that service, so I wonder if things
might have changed - for the better maybe...

My code:

private static void addConfiguredControllersFromWebConfig(IWindsorContainer
container)
        {

            var config = ConfigurationManager.GetSection("adminConfig") as
AdminConfigSection;
            if (config == null)
                return;

            var tree = container.GetService<IControllerTree>();
            var loaders = container.ResolveAll<IViewSourceLoader>(); //
getting null here

            if (tree==null || loaders==null)
                return;

            foreach (TypeConfigElement elm in config.Controllers)
            {
                var controllerName = elm.Type.Name.Replace("Controller",
string.Empty);
                tree.AddController(string.Empty, controllerName, elm.Type);
                container
                    .Register(Component.For(elm.Type)
                    .Named(controllerName)
                    .LifeStyle.Transient);

                foreach (var loader in loaders)
                {
                    var ns = elm.Type.Namespace.Replace(".Controllers",
".Views");
                    var info = new AssemblySourceInfo(elm.Type.Assembly,
ns);
                    loader.AddAssemblySource(info);
                }
            }
        }

any idea. also hint of how to do this with less code would be welcome :)
-- 
Jan

-- 
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.

Reply via email to