-
Notifications
You must be signed in to change notification settings - Fork 495
Expand file tree
/
Copy pathBinaryFileViewer.cs
More file actions
66 lines (56 loc) · 1.61 KB
/
Copy pathBinaryFileViewer.cs
File metadata and controls
66 lines (56 loc) · 1.61 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
using System.IO;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
{
public class BinaryFileViewer : ObservableObject
{
public string File
{
get => _file;
}
public bool IsLoading
{
get => _isLoading;
private set => SetProperty(ref _isLoading, value);
}
public Models.BinaryFile Content
{
get => _content;
private set => SetProperty(ref _content, value);
}
public BinaryFileViewer(string repo, string file, string revision)
{
_repo = repo;
_file = file;
_revision = revision;
}
public async Task LoadAsync()
{
if (_revision != null)
{
string saveTo = Path.GetTempFileName();
await Commands.SaveRevisionFile.RunAsync(_repo, _revision, _file, saveTo);
Content = new Models.BinaryFile(saveTo, true);
}
else
{
Content = new Models.BinaryFile(Path.Combine(_repo, _file), false);
}
IsLoading = false;
}
public void Cleanup()
{
_repo = null;
_file = null;
_revision = null;
_content?.Dispose();
_content = null;
}
private bool _isLoading = true;
private string _repo = null;
private string _file = null;
private string _revision = null;
private Models.BinaryFile _content = null;
}
}