PluginCollection <IGitBranchPlugin> DoFindOrCreate(bool ensureFirstLoad, string branchName, IActivityMonitor m = null) { if (String.IsNullOrWhiteSpace(branchName)) { throw new ArgumentNullException(nameof(branchName)); } if (!_branchPlugins.TryGetValue(branchName, out var c) || (ensureFirstLoad && !c.IsFirstLoadDone)) { using (ensureFirstLoad && m != null ? m.OpenTrace($"Initializing plugins for '{_manager.Registry.FolderPath}' branch '{branchName}'.") : null) { try { _manager._plugins.EnsureFirstLoad(); if (c == null) { c = new PluginCollection <IGitBranchPlugin>(_manager, branchName); _branchPlugins.Add(branchName, ensureFirstLoad ? c.EnsureFirstLoad() : c); } else { c.EnsureFirstLoad(); } } catch (Exception ex) { if (m == null) { throw; } m.Error(ex); return(null); } } } return(c); }