Beispiel #1
0
        public bool LoadFor(IWorkingEnvironment environment, Section section)
        {
            Verify.Argument.IsNotNull(environment, nameof(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) when(!exc.IsCritical())
            {
                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);
        }