|
|
|
@ -42,6 +42,7 @@ namespace Grpc.Core.Internal |
|
|
|
|
static readonly bool isMono; |
|
|
|
|
static readonly bool isNetCore; |
|
|
|
|
static readonly bool isUnity; |
|
|
|
|
static readonly bool isUnityIOS; |
|
|
|
|
static readonly bool isXamarin; |
|
|
|
|
static readonly bool isXamarinIOS; |
|
|
|
|
static readonly bool isXamarinAndroid; |
|
|
|
@ -63,7 +64,25 @@ namespace Grpc.Core.Internal |
|
|
|
|
isNetCore = false; |
|
|
|
|
#endif |
|
|
|
|
isMono = Type.GetType("Mono.Runtime") != null; |
|
|
|
|
isUnity = Type.GetType(UnityEngineApplicationClassName) != null; |
|
|
|
|
|
|
|
|
|
// Unity |
|
|
|
|
var unityApplicationClass = Type.GetType(UnityEngineApplicationClassName); |
|
|
|
|
if (unityApplicationClass != null) |
|
|
|
|
{ |
|
|
|
|
isUnity = true; |
|
|
|
|
// Consult value of Application.platform via reflection |
|
|
|
|
// https://docs.unity3d.com/ScriptReference/Application-platform.html |
|
|
|
|
var platformProperty = unityApplicationClass.GetTypeInfo().GetProperty("platform"); |
|
|
|
|
var unityRuntimePlatform = platformProperty?.GetValue(null)?.ToString(); |
|
|
|
|
isUnityIOS = (unityRuntimePlatform == "IPhonePlayer"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
isUnity = false; |
|
|
|
|
isUnityIOS = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Xamarin |
|
|
|
|
isXamarinIOS = Type.GetType(XamarinIOSObjectClassName) != null; |
|
|
|
|
isXamarinAndroid = Type.GetType(XamarinAndroidObjectClassName) != null; |
|
|
|
|
isXamarin = isXamarinIOS || isXamarinAndroid; |
|
|
|
@ -97,6 +116,14 @@ namespace Grpc.Core.Internal |
|
|
|
|
get { return isUnity; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// true if running on Unity iOS, false otherwise. |
|
|
|
|
/// </summary> |
|
|
|
|
public static bool IsUnityIOS |
|
|
|
|
{ |
|
|
|
|
get { return isUnityIOS; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// true if running on a Xamarin platform (either Xamarin.Android or Xamarin.iOS), |
|
|
|
|
/// false otherwise. |
|
|
|
|