Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            MetadataOnlyMethodInfo metadataOnlyMethodInfo = obj as MetadataOnlyMethodInfo;

            if (metadataOnlyMethodInfo == null)
            {
                return(false);
            }
            if (!this.DeclaringType.Equals(metadataOnlyMethodInfo.DeclaringType))
            {
                return(false);
            }
            if (!this.IsGenericMethod)
            {
                return(metadataOnlyMethodInfo.GetHashCode() == this.GetHashCode());
            }
            if (!metadataOnlyMethodInfo.IsGenericMethod)
            {
                return(false);
            }
            Type[] genericArguments = this.GetGenericArguments();
            Type[] typeArray        = metadataOnlyMethodInfo.GetGenericArguments();
            if ((int)genericArguments.Length != (int)typeArray.Length)
            {
                return(false);
            }
            for (int i = 0; i < (int)genericArguments.Length; i++)
            {
                if (!genericArguments[i].Equals(typeArray[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 private static void ConstructParameters(StringBuilder sb, ParameterInfo[] parameters, CallingConventions callingConvention)
 {
     Type[] parameterType = new Type[(int)parameters.Length];
     for (int i = 0; i < (int)parameters.Length; i++)
     {
         parameterType[i] = parameters[i].ParameterType;
     }
     MetadataOnlyMethodInfo.ConstructParameters(sb, parameterType, callingConvention);
 }
Exemplo n.º 3
0
        internal static string CommonToString(MethodInfo m)
        {
            StringBuilder stringBuilder = new StringBuilder();

            MetadataOnlyCommonType.TypeSigToString(m.ReturnType, stringBuilder);
            stringBuilder.Append(" ");
            MetadataOnlyMethodInfo.ConstructMethodString(m, stringBuilder);
            return(stringBuilder.ToString());
        }
Exemplo n.º 4
0
        public virtual MethodBase CreateMethodOrConstructor(MetadataOnlyModule resolver, Token methodDef, Type[] typeArgs, Type[] methodArgs)
        {
            MetadataOnlyMethodInfo metadataOnlyMethodInfo = new MetadataOnlyMethodInfo(resolver, methodDef, typeArgs, methodArgs);

            if (DefaultFactory.IsRawConstructor(metadataOnlyMethodInfo))
            {
                return(this.CreateConstructorInfo(metadataOnlyMethodInfo));
            }
            return(this.CreateMethodInfo(metadataOnlyMethodInfo));
        }
Exemplo n.º 5
0
        public override MethodInfo MakeGenericMethod(params Type[] types)
        {
            if (!this.IsGenericMethodDefinition)
            {
                throw new InvalidOperationException();
            }
            GenericContext genericContext = new GenericContext(this.m_context.TypeArgs, types);

            return((MethodInfo)MetadataOnlyMethodInfo.Create(this.m_resolver, this.m_methodDef, genericContext));
        }
Exemplo n.º 6
0
        internal static MethodBody TryCreate(MetadataOnlyMethodInfo method)
        {
            MetadataOnlyModule resolver   = method.Resolver;
            MethodBody         methodBody = null;

            if (resolver.Factory.TryCreateMethodBody(method, ref methodBody))
            {
                return(methodBody);
            }
            return(MetadataOnlyMethodBodyWorker.Create(method));
        }
        internal static MethodBody Create(MetadataOnlyMethodInfo method)
        {
            MetadataOnlyModule resolver = method.Resolver;
            uint methodRva = resolver.GetMethodRva(method.MetadataToken);

            if (methodRva == 0)
            {
                return(null);
            }
            return(new MetadataOnlyMethodBodyWorker(method, MetadataOnlyMethodBodyWorker.GetMethodHeader(methodRva, resolver)));
        }
Exemplo n.º 8
0
 public MetadataOnlyMethodInfo(MetadataOnlyMethodInfo method)
 {
     this.m_resolver         = method.m_resolver;
     this.m_methodDef        = method.m_methodDef;
     this.m_tOwner           = method.m_tOwner;
     this.m_descriptor       = method.m_descriptor;
     this.m_name             = method.m_name;
     this.m_attrs            = method.m_attrs;
     this.m_returnParameter  = method.m_returnParameter;
     this.m_methodBody       = method.m_methodBody;
     this.m_declaringTypeDef = method.m_declaringTypeDef;
     this.m_sigBlob          = method.m_sigBlob;
     this.m_typeArgs         = method.m_typeArgs;
     this.m_methodArgs       = method.m_methodArgs;
     this.m_context          = method.m_context;
     this.m_fullyInitialized = method.m_fullyInitialized;
 }
Exemplo n.º 9
0
        private static void ConstructMethodString(MethodInfo m, StringBuilder sb)
        {
            sb.Append(m.Name);
            string str = "";

            if (m.IsGenericMethod)
            {
                sb.Append("[");
                Type[] genericArguments = m.GetGenericArguments();
                for (int i = 0; i < (int)genericArguments.Length; i++)
                {
                    Type type = genericArguments[i];
                    sb.Append(str);
                    MetadataOnlyCommonType.TypeSigToString(type, sb);
                    str = ",";
                }
                sb.Append("]");
            }
            sb.Append("(");
            MetadataOnlyMethodInfo.ConstructParameters(sb, m.GetParameters(), m.CallingConvention);
            sb.Append(")");
        }
Exemplo n.º 10
0
 protected MetadataOnlyMethodBody(MetadataOnlyMethodInfo method)
 {
     this.m_method = method;
 }
 public MetadataOnlyMethodBodyWorker(MetadataOnlyMethodInfo method, MetadataOnlyMethodBodyWorker.IMethodHeader header) : base(method)
 {
     this.m_header = header;
 }
Exemplo n.º 12
0
 public virtual MetadataOnlyMethodInfo CreateMethodInfo(MetadataOnlyMethodInfo method)
 {
     return(new MetadataOnlyMethodInfo(method));
 }
Exemplo n.º 13
0
 public virtual bool TryCreateMethodBody(MetadataOnlyMethodInfo method, ref MethodBody body)
 {
     return(false);
 }
Exemplo n.º 14
0
 public override string ToString()
 {
     return(MetadataOnlyMethodInfo.CommonToString(this));
 }