Exemplo n.º 1
0
        //------------------------------------------------------------
        // ReflectionUtil.GetConstructedMethodInfo2 (obsolete)
        //
        /// <summary></summary>
        /// <param name="methInfo"></param>
        /// <param name="aggTypeSym"></param>
        /// <param name="methTypeArguments"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal static MethodInfo GetConstructedMethodInfo2(
            MethodInfo methInfo,
            AGGTYPESYM aggTypeSym,
            TypeArray methTypeArguments)
        {
            DebugUtil.Assert(methInfo != null);

            bool       isGenericType = false;
            Type       type          = null;
            MethodInfo methInfo2     = null;

            if (aggTypeSym != null)
            {
                type = aggTypeSym.GetConstructedType(null, null, false);
                if (type != null && type.IsGenericType)
                {
                    isGenericType = true;
                }
            }

            if (!methInfo.IsGenericMethod && !isGenericType)
            {
                return(methInfo);
            }

            if (isGenericType)
            {
                string name       = methInfo.Name;
                Type[] paramTypes = SubstParameterTypes(
                    methInfo.GetParameters(),
                    type.GetGenericArguments());

                try
                {
                    methInfo2 = type.GetMethod(
                        name,
                        paramTypes);
                }
                catch (NotSupportedException)
                {
                    methInfo2 = System.Reflection.Emit.TypeBuilder.GetMethod(
                        type,
                        methInfo);
                }
            }
            else
            {
                methInfo2 = methInfo;
            }

            if (methInfo.IsGenericMethod)
            {
                throw new NotImplementedException("");
            }

            return(methInfo2);
        }