public void Compose(BaseParameters parameters) { try { var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()), new AssemblyCatalog(typeof(Logic.SanityCheck).Assembly)); LoadPlugins(catalog, parameters); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); batch.AddPart(parameters); var config = new Configuration(parameters.FileSystem, parameters.Path); config.ReadFromFile(); batch.AddExportedValue((IConfiguration)config); container.Compose(batch); } catch (ReflectionTypeLoadException ex) { Console.WriteLine(@"Unable to load: \r\n{0}", string.Join("\r\n", ex.LoaderExceptions.Select(e => e.Message))); throw; } }
private void Run(string[] args, BaseParameters baseParameters) { if (Commands[baseParameters.CommandName] == null) { Console.WriteLine(@"Can't find command ""{0}""", baseParameters.CommandName); Commands.WriteHelp(baseParameters.Options); return; } Commands[baseParameters.CommandName].Execute(baseParameters.CommandArgs); WaitForClose(); }
public void Compose(BaseParameters parameters) { try { var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly())); LoadPlugins(catalog, parameters); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); batch.AddPart(parameters); container.Compose(batch); } catch (ReflectionTypeLoadException ex) { Console.WriteLine(@"Unable to load: \r\n{0}", string.Join("\r\n", ex.LoaderExceptions.Select(e => e.Message))); throw; } }
private void LoadPlugins(AggregateCatalog catalog, BaseParameters parameters) { if (!parameters.Safe) { var pluginsPath = Path.Combine(parameters.Path, "_plugins"); if (Directory.Exists(pluginsPath)) { catalog.Catalogs.Add(new DirectoryCatalog(pluginsPath)); AddScriptCs(catalog, pluginsPath); } } }