protected void LoadSemantics()
        {
            var image = _module.Image;

            int token = MetadataToken.Get(MetadataTokenType.Event, _rid);

            int[] rids;
            image.GetMethodSemanticsByAssociation(MetadataToken.CompressHasSemantic(token), out rids);

            for (int i = 0; i < rids.Length; i++)
            {
                MethodSemanticsRow row;
                image.GetMethodSemantics(rids[i], out row);

                var methodRef = MethodReference.LoadMethodDef(_module, row.Method);
                switch (row.Semantic)
                {
                case MethodSemanticFlags.AddOn:
                    if (_opFlags.IsBitAtIndexOn(LoadAddSemanticFlag))
                    {
                        _addMethod = methodRef;
                    }
                    break;

                case MethodSemanticFlags.RemoveOn:
                    if (_opFlags.IsBitAtIndexOn(LoadRemoveSemanticFlag))
                    {
                        _removeMethod = methodRef;
                    }
                    break;

                case MethodSemanticFlags.Fire:
                    if (_opFlags.IsBitAtIndexOn(LoadInvokeSemanticFlag))
                    {
                        _invokeMethod = methodRef;
                    }
                    break;
                }
            }

            _opFlags = _opFlags.SetBitAtIndex(LoadAddSemanticFlag, false);
            _opFlags = _opFlags.SetBitAtIndex(LoadRemoveSemanticFlag, false);
            _opFlags = _opFlags.SetBitAtIndex(LoadInvokeSemanticFlag, false);
        }
예제 #2
0
        protected void LoadSemantics()
        {
            var image = _module.Image;

            int token = MetadataToken.Get(MetadataTokenType.Property, _rid);

            int[] rids;
            image.GetMethodSemanticsByAssociation(MetadataToken.CompressHasSemantic(token), out rids);

            for (int i = 0; i < rids.Length; i++)
            {
                MethodSemanticsRow row;
                image.GetMethodSemantics(rids[i], out row);

                var methodRef = MethodReference.LoadMethodDef(_module, row.Method);
                switch (row.Semantic)
                {
                case MethodSemanticFlags.Getter:
                    if (_opFlags.IsBitAtIndexOn(LoadGetSemanticFlag))
                    {
                        _getMethod = methodRef;
                    }
                    break;

                case MethodSemanticFlags.Setter:
                    if (_opFlags.IsBitAtIndexOn(LoadSetSemanticFlag))
                    {
                        _setMethod = methodRef;
                    }
                    break;
                }
            }

            _opFlags = _opFlags.SetBitAtIndex(LoadGetSemanticFlag, false);
            _opFlags = _opFlags.SetBitAtIndex(LoadSetSemanticFlag, false);
        }