Beispiel #1
0
        internal IMethod GetMethodDefOrRef(SimpleIndex i, Context context)
        {
            int index = i.Index - 1;

            switch (i.Table)
            {
            case TableId.MethodDef:
                return(Methods[index]);

            case TableId.MemberRef:
                return(MemberRefs.Get(index, context) as IMethod);

            default:
                throw new ArgumentOutOfRangeException("i");
            }
        }
Beispiel #2
0
        public object ResolveMetadataToken(IMethod method, int token)
        {
            uint msb   = (uint)token >> 24;
            int  index = token & 0xFFFFFF;

            if (msb == 0x70)
            {
                return(Metadata.GetUserString((uint)index));
            }

            var tableId = (TableId)msb;
            var context = new Context(method);

            switch (tableId)
            {
            case TableId.TypeRef:
            case TableId.TypeDef:
            case TableId.TypeSpec:
                return(GetTypeDefOrRef(token, context));

            case TableId.Field:
                return(Fields[index - 1]);

            case TableId.MethodDef:
                return(Methods[index - 1]);

            case TableId.MemberRef:
                return(MemberRefs.Get(index - 1, context));

            case TableId.MethodSpec:
                return(GetMethodSpec(index - 1, context));

            case TableId.StandAloneSig:
                return(null);
            }
            return(null);
        }