This project has moved. For the latest updates, please go here.

Register components using ReflectionContext after TypeCatalog creation

Mar 1, 2011 at 8:44 PM
Edited Mar 1, 2011 at 8:47 PM

Is it possible to add new type in the RegistrationBuilder after the TypeCatalog has been created?

What I would like to do is to access the ReflectionContext of a TypeCatalog and register types any time in the lifetime of the application (after the TypeCatalog has been created).

(see the lines with bold)

public void ExportInterfaceWithTypeOf1()
    var ctx = new RegistrationBuilder();
    var catalog = new TypeCatalog(Helpers.GetEnumerableOfTypes(typeof(CFoo)), ctx);
    Assert.IsTrue(catalog.Parts.Count() != 0);

    var container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
    var importer = new FooImporter();

   Assert.IsNotNull(importer.fooImporter, "fooImporter not set!");

    ctx.OfType<CFoo2>().Export<IFoo>((c) => c.Named("concreteA"));     
    ctx.OfType<CFoo3>().Export<IFoo>((c) => c.Named("concreteB"));