Exemple #1
0
        internal static Type GetActualType(this MemberType memberType)
        {
            Mono.Cecil.TypeReference typeReference = null;
            object         type           = memberType.Annotations.First();
            TypeDefinition typeDefinition = type as TypeDefinition;

            if (typeDefinition != null)
            {
                return(typeDefinition.GetActualType());
            }

            typeReference = type as Mono.Cecil.TypeReference;

            if (typeReference != null)
            {
                if (typeReference.HasGenericParameters)
                {
                    Type[] parameters  = new Type[typeReference.GenericParameters.Count];
                    Type   genericType = typeReference.GetActualType();
                    var    simpleType  = memberType.Target as SimpleType;

                    simpleType.TypeArguments
                    .ForEach((p, i) => {
                        Type parameterType = p.GetActualType();
                        parameters[i]      = parameterType;
                    });

                    return(genericType.MakeGenericType(parameters));
                }

                return(typeReference.GetActualType());
            }

            return(null);
        }