"Assets/Scripts/UI/NetwMenu/updateMouseCursor.cs.meta" did not exist on "c504095b4e712d542ae55b023e6304f900d5e114"
Newer
Older
MaZiFAU
committed
using System;
using System.Collections.Generic;
using System.Linq;
public class FuncExtensions
{
public static readonly Type[] GenericFuncTypes = new Type[]
MaZiFAU
committed
{
//typeof(Action),
typeof(Func<>),
typeof(Func<,>),
typeof(Func<,,>),
typeof(Func<,,,>),
typeof(Func<,,,,>),
typeof(Func<,,,,,>),
typeof(Func<,,,,,,>),
typeof(Func<,,,,,,,>),
typeof(Func<,,,,,,,,>),
typeof(Func<,,,,,,,,,>),
typeof(Func<,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,,,,,>),
typeof(Func<,,,,,,,,,,,,,,,,>),
MaZiFAU
committed
};
private static readonly IReadOnlyDictionary<Type, int> GenericFuncSignature =
GenericFuncTypes.ToDictionary(t => t, t => t.IsGenericType ? t.GetGenericArguments().Count() : 0);
public static Type GetGenericFuncType(int signatureCount)
=> GenericFuncTypes[signatureCount - 1];
public static bool IsFuncType(Type type, out int signatureCount)
=> GenericFuncSignature.TryGetValue(
type.IsGenericType ? type.GetGenericTypeDefinition() : type,
out signatureCount
);
public static Type CreateFuncType(Type[] signature)
=> GetGenericFuncType(signature.Length)
.MakeGenericType(signature);
}