Beispiel #1
0
        /// <summary>
        /// Finds event
        /// </summary>
        /// <param name="name">Event name</param>
        /// <returns></returns>
        public IEnumerable <CorEvent> FindEvents(string name, bool checkBaseClasses = true)
        {
            var mdi = Module.GetMetaDataInterface <IMetaDataImport>();

            foreach (var edToken in MDAPI.GetEventTokens(mdi, token))
            {
                if (MDAPI.GetEventName(mdi, edToken) == name)
                {
                    yield return(new CorEvent(this, edToken));
                }
            }
            if (checkBaseClasses)
            {
                var type = GetParameterizedType(CorElementType.Class);
                if (type != null)
                {
                    type = type.Base;
                }
                if (type != null)
                {
                    foreach (var evt in type.FindEvents(name, checkBaseClasses))
                    {
                        yield return(evt);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Finds events
        /// </summary>
        /// <returns></returns>
        public IEnumerable <CorEvent> FindEvents(bool checkBaseClasses = true)
        {
            for (var type = this; type != null; type = type.Base)
            {
                if (!checkBaseClasses && (object)this != (object)type)
                {
                    break;
                }
                if (!type.HasClass)
                {
                    continue;
                }
                var cls = type.Class;
                if (cls == null)
                {
                    continue;
                }

                var mod = cls.Module;
                var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();
                foreach (var edToken in MDAPI.GetEventTokens(mdi, cls.Token))
                {
                    yield return(new CorEvent(cls, edToken));
                }
            }
        }
Beispiel #3
0
        DmdEventInfo[] ReadDeclaredEvents_COMThread(DmdType declaringType, DmdType reflectedType)
        {
            reader.Dispatcher.VerifyAccess();
            var tokens = MDAPI.GetEventTokens(reader.MetaDataImport, (uint)MetadataToken);

            if (tokens.Length == 0)
            {
                return(Array.Empty <DmdEventInfo>());
            }
            var events = new DmdEventInfo[tokens.Length];

            for (int i = 0; i < events.Length; i++)
            {
                uint rid = tokens[i] & 0x00FFFFFF;
                events[i] = reader.CreateEventDef_COMThread(rid, declaringType, reflectedType);
            }
            return(events);
        }
Beispiel #4
0
        void InitEvents_NoLock()
        {
            var  mdi   = readerModule.MetaDataImport;
            uint token = OriginalToken.Raw;

            events?.Clear();

            var itemTokens = MDAPI.GetEventTokens(mdi, token);
            var newItems   = new MemberInfo <CorEventDef> [itemTokens.Length];

            for (int i = 0; i < itemTokens.Length; i++)
            {
                uint itemRid = itemTokens[i] & 0x00FFFFFF;
                newItems[i] = readerModule.Register(new CorEventDef(readerModule, itemRid, this), cmd => cmd.Initialize());
            }

            events = new LazyList <EventDef, MemberInfo <CorEventDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
        }