mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize<*>: remove deprecated apis (older than .NET 6)
This commit is contained in:
parent
890ff29ac7
commit
338f91357e
8 changed files with 677 additions and 749 deletions
|
@ -85,11 +85,7 @@ namespace SourceGit.Commands {
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
proc.CancelErrorRead();
|
proc.CancelErrorRead();
|
||||||
proc.CancelOutputRead();
|
proc.CancelOutputRead();
|
||||||
#if NET48
|
|
||||||
if (!proc.HasExited) proc.Kill();
|
|
||||||
#else
|
|
||||||
if (!proc.HasExited) proc.Kill(true);
|
if (!proc.HasExited) proc.Kill(true);
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +97,7 @@ namespace SourceGit.Commands {
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
proc.CancelErrorRead();
|
proc.CancelErrorRead();
|
||||||
proc.CancelOutputRead();
|
proc.CancelOutputRead();
|
||||||
#if NET48
|
|
||||||
if (!proc.HasExited) proc.Kill();
|
|
||||||
#else
|
|
||||||
if (!proc.HasExited) proc.Kill(true);
|
if (!proc.HasExited) proc.Kill(true);
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,7 @@ using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#if NET6_0
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
#else
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Models {
|
namespace SourceGit.Models {
|
||||||
|
|
||||||
|
@ -50,16 +44,11 @@ namespace SourceGit.Models {
|
||||||
Preference.Instance.General.LastCheckDay = curDayOfYear;
|
Preference.Instance.General.LastCheckDay = curDayOfYear;
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
try {
|
try {
|
||||||
#if NET6_0
|
|
||||||
var req = new HttpClient();
|
var req = new HttpClient();
|
||||||
var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
|
var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
|
||||||
rsp.EnsureSuccessStatusCode();
|
rsp.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var raw = await rsp.Content.ReadAsStringAsync();
|
var raw = await rsp.Content.ReadAsStringAsync();
|
||||||
#else
|
|
||||||
var web = new WebClient() { Encoding = Encoding.UTF8 };
|
|
||||||
var raw = await web.DownloadStringTaskAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
|
|
||||||
#endif
|
|
||||||
var ver = JsonSerializer.Deserialize<Version>(raw);
|
var ver = JsonSerializer.Deserialize<Version>(raw);
|
||||||
var cur = Assembly.GetExecutingAssembly().GetName().Version;
|
var cur = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
Margin="0,0,0,8"
|
Margin="0,0,0,8"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
Text="VERSION: v1.0 .NET: v5.0"/>
|
Text="VERSION: v1.0"/>
|
||||||
|
|
||||||
<DataGrid
|
<DataGrid
|
||||||
x:Name="hotkeys"
|
x:Name="hotkeys"
|
||||||
|
|
|
@ -21,10 +21,7 @@ namespace SourceGit.Views {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
var asm = Assembly.GetExecutingAssembly().GetName();
|
var asm = Assembly.GetExecutingAssembly().GetName();
|
||||||
var framework = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
|
version.Text = $"VERSION : v{asm.Version.Major}.{asm.Version.Minor}";
|
||||||
var dotnetVer = framework.Substring(framework.IndexOf("=") + 1);
|
|
||||||
|
|
||||||
version.Text = $"VERSION : v{asm.Version.Major}.{asm.Version.Minor} .NET : {dotnetVer}";
|
|
||||||
|
|
||||||
hotkeys.ItemsSource = new List<Keymap>() {
|
hotkeys.ItemsSource = new List<Keymap>() {
|
||||||
new Keymap("CTRL + T", "NewTab"),
|
new Keymap("CTRL + T", "NewTab"),
|
||||||
|
@ -39,13 +36,9 @@ namespace SourceGit.Views {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {
|
private void OnRequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {
|
||||||
#if NET48
|
|
||||||
Process.Start(e.Uri.AbsoluteUri);
|
|
||||||
#else
|
|
||||||
var info = new ProcessStartInfo("cmd", $"/c start {e.Uri.AbsoluteUri}");
|
var info = new ProcessStartInfo("cmd", $"/c start {e.Uri.AbsoluteUri}");
|
||||||
info.CreateNoWindow = true;
|
info.CreateNoWindow = true;
|
||||||
Process.Start(info);
|
Process.Start(info);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Quit(object sender, RoutedEventArgs e) {
|
private void Quit(object sender, RoutedEventArgs e) {
|
||||||
|
|
|
@ -10,10 +10,7 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
#if NET6_0
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Views.Controls {
|
namespace SourceGit.Views.Controls {
|
||||||
|
|
||||||
|
@ -196,7 +193,6 @@ namespace SourceGit.Views.Controls {
|
||||||
if (!requesting.ContainsKey(email)) return;
|
if (!requesting.ContainsKey(email)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if NET6_0
|
|
||||||
var req = new HttpClient().GetAsync(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
var req = new HttpClient().GetAsync(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
||||||
req.Wait();
|
req.Wait();
|
||||||
|
|
||||||
|
@ -217,30 +213,6 @@ namespace SourceGit.Views.Controls {
|
||||||
} else {
|
} else {
|
||||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
HttpWebRequest req = WebRequest.CreateHttp(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
|
||||||
req.Timeout = 2000;
|
|
||||||
req.Method = "GET";
|
|
||||||
|
|
||||||
HttpWebResponse rsp = req.GetResponse() as HttpWebResponse;
|
|
||||||
if (rsp.StatusCode == HttpStatusCode.OK) {
|
|
||||||
using (Stream reader = rsp.GetResponseStream())
|
|
||||||
using (FileStream writer = File.OpenWrite(filePath)) {
|
|
||||||
reader.CopyTo(writer);
|
|
||||||
}
|
|
||||||
|
|
||||||
a.Dispatcher.Invoke(() => {
|
|
||||||
var img = new BitmapImage(new Uri(filePath));
|
|
||||||
loaded.Add(email, img);
|
|
||||||
|
|
||||||
if (requesting.ContainsKey(email)) {
|
|
||||||
foreach (var one in requesting[email]) one.Source = img;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} catch {
|
} catch {
|
||||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,9 @@ namespace SourceGit.Views {
|
||||||
|
|
||||||
private void Download(object sender, RoutedEventArgs e) {
|
private void Download(object sender, RoutedEventArgs e) {
|
||||||
var url = $"https://github.com/sourcegit-scm/sourcegit/releases/{Version.TagName}";
|
var url = $"https://github.com/sourcegit-scm/sourcegit/releases/{Version.TagName}";
|
||||||
#if NET48
|
|
||||||
Process.Start(url);
|
|
||||||
#else
|
|
||||||
var info = new ProcessStartInfo("cmd", $"/c start {url}");
|
var info = new ProcessStartInfo("cmd", $"/c start {url}");
|
||||||
info.CreateNoWindow = true;
|
info.CreateNoWindow = true;
|
||||||
Process.Start(info);
|
Process.Start(info);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Quit(object sender, RoutedEventArgs e) {
|
private void Quit(object sender, RoutedEventArgs e) {
|
||||||
|
|
|
@ -72,15 +72,6 @@ namespace SourceGit.Views.Widgets {
|
||||||
} else {
|
} else {
|
||||||
searching = true;
|
searching = true;
|
||||||
foreach (var c in cachedCommits) {
|
foreach (var c in cachedCommits) {
|
||||||
#if NET48
|
|
||||||
if (c.SHA.Contains(filter)
|
|
||||||
|| c.Subject.Contains(filter)
|
|
||||||
|| c.Message.Contains(filter)
|
|
||||||
|| c.Author.Name.Contains(filter)
|
|
||||||
|| c.Committer.Name.Contains(filter)) {
|
|
||||||
visible.Add(c);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (c.SHA.Contains(filter, StringComparison.Ordinal)
|
if (c.SHA.Contains(filter, StringComparison.Ordinal)
|
||||||
|| c.Subject.Contains(filter, StringComparison.Ordinal)
|
|| c.Subject.Contains(filter, StringComparison.Ordinal)
|
||||||
|| c.Message.Contains(filter, StringComparison.Ordinal)
|
|| c.Message.Contains(filter, StringComparison.Ordinal)
|
||||||
|
@ -88,7 +79,6 @@ namespace SourceGit.Views.Widgets {
|
||||||
|| c.Committer.Name.Contains(filter, StringComparison.Ordinal)) {
|
|| c.Committer.Name.Contains(filter, StringComparison.Ordinal)) {
|
||||||
visible.Add(c);
|
visible.Add(c);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,11 +215,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
if (!added) Changes.Add(c);
|
if (!added) Changes.Add(c);
|
||||||
|
|
||||||
#if NET48
|
|
||||||
int sepIdx = c.Path.IndexOf("/", StringComparison.Ordinal);
|
|
||||||
#else
|
|
||||||
int sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal);
|
int sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal);
|
||||||
#endif
|
|
||||||
if (sepIdx < 0) {
|
if (sepIdx < 0) {
|
||||||
GetOrAddTreeNode(Nodes, c.Path, c, false);
|
GetOrAddTreeNode(Nodes, c.Path, c, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue