2020-03-09 19:47:39 +00:00
|
|
|
using System.Diagnostics;
|
2018-08-24 13:10:13 +01:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Auth
|
|
|
|
{
|
2020-03-09 19:47:39 +00:00
|
|
|
internal static class AuthUtil
|
|
|
|
{
|
|
|
|
public static void OpenBrowser(string url)
|
2018-08-24 13:10:13 +01:00
|
|
|
{
|
2018-09-04 13:39:07 +01:00
|
|
|
#if NETSTANDARD2_0
|
2020-03-09 19:47:39 +00:00
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
{
|
|
|
|
url = url.Replace("&", "^&");
|
|
|
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
|
|
|
}
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
{
|
|
|
|
Process.Start("xdg-open", url);
|
|
|
|
}
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
|
{
|
|
|
|
Process.Start("open", url);
|
|
|
|
}
|
2018-09-04 13:39:07 +01:00
|
|
|
#else
|
2020-03-09 19:47:39 +00:00
|
|
|
url = url.Replace("&", "^&");
|
|
|
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
2018-09-04 13:39:07 +01:00
|
|
|
#endif
|
2018-08-24 13:10:13 +01:00
|
|
|
}
|
2020-03-09 19:47:39 +00:00
|
|
|
}
|
2018-08-24 13:10:13 +01:00
|
|
|
}
|