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

GetEventsInternal() private method

private GetEventsInternal ( BindingFlags bf, MonoGenericClass reftype ) : System.Reflection.EventInfo[]
bf BindingFlags
reftype MonoGenericClass
return System.Reflection.EventInfo[]
		EventInfo[] GetEventsInternal (BindingFlags bf, MonoGenericClass reftype) {
			TypeBuilder tb = generic_type as TypeBuilder;
			if (tb == null) {
				EventInfo[] res = generic_type.GetEvents (bf);
				for (int i = 0; i < res.Length; ++i)
					res [i] = new EventOnTypeBuilderInst (this, res [i]);
				return res;
			}
			EventBuilder[] events = tb.events;

			if (events == null || events.Length == 0)
				return new EventInfo [0];

			initialize ();

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

			for (int i = 0; i < event_count; ++i) {
				EventBuilder ev = events [i];

				match = false;
				accessor = ev.add_method;
				if (accessor == null)
					accessor = ev.remove_method;
				if (accessor == null)
					continue;
				mattrs = accessor.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;
				l.Add (new EventOnTypeBuilderInst (this, ev));
			}
			EventInfo[] result = new EventInfo [l.Count];
			l.CopyTo (result);
			return result;
		}

Usage Example

Esempio n. 1
0
        public override EventInfo[] GetEvents(BindingFlags bf)
        {
            if (!this.generic_type.IsCompilerContext)
            {
                throw new NotSupportedException();
            }
            ArrayList arrayList = new ArrayList();
            Type      type      = this;

            for (;;)
            {
                MonoGenericClass monoGenericClass = type as MonoGenericClass;
                if (monoGenericClass != null)
                {
                    arrayList.AddRange(monoGenericClass.GetEventsInternal(bf, this));
                }
                else
                {
                    if (!(type is TypeBuilder))
                    {
                        break;
                    }
                    arrayList.AddRange(type.GetEvents(bf));
                }
                if ((bf & BindingFlags.DeclaredOnly) != BindingFlags.Default)
                {
                    goto Block_4;
                }
                type = type.BaseType;
                if (type == null)
                {
                    goto IL_8E;
                }
            }
            MonoType monoType = (MonoType)type;

            arrayList.AddRange(monoType.GetEvents(bf));
Block_4:
IL_8E:
            EventInfo[] array = new EventInfo[arrayList.Count];
            arrayList.CopyTo(array);
            return(array);
        }
All Usage Examples Of System.Reflection.MonoGenericClass::GetEventsInternal