mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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;
|
||||
proc.CancelErrorRead();
|
||||
proc.CancelOutputRead();
|
||||
#if NET48
|
||||
if (!proc.HasExited) proc.Kill();
|
||||
#else
|
||||
if (!proc.HasExited) proc.Kill(true);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -101,11 +97,7 @@ namespace SourceGit.Commands {
|
|||
isCancelled = true;
|
||||
proc.CancelErrorRead();
|
||||
proc.CancelOutputRead();
|
||||
#if NET48
|
||||
if (!proc.HasExited) proc.Kill();
|
||||
#else
|
||||
if (!proc.HasExited) proc.Kill(true);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,7 @@ using System.Text.Json;
|
|||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if NET6_0
|
||||
using System.Net.Http;
|
||||
#else
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
#endif
|
||||
|
||||
namespace SourceGit.Models {
|
||||
|
||||
|
@ -50,16 +44,11 @@ namespace SourceGit.Models {
|
|||
Preference.Instance.General.LastCheckDay = curDayOfYear;
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
#if NET6_0
|
||||
var req = new HttpClient();
|
||||
var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
|
||||
rsp.EnsureSuccessStatusCode();
|
||||
|
||||
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 cur = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
Margin="0,0,0,8"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="11"
|
||||
Text="VERSION: v1.0 .NET: v5.0"/>
|
||||
Text="VERSION: v1.0"/>
|
||||
|
||||
<DataGrid
|
||||
x:Name="hotkeys"
|
||||
|
|
|
@ -21,10 +21,7 @@ namespace SourceGit.Views {
|
|||
InitializeComponent();
|
||||
|
||||
var asm = Assembly.GetExecutingAssembly().GetName();
|
||||
var framework = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
|
||||
var dotnetVer = framework.Substring(framework.IndexOf("=") + 1);
|
||||
|
||||
version.Text = $"VERSION : v{asm.Version.Major}.{asm.Version.Minor} .NET : {dotnetVer}";
|
||||
version.Text = $"VERSION : v{asm.Version.Major}.{asm.Version.Minor}";
|
||||
|
||||
hotkeys.ItemsSource = new List<Keymap>() {
|
||||
new Keymap("CTRL + T", "NewTab"),
|
||||
|
@ -39,13 +36,9 @@ namespace SourceGit.Views {
|
|||
}
|
||||
|
||||
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}");
|
||||
info.CreateNoWindow = true;
|
||||
Process.Start(info);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
|
|
|
@ -10,10 +10,7 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
#if NET6_0
|
||||
using System.Net.Http;
|
||||
#endif
|
||||
|
||||
namespace SourceGit.Views.Controls {
|
||||
|
||||
|
@ -196,7 +193,6 @@ namespace SourceGit.Views.Controls {
|
|||
if (!requesting.ContainsKey(email)) return;
|
||||
|
||||
try {
|
||||
#if NET6_0
|
||||
var req = new HttpClient().GetAsync(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
||||
req.Wait();
|
||||
|
||||
|
@ -217,30 +213,6 @@ namespace SourceGit.Views.Controls {
|
|||
} else {
|
||||
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 {
|
||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||
}
|
||||
|
|
|
@ -16,13 +16,9 @@ namespace SourceGit.Views {
|
|||
|
||||
private void Download(object sender, RoutedEventArgs e) {
|
||||
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}");
|
||||
info.CreateNoWindow = true;
|
||||
Process.Start(info);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
|
|
|
@ -72,15 +72,6 @@ namespace SourceGit.Views.Widgets {
|
|||
} else {
|
||||
searching = true;
|
||||
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)
|
||||
|| c.Subject.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)) {
|
||||
visible.Add(c);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -215,11 +215,7 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
if (!added) Changes.Add(c);
|
||||
|
||||
#if NET48
|
||||
int sepIdx = c.Path.IndexOf("/", StringComparison.Ordinal);
|
||||
#else
|
||||
int sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal);
|
||||
#endif
|
||||
if (sepIdx < 0) {
|
||||
GetOrAddTreeNode(Nodes, c.Path, c, false);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue