/// <summary> /// Initializes the singleton instance /// </summary> /// <param name="progressCallback"></param> /// <returns></returns> public Task <bool> Initialize(Action <int, string> progressCallback) => Task.Factory.StartNew(delegate { try { progressCallback?.Invoke(-1, "Adding the current assembly to the catalog..."); CompositionCatalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly)); if (Directory.Exists(Properties.Settings.Default.PluginsPath)) { progressCallback?.Invoke(50, "Loading Plugins..."); CompositionCatalog.Catalogs.Add(new DirectoryCatalog(Properties.Settings.Default.PluginsPath)); } progressCallback?.Invoke(50, "Creatng app controller..."); CompositionCatalog.CreateCompositionService().SatisfyImportsOnce(this); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } }, TaskCreationOptions.LongRunning);
public DiContainer(CompositionCatalog catalog) { _catalog = catalog; _parts = new ConcurrentDictionary <ExportDefinition, IComposablePart>(); }