This project has moved and is read-only. For the latest updates, please go here.

Two stage composition?

Feb 17, 2011 at 5:42 PM
Edited Feb 17, 2011 at 5:45 PM


I'm in a situation where the optimum solution would be to first compose just one property of an object (the object implementing the Compose method) and then all the rest.

The idea is that the object composed onto the first property then gets me lots of paths for other assemblies. Here's some Code:

class X
    CAD_PointTool.Contracts.CAD_IPointTool _Env { get; set; }
    public IEnumerable<CAD_NoGui_AddOn.Contracts.ICAD_NoGui_AddOn> _RawAddOns { get; set; }

    void Compose()
      TypeCatalog EnvCat = new TypeCatalog(typeof(DxDPointTool.DxDPointTool));
      // Now compose _Env
      // How?
      // After that we are set up for the real Compose:
      List <ComposablePartCatalog> CatList = new List<ComposablePartCatalog>();
      foreach (FileInfo Assembly in _Env.GetAssemblies())
        CatList.Add(new CAD_MEFSupport.CAD_AssemblyCatalog(Assembly));
      CompositionContainer CheckCont = new CompositionContainer(new AggregateCatalog(CatList.ToArray()));

The CheckCont.ComposeParts(this) fills the _RawAddOns IEnumerable with the parts contained in the assemblies given bey _Env.

Is this possible?

Lots of Greetings!