This project is read-only.

Purpose Of IComponentRegistrarMarker

May 6, 2010 at 5:25 AM

What is the purpose of IComponentRegistrarMarker relative to IComponentRegistrar?

I know they both have something to do with building the catalog of assemblies from which to pull IComponentInitializer classes and run their Initialize(), but what's the diff?

Thanks for any time spent on my basic questions. I am a newb at this... :)

May 6, 2010 at 11:46 AM

IComponentRegistrar defines the contract for a ComponentRegistrar - a type that will be responsible for registering types in that project with the IoC Container.

IComponentRegistrarMarker is simply a marker type - used to allow the subsystem for find types to load - essentially it a nicer workaround than having magic strings and also supports refactoring etc...

 

h

Jul 30, 2010 at 2:20 AM

As a curiosity, ComponentRegistrar.Register looks for the IComponentRegistrarMarker type, and then runs the found IComponentRegistrar:

 

namespace Anitec.SkyNet.Framework.Container
{
    public static class ComponentRegistrar
    {
        public static void Register(IWindsorContainer container)
        {
            var catalog = new CatalogBuilder()
                              .ForAssembly(typeof(IComponentRegistrarMarker).Assembly)
                                                                                          .Build();

            var compositionContainer = new CompositionContainer(catalog);

            compositionContainer
                .GetExports<IComponentRegistrar>>()
                .Each(e => e.Value.Register(container));
        }
    }
}

Is there a reason that ComponentInitialiser.Initialise also looks for the IComponentRegistrarMarker type?

 

namespace Anitec.SkyNet.Framework.Container
{
    public static class ComponentInitialiser
    {
        public static void Initialise()
        {
            var catalog = new CatalogBuilder()
                              .ForAssembly(typeof(IComponentRegistrarMarker).Assembly)
                                                            .Build();

            var compositionContainer = new CompositionContainer(catalog);

            compositionContainer
                .GetExports<IComponentInitialiser>()
                .Each(e => e.Value.Initialise());
        }
    }
}

 

Would it be more clear if it looked for a IComponentInitialiserMarker instead?

Jul 30, 2010 at 2:19 PM
Yes, probably. Looks like a copy-and-paste error.

I'm not going to fix it though - an ex-colleague who is currently working on a SA/WCHM-based app has simplified the MEF code in her codebase and has agreed to make the updates to WCHM as well, so I'm looking forward to a pull request from her at some point in the next couple of weeks. If you're interested, she did a screencast on it - http://www.developerdame.com/?p=199

Cheers
Jon

On 30 July 2010 02:21, martin_aatmaa <notifications@codeplex.com> wrote:

From: martin_aatmaa

As a curiosity, ComponentRegistrar.Register looks for the IComponentRegistrarMarker type, and then runs the found IComponentRegistrar:

 

namespace Anitec.SkyNet.Framework.Container
{
    public static class ComponentRegistrar
    {
        public static void Register(IWindsorContainer container)
        {
            var catalog = new CatalogBuilder()
                              .ForAssembly(typeof(IComponentRegistrarMarker).Assembly)
                                                                                          .Build();

            var compositionContainer = new CompositionContainer(catalog);

            compositionContainer
                .GetExports<IComponentRegistrar>>()
                .Each(e => e.Value.Register(container));
        }
    }
}

Is there a reason that ComponentInitialiser.Initialise also looks for the IComponentRegistrarMarker type?

 

namespace Anitec.SkyNet.Framework.Container
{
    public static class ComponentInitialiser
    {
        public static void Initialise()
        {
            var catalog = new CatalogBuilder()
                              .ForAssembly(typeof(IComponentRegistrarMarker).Assembly)
                                                            .Build();

            var compositionContainer = new CompositionContainer(catalog);

            compositionContainer
                .GetExports<IComponentInitialiser>()
                .Each(e => e.Value.Initialise());
        }
    }
}

 

Would it be more clear if it looked for a IComponentInitialiserMarker instead?

Read the full discussion online.

To add a post to this discussion, reply to this email (whocanhelpme@discussions.codeplex.com)

To start a new discussion for this project, email whocanhelpme@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com