Skip to content

Commit 1d4395a

Browse files
committed
more editor work
1 parent 8e8f2b1 commit 1d4395a

File tree

15 files changed

+656
-955
lines changed

15 files changed

+656
-955
lines changed

Framework/Intersect.Framework.Core/Web/IntersectHttpClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net;
22
using System.Net.Http.Headers;
3+
using System.Security.Authentication;
34
using System.Security.Cryptography;
45
using System.Text;
56
using Intersect.Core;
@@ -13,8 +14,9 @@ public partial class IntersectHttpClient : HttpClient
1314
{
1415
private static HttpClientHandler GetHttpClientHandler()
1516
{
16-
return new()
17+
return new HttpClientHandler
1718
{
19+
// SslProtocols = SslProtocols.Tls12,
1820
ServerCertificateCustomValidationCallback = (request, certificate, chain, policyErrors) =>
1921
{
2022
var host = request.RequestUri?.Host;
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics;
2+
23
// ReSharper disable MemberCanBePrivate.Global
34

45
namespace Intersect.Framework.Utilities;
@@ -7,11 +8,16 @@ public static class BrowserHelper
78
{
89
public static void Open(string url)
910
{
10-
Process.Start(new ProcessStartInfo(url)
11-
{
12-
UseShellExecute = true,
13-
});
11+
Process.Start(
12+
new ProcessStartInfo(url)
13+
{
14+
UseShellExecute = true,
15+
}
16+
);
1417
}
1518

16-
public static void Open(Uri uri) => Open(uri.AbsoluteUri);
17-
}
19+
public static void Open(Uri uri)
20+
{
21+
Open(uri.AbsoluteUri);
22+
}
23+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using System.Diagnostics;
2+
using System.Diagnostics.CodeAnalysis;
3+
using System.Reflection;
4+
using System.Text;
5+
6+
namespace Intersect.Framework.Utilities;
7+
8+
public static class ProcessHelper
9+
{
10+
public static bool TryLaunchWithArgs(string executable, params string[] args)
11+
{
12+
var arguments = string.Join(
13+
' ',
14+
args.Where(arg => arg == "--restarting").Take(args.Length - 1).Append("--restarting")
15+
);
16+
17+
try
18+
{
19+
Console.WriteLine(
20+
$"Launching '{executable}' with arguments '{arguments}' in {Environment.CurrentDirectory}"
21+
);
22+
Process.Start(executable, arguments);
23+
Environment.Exit(0);
24+
return true;
25+
}
26+
catch (Exception exception)
27+
{
28+
StringBuilder exceptionText = new();
29+
30+
var currentException = exception;
31+
while (currentException != default)
32+
{
33+
if (currentException != exception)
34+
{
35+
exceptionText.Append("Caused by ");
36+
}
37+
38+
exceptionText.AppendLine(exception.Message);
39+
var stackTrace = exception.StackTrace;
40+
if (string.IsNullOrEmpty(stackTrace))
41+
{
42+
exceptionText.AppendLine(stackTrace);
43+
}
44+
45+
currentException = currentException.InnerException;
46+
}
47+
48+
Console.Error.WriteLine(exceptionText);
49+
50+
return false;
51+
}
52+
}
53+
54+
public static bool TryRelaunch()
55+
{
56+
var args = Environment.GetCommandLineArgs();
57+
var childProcessArgs = args.Skip(1).ToArray();
58+
return TryRelaunchWithArgs(childProcessArgs);
59+
}
60+
61+
public static bool TryRelaunchWithArgs(params string[] args)
62+
{
63+
if (!TryGetPathToEntryAssembly(out var pathToEntryAssembly))
64+
{
65+
Console.WriteLine("No path to entry assembly");
66+
return false;
67+
}
68+
69+
return TryLaunchWithArgs(pathToEntryAssembly, args);
70+
}
71+
72+
public static bool TryGetPathToEntryAssembly([NotNullWhen(true)] out string? pathToEntryAssembly)
73+
{
74+
pathToEntryAssembly = Assembly.GetEntryAssembly()?.Location;
75+
76+
#if !DEBUG
77+
if (string.IsNullOrWhiteSpace(pathToEntryAssembly))
78+
{
79+
pathToEntryAssembly = Environment.GetCommandLineArgs().FirstOrDefault();
80+
}
81+
#endif
82+
83+
return !string.IsNullOrWhiteSpace(pathToEntryAssembly);
84+
}
85+
86+
public static bool TryReplaceTargetWithEntryAssembly(string pathToTarget)
87+
{
88+
return TryReplaceTargetWithEntryAssembly(new FileInfo(pathToTarget));
89+
}
90+
91+
public static bool TryReplaceTargetWithEntryAssembly(FileInfo targetFileInfo)
92+
{
93+
if (!TryGetPathToEntryAssembly(out var pathToEntryAssembly))
94+
{
95+
Console.Error.WriteLine("Failed to get path to entry assembly");
96+
return false;
97+
}
98+
99+
FileInfo entryAssemblyFileInfo = new(pathToEntryAssembly);
100+
101+
try
102+
{
103+
entryAssemblyFileInfo.CopyTo(targetFileInfo.FullName, true);
104+
return true;
105+
}
106+
catch (Exception exception)
107+
{
108+
Console.Error.WriteLine(
109+
$"Failed to copy \"{entryAssemblyFileInfo.FullName}\" to \"{targetFileInfo.FullName}\""
110+
);
111+
Console.Error.WriteLine(exception.Message);
112+
return false;
113+
}
114+
}
115+
}

Intersect (Core)/Updater/Update.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Intersect (Core)/Updater/UpdateFile.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

Intersect (Core)/Updater/UpdateStatus.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)