Ejemplo n.º 1
0
        private MemberInfo ResolveTypeMemberRef(Type type, string name, ByteReader sig, Type[] genericTypeArguments, Type[] genericMethodArguments)
        {
            IGenericContext context;

            if ((genericTypeArguments == null && genericMethodArguments == null) || type.IsGenericType)
            {
                context = type;
            }
            else
            {
                context = new GenericContext(genericTypeArguments, genericMethodArguments);
            }
            if (sig.PeekByte() == Signature.FIELD)
            {
                Type           org      = type;
                FieldSignature fieldSig = FieldSignature.ReadSig(this, sig, context);
                do
                {
                    FieldInfo field = type.FindField(name, fieldSig);
                    if (field != null)
                    {
                        return(field);
                    }
                    type = type.BaseType;
                } while (type != null);
                throw new MissingFieldException(org.ToString(), name);
            }
            else
            {
                Type            org       = type;
                MethodSignature methodSig = MethodSignature.ReadSig(this, sig, context);
                do
                {
                    MethodBase method = type.FindMethod(name, methodSig);
                    if (method != null)
                    {
                        return(method);
                    }
                    type = type.BaseType;
                } while (type != null);
                return(universe.GetMissingMethodOrThrow(org, name, methodSig));
            }
        }
Ejemplo n.º 2
0
 private MemberInfo ResolveTypeMemberRef(Type type, string name, ByteReader sig)
 {
     if (sig.PeekByte() == Signature.FIELD)
     {
         Type           org      = type;
         FieldSignature fieldSig = FieldSignature.ReadSig(this, sig, type);
         FieldInfo      field    = type.FindField(name, fieldSig);
         if (field == null && universe.MissingMemberResolution)
         {
             return(universe.GetMissingFieldOrThrow(type, name, fieldSig));
         }
         while (field == null && (type = type.BaseType) != null)
         {
             field = type.FindField(name, fieldSig);
         }
         if (field != null)
         {
             return(field);
         }
         throw new MissingFieldException(org.ToString(), name);
     }
     else
     {
         Type            org       = type;
         MethodSignature methodSig = MethodSignature.ReadSig(this, sig, type);
         MethodBase      method    = type.FindMethod(name, methodSig);
         if (method == null && universe.MissingMemberResolution)
         {
             return(universe.GetMissingMethodOrThrow(type, name, methodSig));
         }
         while (method == null && (type = type.BaseType) != null)
         {
             method = type.FindMethod(name, methodSig);
         }
         if (method != null)
         {
             return(method);
         }
         throw new MissingMethodException(org.ToString(), name);
     }
 }