/// <summary> /// Gets or creates the UI state for a named <see cref="IGitHubConnectSection"/>. /// </summary> /// <param name="sectionName">The name of the section.</param> /// <returns>A <see cref="GitHubConnectSectionState"/> object.</returns> public GitHubConnectSectionState GetOrCreateConnectSection(string sectionName) { var result = GitHubConnectSections.FirstOrDefault(x => x.SectionName == sectionName); if (result == null) { result = new GitHubConnectSectionState { SectionName = sectionName }; GitHubConnectSections.Add(result); } return result; }
/// <summary> /// Gets or creates the UI state for a named <see cref="IGitHubConnectSection"/>. /// </summary> /// <param name="sectionName">The name of the section.</param> /// <returns>A <see cref="GitHubConnectSectionState"/> object.</returns> public GitHubConnectSectionState GetOrCreateConnectSection(string sectionName) { var result = GitHubConnectSections.FirstOrDefault(x => x.SectionName == sectionName); if (result == null) { result = new GitHubConnectSectionState { SectionName = sectionName }; GitHubConnectSections.Add(result); } return(result); }
protected void Refresh(IConnection connection) { if (connection == null) { LoggedIn = false; IsVisible = false; SectionConnection = null; if (Repositories != null) Repositories.CollectionChanged -= UpdateRepositoryList; Repositories = null; settings = null; if (sectionIndex == 0 && ServiceProvider != null) { var section = GetSection(TeamExplorerInvitationBase.TeamExplorerInvitationSectionGuid); IsVisible = !(section?.IsVisible ?? true); // only show this when the invitation section is hidden. When in doubt, don't show it. if (section != null) section.PropertyChanged += (s, p) => { if (p.PropertyName == "IsVisible") IsVisible = LoggedIn || !((ITeamExplorerSection)s).IsVisible; }; } } else { if (connection != SectionConnection) { SectionConnection = connection; Repositories = SectionConnection.Repositories.CreateDerivedCollection(x => x, orderer: OrderedComparer<ILocalRepositoryModel>.OrderBy(x => x.Name).Compare); Repositories.CollectionChanged += UpdateRepositoryList; Title = connection.HostAddress.Title; IsVisible = true; LoggedIn = true; if (ServiceProvider != null) RefreshRepositories().Forget(); settings = packageSettings.UIState.GetOrCreateConnectSection(Title); IsExpanded = settings.IsExpanded; } } }