System.Reflection.MonoGenericClass.GetMethodsInternal C# (CSharp) Method

GetMethodsInternal() private method

private GetMethodsInternal ( BindingFlags bf, MonoGenericClass reftype ) : System.Reflection.MethodInfo[]
bf BindingFlags
reftype MonoGenericClass
return System.Reflection.MethodInfo[]
		MethodInfo[] GetMethodsInternal (BindingFlags bf, MonoGenericClass reftype)
		{
			if (reftype != this)
				bf |= BindingFlags.DeclaredOnly; /*To avoid duplicates*/

			MethodInfo[] methods = GetMethodsFromGTDWithHint (bf);
			if (methods.Length == 0)
				return new MethodInfo [0];

			ArrayList l = new ArrayList ();
			bool match;
			MethodAttributes mattrs;

			initialize ();

			for (int i = 0; i < methods.Length; ++i) {
				MethodInfo c = methods [i];

				match = false;
				mattrs = c.Attributes;
				if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
					if ((bf & BindingFlags.Public) != 0)
						match = true;
				} else {
					if ((bf & BindingFlags.NonPublic) != 0)
						match = true;
				}
				if (!match)
					continue;
				match = false;
				if ((mattrs & MethodAttributes.Static) != 0) {
					if ((bf & BindingFlags.Static) != 0)
						match = true;
				} else {
					if ((bf & BindingFlags.Instance) != 0)
						match = true;
				}
				if (!match)
					continue;
				if (c.DeclaringType.IsGenericTypeDefinition)
					c = TypeBuilder.GetMethod (this, c);
				l.Add (c);
			}

			MethodInfo[] result = new MethodInfo [l.Count];
			l.CopyTo (result);
			return result;
		}

Usage Example

Esempio n. 1
0
        public override MethodInfo[] GetMethods(BindingFlags bf)
        {
            if (!generic_type.IsCompilerContext)
            {
                throw new NotSupportedException();
            }

            ArrayList l = new ArrayList();

            //
            // Walk up our class hierarchy and retrieve methods from our
            // parent classes.
            //

            Type current_type = this;

            do
            {
                MonoGenericClass gi = current_type as MonoGenericClass;
                if (gi != null)
                {
                    l.AddRange(gi.GetMethodsInternal(bf, this));
                }
                else if (current_type is TypeBuilder)
                {
                    l.AddRange(current_type.GetMethods(bf));
                }
                else
                {
                    // If we encounter a `MonoType', its
                    // GetMethodsByName() will return all the methods
                    // from its parent type(s), so we can stop here.
                    MonoType mt = (MonoType)current_type;
                    l.AddRange(mt.GetMethodsByName(null, bf, false, this));
                    break;
                }

                if ((bf & BindingFlags.DeclaredOnly) != 0)
                {
                    break;
                }
                current_type = current_type.BaseType;
            } while (current_type != null);

            MethodInfo[] result = new MethodInfo [l.Count];
            l.CopyTo(result);
            return(result);
        }
All Usage Examples Of System.Reflection.MonoGenericClass::GetMethodsInternal