private void ShowGitAccessorSetupControl(IGitAccessorProvider accessorProvider, IGitAccessor accessor) { if (accessorProvider != null) { var type = accessorProvider.GetType(); Tuple <IGitAccessor, DialogBase> cachedControl; if (_cachedControls.TryGetValue(type, out cachedControl)) { ShowGitAccessorSetupControl(cachedControl.Item2); _selectedAccessorProvder = accessorProvider; _selectedAccessor = cachedControl.Item1; } else { if (accessor == null) { accessor = accessorProvider.CreateAccessor(); } Func <IGitAccessor, DialogBase> setupControlFactory; if (_gitAcessorSetupControls.TryGetValue(type, out setupControlFactory)) { var setupControl = setupControlFactory(accessor); ShowGitAccessorSetupControl(setupControl); _cachedControls.Add(type, Tuple.Create(accessor, setupControl)); } _selectedAccessorProvder = accessorProvider; _selectedAccessor = accessor; } } }
/// <summary>Initializes a new instance of the <see cref="GitCLI"/> class.</summary> /// <param name="provider">Provider of this accessor.</param> public GitCLI(IGitAccessorProvider provider) { Verify.Argument.IsNotNull(provider, "provider"); _provider = provider; _executor = new GitCommandExecutor(this); _commandBuilder = new CommandBuilder(this); _outputParser = new OutputParser(this); _autodetectGitExePath = true; _manualGitExePath = string.Empty; GitProcess.GitExePath = GitExecutablePath; GitCliMethod.Create(out _init, this, CommandBuilder.GetInitCommand); GitCliMethod.Create(out _clone, CommandExecutor, CommandBuilder.GetCloneCommand); GitCliMethod.Create(out _queryConfig, CommandExecutor, CommandBuilder.GetQueryConfigCommand, OutputParser.ParseQueryConfigResults); GitCliMethod.Create(out _queryConfigParameter, CommandExecutor, CommandBuilder.GetQueryConfigParameterCommand, OutputParser.ParseQueryConfigParameterResult); GitCliMethod.Create(out _addConfigValue, CommandExecutor, CommandBuilder.GetAddConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _setConfigValue, CommandExecutor, CommandBuilder.GetSetConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _unsetConfigValue, CommandExecutor, CommandBuilder.GetUnsetConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _renameConfigSection, CommandExecutor, CommandBuilder.GetRenameConfigSectionCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _deleteConfigSection, CommandExecutor, CommandBuilder.GetDeleteConfigSectionCommand, OutputParser.HandleConfigResults); }