示例#1
0
        /// <summary>
        /// Load any extra extensions in the search path
        /// </summary>
        /// <param name="commandService">Used to add the commands</param>
        /// <param name="extensionPath">Extension assembly path</param>
        private void LoadExtension(string extensionPath)
        {
            Assembly assembly = null;

            try
            {
                assembly = Assembly.LoadFrom(extensionPath);
            }
            catch (Exception ex) when(ex is IOException || ex is ArgumentException || ex is BadImageFormatException || ex is System.Security.SecurityException)
            {
                _consoleProvider.WriteLineError($"Extension load {extensionPath} FAILED {ex.Message}");
            }
            if (assembly is not null)
            {
                _commandProcessor.AddCommands(assembly);
                _consoleProvider.WriteLine($"Extension loaded {extensionPath}");
            }
        }