Exemplo n.º 1
0
        internal static void GetUncurried0(Type func, ref Typed_RefReturn_Wrapped_Huge.Collections.Generic.List <Type> list)
        {
            var t    = func.GetGenericTypeDefinition();
            var gtas = func.GenericTypeArguments;

            for (var i = 0; gtas.Length - 1 > i; ++i)
            {
                list.Add(gtas[i]);
            }
            var r = gtas[gtas.Length - 1];

            if (r.IsGenericType)
            {
                GetUncurried0(gtas[gtas.Length - 1], ref list);
            }
            else
            {
                list.Add(r);
            }
            return;
        }
Exemplo n.º 2
0
        public static Type GetUncurried(Type func)
        {
            if (func.IsGenericType)
            {
                var t    = func.GetGenericTypeDefinition();
                var gtas = func.GenericTypeArguments;
                var list = new Typed_RefReturn_Wrapped_Huge.Collections.Generic.List <Type>(17);
                for (var i = 0; gtas.Length - 1 > i; ++i)
                {
                    list.Add(gtas[i]);
                }
                var r = gtas[gtas.Length - 1];
                if (r.IsGenericType)
                {
                    GetUncurried0(r, ref list);
                }
                else
                {
                    list.Add(r);
                }
                var ts = list.ToArray();
                switch (ts.Length)
                {
                case 0:
                    throw new NotSupportedException();

                case 1:
                    return(ts[0]);

                case 2:
                    return(typeof(Func <,>).MakeGenericType(ts));

                case 3:
                    return(typeof(Func <, ,>).MakeGenericType(ts));

                case 4:
                    return(typeof(Func <, , ,>).MakeGenericType(ts));

                case 5:
                    return(typeof(Func <, , , ,>).MakeGenericType(ts));

                case 6:
                    return(typeof(Func <, , , , ,>).MakeGenericType(ts));

                case 7:
                    return(typeof(Func <, , , , , ,>).MakeGenericType(ts));

                case 8:
                    return(typeof(Func <, , , , , , ,>).MakeGenericType(ts));

                case 9:
                    return(typeof(Func <, , , , , , , ,>).MakeGenericType(ts));

                case 10:
                    return(typeof(Func <, , , , , , , , ,>).MakeGenericType(ts));

                case 11:
                    return(typeof(Func <, , , , , , , , , ,>).MakeGenericType(ts));

                case 12:
                    return(typeof(Func <, , , , , , , , , , ,>).MakeGenericType(ts));

                case 13:
                    return(typeof(Func <, , , , , , , , , , , ,>).MakeGenericType(ts));

                case 14:
                    return(typeof(Func <, , , , , , , , , , , , ,>).MakeGenericType(ts));

                case 15:
                    return(typeof(Func <, , , , , , , , , , , , , ,>).MakeGenericType(ts));

                case 16:
                    return(typeof(Func <, , , , , , , , , , , , , , ,>).MakeGenericType(ts));

                case 17:
                    return(typeof(Func <, , , , , , , , , , , , , , , ,>).MakeGenericType(ts));

                default:
                    throw new PlatformNotSupportedException();
                }
            }
            return(func);
        }
Exemplo n.º 3
0
        public static IEnumerable <Type> GetCurryingFamily(Type func)
        {
            if (func.IsGenericType)
            {
                var t    = func.GetGenericTypeDefinition();
                var gtas = func.GenericTypeArguments;
                var list = new Typed_RefReturn_Wrapped_Huge.Collections.Generic.List <Type>(17);
                for (var i = 0; gtas.Length - 1 > i; ++i)
                {
                    list.Add(gtas[i]);
                }
                var r = gtas[gtas.Length - 1];
                if (r.IsGenericType)
                {
                    GetUncurried0(r, ref list);
                }
                else
                {
                    list.Add(r);
                }
                var ts  = list.ToArray();
                var res = (IEnumerable <Type>)null;
                switch (ts.Length)
                {
                case 0:
                    throw new NotSupportedException();

                case 1:
                    return(new SingletonEnumerable <Type>(ts[0]));

                case 2:
                    return(new SingletonEnumerable <Type>(typeof(Func <,>).MakeGenericType(ts)));

                case 3:
                    res = new Type[] {
                        GetFunc(ts[0], GetFunc(ts[1], ts[2])),
                        typeof(Func <, ,>).MakeGenericType(ts),
                    };
                    return(res);

                case 4:
                    res = new Type[] {
                        GetFunc(ts[0], GetFunc(ts[1], GetFunc(ts[2], ts[3]))),
                        GetFunc(ts[0], ts[1], GetFunc(ts[2], ts[3])),
                        GetFunc(ts[0], GetFunc(ts[1], ts[2], ts[3])),
                        typeof(Func <, , ,>).MakeGenericType(ts),
                    };
                    return(res);

                case 5:
                    res = new Type[] {
                        GetFunc(ts[0], GetFunc(ts[1], GetFunc(ts[2], GetFunc(ts[3], ts[4])))),
                        GetFunc(ts[0], ts[1], GetFunc(ts[2], GetFunc(ts[3], ts[4]))),
                        GetFunc(ts[0], GetFunc(ts[1], ts[2], GetFunc(ts[3], ts[4]))),
                        GetFunc(ts[0], ts[1], ts[2], GetFunc(ts[3], ts[4])),
                        GetFunc(ts[0], GetFunc(ts[1], GetFunc(ts[2], ts[3], ts[4]))),
                        GetFunc(ts[0], ts[1], GetFunc(ts[2], ts[3], ts[4])),
                        GetFunc(ts[0], GetFunc(ts[1], ts[2], ts[3], ts[4])),
                        typeof(Func <, , , ,>).MakeGenericType(ts),
                    };
                    return(res);

                case 6:
                    throw new NotImplementedException();

                case 7:
                    throw new NotImplementedException();

                case 8:
                    throw new NotImplementedException();

                case 9:
                    throw new NotImplementedException();

                case 10:
                    throw new NotImplementedException();

                case 11:
                    throw new NotImplementedException();

                case 12:
                    throw new NotImplementedException();

                case 13:
                    throw new NotImplementedException();

                case 14:
                    throw new NotImplementedException();

                case 15:
                    throw new NotImplementedException();

                case 16:
                    throw new NotImplementedException();

                case 17:
                    throw new NotImplementedException();

                default:
                    throw new PlatformNotSupportedException();
                }
            }
            return(new SingletonEnumerable <Type>(func));
        }