This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathUIState.cs
More file actions
79 lines (69 loc) · 2.63 KB
/
Copy pathUIState.cs
File metadata and controls
79 lines (69 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using GitHub.Settings;
using System.Linq;
using GitHub.VisualStudio.TeamExplorer.Connect;
namespace GitHub.Settings
{
/// <summary>
/// Stores persistent UI state in <see cref="IPackageSettings"/>.
/// </summary>
public class UIState
{
PullRequestDetailUIState prState = new PullRequestDetailUIState();
/// <summary>
/// Gets or sets the UI state for the <see cref="IGitHubConnectSection"/>s in Team Explorer.
/// </summary>
public List<GitHubConnectSectionState> GitHubConnectSections { get; set; }
= new List<GitHubConnectSectionState>();
/// <summary>
/// Gets or sets a a collection of UI state objects for repositories.
/// </summary>
public List<RepositoryUIState> RepositoryState { get; set; }
= new List<RepositoryUIState>();
/// <summary>
/// Gets or sets global settings for the Pull Request detail view.
/// </summary>
public PullRequestDetailUIState PullRequestDetailState
{
get { return prState; }
set
{
if (value != null)
{
prState = value;
}
}
}
/// <summary>
/// Gets or creates the UI state for a repository.
/// </summary>
/// <param name="repositoryUrl">The URL of the repository.</param>
/// <returns>A <see cref="RepositoryUIState"/> object.</returns>
public RepositoryUIState GetOrCreateRepositoryState(string repositoryUrl)
{
var result = RepositoryState.FirstOrDefault(x => x.RepositoryUrl == repositoryUrl);
if (result == null)
{
result = new RepositoryUIState { RepositoryUrl = repositoryUrl };
RepositoryState.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;
}
}
}