forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeExtensions.cs
More file actions
25 lines (23 loc) · 720 Bytes
/
Copy pathTypeExtensions.cs
File metadata and controls
25 lines (23 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
namespace MLAPI.Reflection
{
internal static class TypeExtensions
{
internal static bool HasInterface(this Type type, Type interfaceType)
{
Type[] interfaces = type.GetInterfaces();
for (int i = 0; i < interfaces.Length; i++)
{
if (interfaces[i] == interfaceType)
return true;
}
return false;
}
internal static bool IsNullable(this Type type)
{
if (!type.IsValueType) return true; // ref-type
if (Nullable.GetUnderlyingType(type) != null) return true; // Nullable<T>
return false; // value-type
}
}
}