public bool IsValidFor(string workingDirectory) { if (GitAccessor != null) { return(GitAccessor.IsValidRepository(workingDirectory)); } else { return(false); } }
/// <summary>Save configuration to <paramref name="section"/>.</summary> /// <param name="section"><see cref="Section"/> for storing configuration.</param> public void SaveTo(Section section) { Verify.Argument.IsNotNull(section, "section"); if (ActiveGitAccessorProvider != null) { section.SetValue <string>("AccessorProvider", ActiveGitAccessorProvider.Name); if (GitAccessor != null) { var gitAccessorSection = section.GetCreateSection(ActiveGitAccessorProvider.Name); GitAccessor.SaveTo(gitAccessorSection); } } _configSection = section; }
public bool LoadFor(IWorkingEnvironment environment, Section section) { Verify.Argument.IsNotNull(environment, "environment"); if (section != null) { var providerName = section.GetValue <string>("AccessorProvider", string.Empty); if (!string.IsNullOrWhiteSpace(providerName)) { ActiveGitAccessorProvider = GitAccessorProviders.FirstOrDefault( prov => prov.Name == providerName); } if (ActiveGitAccessorProvider == null) { ActiveGitAccessorProvider = GitAccessorProviders.First(); } var gitAccessorSection = section.TryGetSection(ActiveGitAccessorProvider.Name); if (gitAccessorSection != null) { GitAccessor.LoadFrom(gitAccessorSection); } } else { ActiveGitAccessorProvider = GitAccessorProviders.First(); } Version gitVersion; try { gitVersion = _gitAccessor.GitVersion; } catch (Exception exc) { if (exc.IsCritical()) { throw; } gitVersion = null; } if (gitVersion == null || gitVersion < MinimumRequiredGitVersion) { using (var dlg = new VersionCheckDialog(environment, this, MinimumRequiredGitVersion, gitVersion)) { dlg.Run(environment.MainForm); gitVersion = dlg.InstalledVersion; if (gitVersion == null || gitVersion < _minVersion) { return(false); } } } GlobalOptions.RegisterPropertyPageFactory( new PropertyPageFactory( GitOptionsPage.Guid, Resources.StrGit, null, PropertyPageFactory.RootGroupGuid, env => new GitOptionsPage(env))); GlobalOptions.RegisterPropertyPageFactory( new PropertyPageFactory( ConfigurationPage.Guid, Resources.StrConfig, null, GitOptionsPage.Guid, env => new ConfigurationPage(env))); _environment = environment; _configSection = section; return(true); }