23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace TapTap.Common.Internal.Utils {
|
|
public static class BridgeUtils {
|
|
public static bool IsSupportMobilePlatform => Application.platform == RuntimePlatform.Android ||
|
|
Application.platform == RuntimePlatform.IPhonePlayer;
|
|
|
|
public static bool IsSupportStandalonePlatform => Application.platform == RuntimePlatform.OSXPlayer ||
|
|
Application.platform == RuntimePlatform.WindowsPlayer ||
|
|
Application.platform == RuntimePlatform.LinuxPlayer;
|
|
|
|
public static object CreateBridgeImplementation(Type interfaceType, string startWith) {
|
|
Type bridgeImplementationType = AppDomain.CurrentDomain.GetAssemblies()
|
|
.Where(asssembly => asssembly.GetName().FullName.StartsWith(startWith))
|
|
.SelectMany(assembly => assembly.GetTypes())
|
|
.SingleOrDefault(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass);
|
|
return Activator.CreateInstance(bridgeImplementationType);
|
|
}
|
|
}
|
|
}
|