internal override int ParentToken(int token)
        {
            RuntimeType declaringType = null;
            object      obj2          = this.m_scope[token];

            if (obj2 is RuntimeMethodHandle)
            {
                declaringType = RuntimeMethodHandle.GetDeclaringType(((RuntimeMethodHandle)obj2).GetMethodInfo());
            }
            else if (obj2 is RuntimeFieldHandle)
            {
                declaringType = RuntimeFieldHandle.GetApproxDeclaringType(((RuntimeFieldHandle)obj2).GetRuntimeFieldInfo());
            }
            else if (obj2 is DynamicMethod)
            {
                DynamicMethod method = (DynamicMethod)obj2;
                declaringType = RuntimeMethodHandle.GetDeclaringType(method.m_methodHandle);
            }
            else if (obj2 is GenericMethodInfo)
            {
                GenericMethodInfo info = (GenericMethodInfo)obj2;
                declaringType = info.m_context.GetRuntimeType();
            }
            else if (obj2 is GenericFieldInfo)
            {
                GenericFieldInfo info2 = (GenericFieldInfo)obj2;
                declaringType = info2.m_context.GetRuntimeType();
            }
            else if (obj2 is VarArgMethod)
            {
                VarArgMethod  method2       = (VarArgMethod)obj2;
                DynamicMethod dynamicMethod = method2.m_dynamicMethod;
                if (dynamicMethod != null)
                {
                    dynamicMethod.GetMethodDescriptor();
                    declaringType = RuntimeMethodHandle.GetDeclaringType(dynamicMethod.m_methodHandle);
                }
                else
                {
                    RuntimeMethodInfo info3 = method2.m_method;
                    if (info3.DeclaringType == null)
                    {
                        declaringType = RuntimeMethodHandle.GetDeclaringType(info3);
                    }
                    else
                    {
                        declaringType = info3.DeclaringType.TypeHandle.GetRuntimeType();
                    }
                }
            }
            if (declaringType == null)
            {
                return(-1);
            }
            return(this.m_scope.GetTokenFor(declaringType.GetTypeHandleInternal()));
        }
        internal override unsafe void *ResolveToken(int token)
        {
            object obj2 = this.m_scope[token];

            if (obj2 is RuntimeTypeHandle)
            {
                RuntimeTypeHandle handle = (RuntimeTypeHandle)obj2;
                return((void *)handle.Value);
            }
            if (obj2 is RuntimeMethodHandle)
            {
                RuntimeMethodHandle handle2 = (RuntimeMethodHandle)obj2;
                return((void *)handle2.Value);
            }
            if (obj2 is RuntimeFieldHandle)
            {
                RuntimeFieldHandle handle3 = (RuntimeFieldHandle)obj2;
                return((void *)handle3.Value);
            }
            if (obj2 is DynamicMethod)
            {
                DynamicMethod method = (DynamicMethod)obj2;
                return((void *)method.GetMethodDescriptor().Value);
            }
            if (obj2 is GenericMethodInfo)
            {
                GenericMethodInfo info = (GenericMethodInfo)obj2;
                return((void *)info.m_methodHandle.Value);
            }
            if (obj2 is GenericFieldInfo)
            {
                GenericFieldInfo info2 = (GenericFieldInfo)obj2;
                return((void *)info2.m_fieldHandle.Value);
            }
            if (!(obj2 is VarArgMethod))
            {
                return(null);
            }
            VarArgMethod method2 = (VarArgMethod)obj2;

            if (method2.m_dynamicMethod == null)
            {
                return((void *)method2.m_method.MethodHandle.Value);
            }
            return((void *)method2.m_dynamicMethod.GetMethodDescriptor().Value);
        }
Exemplo n.º 3
0
        internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
        {
            typeHandle   = new IntPtr();
            methodHandle = new IntPtr();
            fieldHandle  = new IntPtr();

            Object handle = m_scope[token];

            if (handle == null)
            {
                throw new InvalidProgramException();
            }

            if (handle is RuntimeTypeHandle)
            {
                typeHandle = ((RuntimeTypeHandle)handle).Value;
                return;
            }

            if (handle is RuntimeMethodHandle)
            {
                methodHandle = ((RuntimeMethodHandle)handle).Value;
                return;
            }

            if (handle is RuntimeFieldHandle)
            {
                fieldHandle = ((RuntimeFieldHandle)handle).Value;
                return;
            }

            DynamicMethod dm = handle as DynamicMethod;

            if (dm != null)
            {
                methodHandle = dm.GetMethodDescriptor().Value;
                return;
            }

            GenericMethodInfo gmi = handle as GenericMethodInfo;

            if (gmi != null)
            {
                methodHandle = gmi.m_methodHandle.Value;
                typeHandle   = gmi.m_context.Value;
                return;
            }

            GenericFieldInfo gfi = handle as GenericFieldInfo;

            if (gfi != null)
            {
                fieldHandle = gfi.m_fieldHandle.Value;
                typeHandle  = gfi.m_context.Value;
                return;
            }

            VarArgMethod vaMeth = handle as VarArgMethod;

            if (vaMeth != null)
            {
                if (vaMeth.m_dynamicMethod == null)
                {
                    methodHandle = vaMeth.m_method.MethodHandle.Value;
                    typeHandle   = vaMeth.m_method.GetDeclaringTypeInternal().GetTypeHandleInternal().Value;
                }
                else
                {
                    methodHandle = vaMeth.m_dynamicMethod.GetMethodDescriptor().Value;
                }

                return;
            }
        }
Exemplo n.º 4
0
        internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
        {
            typeHandle   = new IntPtr();
            methodHandle = new IntPtr();
            fieldHandle  = new IntPtr();
            object obj = this.m_scope[token];

            if (obj == null)
            {
                throw new InvalidProgramException();
            }
            if (obj is RuntimeTypeHandle)
            {
                typeHandle = ((RuntimeTypeHandle)obj).Value;
            }
            else if (obj is RuntimeMethodHandle)
            {
                methodHandle = ((RuntimeMethodHandle)obj).Value;
            }
            else if (obj is RuntimeFieldHandle)
            {
                fieldHandle = ((RuntimeFieldHandle)obj).Value;
            }
            else
            {
                DynamicMethod dynamicMethod = obj as DynamicMethod;
                if ((MethodInfo)dynamicMethod != (MethodInfo)null)
                {
                    methodHandle = dynamicMethod.GetMethodDescriptor().Value;
                }
                else
                {
                    GenericMethodInfo genericMethodInfo = obj as GenericMethodInfo;
                    if (genericMethodInfo != null)
                    {
                        methodHandle = genericMethodInfo.m_methodHandle.Value;
                        typeHandle   = genericMethodInfo.m_context.Value;
                    }
                    else
                    {
                        GenericFieldInfo genericFieldInfo = obj as GenericFieldInfo;
                        if (genericFieldInfo != null)
                        {
                            fieldHandle = genericFieldInfo.m_fieldHandle.Value;
                            typeHandle  = genericFieldInfo.m_context.Value;
                        }
                        else
                        {
                            VarArgMethod varArgMethod = obj as VarArgMethod;
                            if (varArgMethod == null)
                            {
                                return;
                            }
                            if ((MethodInfo)varArgMethod.m_dynamicMethod == (MethodInfo)null)
                            {
                                methodHandle = varArgMethod.m_method.MethodHandle.Value;
                                typeHandle   = varArgMethod.m_method.GetDeclaringTypeInternal().GetTypeHandleInternal().Value;
                            }
                            else
                            {
                                methodHandle = varArgMethod.m_dynamicMethod.GetMethodDescriptor().Value;
                            }
                        }
                    }
                }
            }
        }