GetGenericArguments() public méthode

public GetGenericArguments ( ) : System.Type[]
Résultat System.Type[]
Exemple #1
0
        public override bool Equals(object obj)
        {
            if (!this.IsGenericMethod)
            {
                return(obj == this);
            }
            RuntimeMethodInfo runtimeMethodInfo = obj as RuntimeMethodInfo;

            if (runtimeMethodInfo == null || !runtimeMethodInfo.IsGenericMethod)
            {
                return(false);
            }
            IRuntimeMethodInfo runtimeMethodInfo2 = RuntimeMethodHandle.StripMethodInstantiation(this);
            IRuntimeMethodInfo runtimeMethodInfo3 = RuntimeMethodHandle.StripMethodInstantiation(runtimeMethodInfo);

            if (runtimeMethodInfo2.Value.Value != runtimeMethodInfo3.Value.Value)
            {
                return(false);
            }
            Type[] genericArguments  = this.GetGenericArguments();
            Type[] genericArguments2 = runtimeMethodInfo.GetGenericArguments();
            if (genericArguments.Length != genericArguments2.Length)
            {
                return(false);
            }
            for (int i = 0; i < genericArguments.Length; i++)
            {
                if (genericArguments[i] != genericArguments2[i])
                {
                    return(false);
                }
            }
            return(!(this.DeclaringType != runtimeMethodInfo.DeclaringType) && !(this.ReflectedType != runtimeMethodInfo.ReflectedType));
        }
Exemple #2
0
        public override bool Equals(object obj)
        {
            if (!this.IsGenericMethod)
            {
                return(obj == this);
            }
            RuntimeMethodInfo runtimeMethodInfo = obj as RuntimeMethodInfo;

            if ((MethodInfo)runtimeMethodInfo == (MethodInfo)null || !runtimeMethodInfo.IsGenericMethod || RuntimeMethodHandle.StripMethodInstantiation((IRuntimeMethodInfo)this).Value.Value != RuntimeMethodHandle.StripMethodInstantiation((IRuntimeMethodInfo)runtimeMethodInfo).Value.Value)
            {
                return(false);
            }
            Type[] genericArguments1 = this.GetGenericArguments();
            Type[] genericArguments2 = runtimeMethodInfo.GetGenericArguments();
            if (genericArguments1.Length != genericArguments2.Length)
            {
                return(false);
            }
            for (int index = 0; index < genericArguments1.Length; ++index)
            {
                if (genericArguments1[index] != genericArguments2[index])
                {
                    return(false);
                }
            }
            return(!(this.DeclaringType != runtimeMethodInfo.DeclaringType) && !(this.ReflectedType != runtimeMethodInfo.ReflectedType));
        }
Exemple #3
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public override bool Equals(object obj)
        {
            if (!IsGenericMethod)
            {
                return(obj == (object)this);
            }

            // We cannot do simple object identity comparisons for generic methods.
            // Equals will be called in CerHashTable when RuntimeType+RuntimeTypeCache.GetGenericMethodInfo()
            // retrive items from and insert items into s_methodInstantiations which is a CerHashtable.
            //

            RuntimeMethodInfo mi = obj as RuntimeMethodInfo;

            if (mi == null || !mi.IsGenericMethod)
            {
                return(false);
            }

            // now we know that both operands are generic methods

            IRuntimeMethodInfo handle1 = RuntimeMethodHandle.StripMethodInstantiation(this);
            IRuntimeMethodInfo handle2 = RuntimeMethodHandle.StripMethodInstantiation(mi);

            if (handle1.Value.Value != handle2.Value.Value)
            {
                return(false);
            }

            Type[] lhs = GetGenericArguments();
            Type[] rhs = mi.GetGenericArguments();

            if (lhs.Length != rhs.Length)
            {
                return(false);
            }

            for (int i = 0; i < lhs.Length; i++)
            {
                if (lhs[i] != rhs[i])
                {
                    return(false);
                }
            }

            if (DeclaringType != mi.DeclaringType)
            {
                return(false);
            }

            if (ReflectedType != mi.ReflectedType)
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
        public override bool Equals(object obj)
        {
            if (!this.IsGenericMethod)
            {
                return(obj == this);
            }
            RuntimeMethodInfo   info    = obj as RuntimeMethodInfo;
            RuntimeMethodHandle handle  = this.GetMethodHandle().StripMethodInstantiation();
            RuntimeMethodHandle handle2 = info.GetMethodHandle().StripMethodInstantiation();

            if (handle != handle2)
            {
                return(false);
            }
            if ((info == null) || !info.IsGenericMethod)
            {
                return(false);
            }
            Type[] genericArguments = this.GetGenericArguments();
            Type[] typeArray2       = info.GetGenericArguments();
            if (genericArguments.Length != typeArray2.Length)
            {
                return(false);
            }
            for (int i = 0; i < genericArguments.Length; i++)
            {
                if (genericArguments[i] != typeArray2[i])
                {
                    return(false);
                }
            }
            if (info.IsGenericMethod)
            {
                if (this.DeclaringType != info.DeclaringType)
                {
                    return(false);
                }
                if (this.ReflectedType != info.ReflectedType)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #5
0
        public override bool Equals(object obj)
        {
            if (!this.IsGenericMethod)
            {
                return(obj == this);
            }
            RuntimeMethodInfo method = obj as RuntimeMethodInfo;

            if ((method == null) || !method.IsGenericMethod)
            {
                return(false);
            }
            IRuntimeMethodInfo info2 = RuntimeMethodHandle.StripMethodInstantiation(this);
            IRuntimeMethodInfo info3 = RuntimeMethodHandle.StripMethodInstantiation(method);

            if (info2.Value.Value != info3.Value.Value)
            {
                return(false);
            }
            Type[] genericArguments = this.GetGenericArguments();
            Type[] typeArray2       = method.GetGenericArguments();
            if (genericArguments.Length != typeArray2.Length)
            {
                return(false);
            }
            for (int i = 0; i < genericArguments.Length; i++)
            {
                if (genericArguments[i] != typeArray2[i])
                {
                    return(false);
                }
            }
            if (this.DeclaringType != method.DeclaringType)
            {
                return(false);
            }
            if (this.ReflectedType != method.ReflectedType)
            {
                return(false);
            }
            return(true);
        }
Exemple #6
0
		internal static string ConstructInstantiation (RuntimeMethodInfo method, TypeNameFormatFlags format)
		{
			var sb = new StringBuilder ();
			var gen_params = method.GetGenericArguments ();
			sb.Append ("[");
			for (int j = 0; j < gen_params.Length; j++) {
				if (j > 0)
					sb.Append (",");
				sb.Append (gen_params [j].Name);
			}
			sb.Append ("]");
			return sb.ToString ();
		}