Hi there
Cannot accomplish the simple thing: import a singleton instance of the class to the places where it is needed.
Here is my export declaration:
[PartCreationPolicy(CreationPolicy.Shared)] [Export] public class SelfScheduleMainVM : BaseController, IBroadcasting {...
In the class which needs it, there is an import declaration:
[Import(RequiredCreationPolicy = CreationPolicy.Shared)] public SelfScheduleMainVM MainVM;
and constractor of that class instantiates it:
var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(SelfScheduleMainVM).Assembly)); new CompositionContainer(catalog).ComposeParts(this);
I got the instance of MainVM, but! It is the new instance, not the class which I need to be shared as a singleton.
How to fix it?
Thanks.