UniVRM/Scripts/Extensions/TypeExtensions.cs
ousttrue df5f795843 Squashed 'UniJSON/' content from commit 8e22468
git-subtree-dir: UniJSON
git-subtree-split: 8e224689031f2a5e6ea30872e60fe808ddfdc31d
2018-12-28 20:36:46 +09:00

29 lines
728 B
C#

using System;
using System.Linq;
using System.Collections.Generic;
namespace UniJSON
{
public static class TypeExtensions
{
public static bool GetIsGenericList(this Type t)
{
if (t == null) return false;
return t.IsGenericType
&& (t.GetGenericTypeDefinition() == typeof(List<>));
}
public static bool GetIsGenericDictionary(this Type t)
{
if (t == null) return false;
return t.IsGenericType
&& (t.GetGenericTypeDefinition() == typeof(Dictionary<,>)
&& t.GetGenericArguments().FirstOrDefault() == typeof(string)
);
}
}
}