/// <summary> /// Initializes a new plugin manager. /// </summary> /// <param name="registry">The registry of plugins.</param> /// <param name="baseProvider">The base service provider.</param> /// <param name="commandRegister">Command registerer.</param> /// <param name="defaultBranchName">The default branch name (typically "develop"). Must not be null or empty.</param> public GitPluginManager(GitPluginRegistry registry, ISimpleServiceContainer baseProvider, CommandRegister commandRegister, string defaultBranchName) { if (String.IsNullOrWhiteSpace(defaultBranchName)) { throw new ArgumentNullException(nameof(defaultBranchName)); } ServiceContainer = new SimpleServiceContainer(baseProvider); _defaultBranchName = defaultBranchName; _commandRegister = commandRegister ?? throw new ArgumentNullException(nameof(commandRegister)); Registry = registry; _plugins = new PluginCollection <IGitPlugin>(this, null); _branches = new Branches(this); }
void Reset() { var pluginKeys = _mappings.Keys.Where(k => GitPluginRegistry.IsGitFolderPlugin(k)).ToList(); foreach (var k in pluginKeys) { var p = _mappings[k]; if (p is ICommandMethodsProvider commandProvider) { _manager._commandRegister.Unregister(commandProvider); } if (p is IDisposable disposable) { disposable.Dispose(); } _mappings.Remove(k); } }