2018-08-24 13:10:13 +01:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Auth
|
|
|
|
|
{
|
|
|
|
|
internal static class AuthUtil
|
|
|
|
|
{
|
|
|
|
|
public static void OpenBrowser(string url)
|
|
|
|
|
{
|
2018-09-04 13:39:07 +01:00
|
|
|
|
#if NETSTANDARD2_0
|
2018-08-24 13:10:13 +01: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
|
|
|
|
|
url = url.Replace("&", "^&");
|
|
|
|
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
|
|
|
|
#endif
|
2018-08-24 13:10:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|