DataType TryGetGenericTypeFromMethodGroup(GenericParameterType gt, DelegateType dt, MethodGroup mg, GenericParameterType[] gparams, DataType[] gargs)
        {
            dt.AssignBaseType();
            var pl = dt.Parameters;

            foreach (var c in mg.Candidates)
            {
                var m = c;
                if (m.IsGenericDefinition)
                {
                    DataType[] typeArgs;
                    if (TryGetGenericTypeArgumentsFromParameterList(c.GenericParameters, c.Parameters,
                                                                    dt.GenericArguments, out typeArgs))
                    {
                        for (int i = 0; i < typeArgs.Length; i++)
                        {
                            typeArgs[i] = TryParameterize(typeArgs[i], gparams, gargs);
                            if (typeArgs[i] == null)
                            {
                                goto CONTINUE;
                            }
                        }

                        m = TypeBuilder.Parameterize(mg.Source, c, typeArgs);
                    }
                    else
                    {
                        goto CONTINUE;
                    }
                }

                for (int j = 0; j < Math.Min(pl.Length, m.Parameters.Length); j++)
                {
                    var at = TryGetGenericTypeArgumentRecursive(gt, pl[j].Type, m.Parameters[j].Type);
                    if (at != null)
                    {
                        return(at);
                    }
                }

                if (!m.ReturnType.IsVoid)
                {
                    var at = TryGetGenericTypeArgumentRecursive(gt, dt.ReturnType, m.ReturnType);
                    if (at != null)
                    {
                        return(at);
                    }
                }
CONTINUE:
                ;
            }

            return(null);
        }