2020-03-26 17:34:32 +00:00
|
|
|
using System;
|
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
|
|
|
|
{
|
2020-03-26 17:34:32 +00:00
|
|
|
public static bool OpenBrowser(string url)
|
2018-08-24 13:10:13 +01:00
|
|
|
{
|
2020-03-26 17:34:32 +00:00
|
|
|
try
|
2020-03-09 19:47:39 +00:00
|
|
|
{
|
2020-03-26 17:34:32 +00:00
|
|
|
#if NETSTANDARD2_0
|
|
|
|
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
|
2020-03-26 17:34:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-24 13:10:13 +01:00
|
|
|
}
|
2020-03-09 19:47:39 +00:00
|
|
|
}
|
2020-03-26 17:34:32 +00:00
|
|
|
}
|