-
Notifications
You must be signed in to change notification settings - Fork 0
/
WpfExperimental.linq
78 lines (69 loc) · 3.37 KB
/
WpfExperimental.linq
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
<Query Kind="Program">
<Reference Relative="Frank.Wpf.Controls.Git\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Git.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Controls.Git\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Git.dll</Reference>
<Reference Relative="Frank.Wpf.Controls.Grid\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Grid.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Controls.Grid\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Grid.dll</Reference>
<Reference Relative="Frank.Wpf.Controls.Pages\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Pages.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Controls.Pages\bin\Debug\net8.0-windows\Frank.Wpf.Controls.Pages.dll</Reference>
<Reference Relative="Frank.Wpf.Dialogs\bin\Debug\net8.0-windows\Frank.Wpf.Dialogs.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Dialogs\bin\Debug\net8.0-windows\Frank.Wpf.Dialogs.dll</Reference>
<Reference Relative="Frank.Wpf.Hosting\bin\Debug\net8.0-windows\Frank.Wpf.Hosting.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Hosting\bin\Debug\net8.0-windows\Frank.Wpf.Hosting.dll</Reference>
<Reference Relative="Frank.Wpf.Markdown.Editor\bin\Debug\net8.0-windows\Frank.Wpf.Markdown.Editor.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Markdown.Editor\bin\Debug\net8.0-windows\Frank.Wpf.Markdown.Editor.dll</Reference>
<Reference Relative="Frank.Wpf.Markdown.Previewer\bin\Debug\net8.0-windows\Frank.Wpf.Markdown.Previewer.dll">D:\frankrepos\Frank.Wpf\Frank.Wpf.Markdown.Previewer\bin\Debug\net8.0-windows\Frank.Wpf.Markdown.Previewer.dll</Reference>
<NuGetReference>LibGit2Sharp</NuGetReference>
<NuGetReference>MdXaml</NuGetReference>
<Namespace>Frank.Wpf.Controls.Git</Namespace>
<Namespace>Frank.Wpf.Controls.Grid</Namespace>
<Namespace>Frank.Wpf.Controls.Pages</Namespace>
<Namespace>Frank.Wpf.Dialogs</Namespace>
<Namespace>Frank.Wpf.Hosting</Namespace>
<Namespace>Frank.Wpf.Markdown.Editor</Namespace>
<Namespace>Frank.Wpf.Markdown.Previewer</Namespace>
<Namespace>LibGit2Sharp</Namespace>
<Namespace>MdXaml</Namespace>
<Namespace>Microsoft.Extensions.DependencyInjection</Namespace>
<Namespace>System.Windows</Namespace>
<Namespace>System.Windows.Controls</Namespace>
<Namespace>System.Windows.Media</Namespace>
<Namespace>System.Windows.Shapes</Namespace>
<IncludeUncapsulator>false</IncludeUncapsulator>
<DisableMyExtensions>true</DisableMyExtensions>
<CopyLocal>true</CopyLocal>
<RuntimeVersion>8.0</RuntimeVersion>
</Query>
[STAThread]
void Main()
{
var builder = Host.CreateWpfHostBuilder();
var host = builder.Build<LinqPadWindow>();
host.Run();
}
public class LinqPadWindow : MainWindow
{
public LinqPadWindow()
{
var repository = new Repository(@"D:\frankrepos\Frank.GitKit");
RepositoryViewModel repositoryViewModel = MapToViewModel(repository);
var gitFlow = new GitFlow(repositoryViewModel);
Content = gitFlow;
}
RepositoryViewModel MapToViewModel(Repository repository)
{
var commits = repository.Branches.SelectMany(b =>
b.Commits.Select(c =>
new CommitViewModel
{
ShortMessage = c.MessageShort,
Message = c.Message,
Author = c.Author.Email,
Timestamp = c.Author.When,
BranchHash = b.CanonicalName
})
).ToList();
var branches = repository.Branches.Select(b => new BranchViewModel
{
Name = b.FriendlyName,
Commits = commits.Where(c => c.BranchHash == b.CanonicalName).ToList()
}).ToList();
return new RepositoryViewModel
{
Branches = branches
};
}
}