Ejemplo n.º 1
0
        internal PropertyDefinition(MetadataImage image, MetadataRow <PropertyAttributes, uint, uint> row)
            : base(row.MetadataToken)
        {
            _image     = image;
            Attributes = row.Column1;

            _name = new LazyValue <string>(() =>
                                           image.Header.GetStream <StringStream>().GetStringByOffset(row.Column2));

            _signature = new LazyValue <PropertySignature>(()
                                                           => PropertySignature.FromReader(image, image.Header.GetStream <BlobStream>().CreateBlobReader(row.Column3)));

            _propertyMap = new LazyValue <PropertyMap>(() =>
            {
                var table  = image.Header.GetStream <TableStream>().GetTable(MetadataTokenType.PropertyMap);
                var mapRow = table.GetRowClosestToKey(1, row.MetadataToken.Rid);
                return(mapRow != null ? (PropertyMap)table.GetMemberFromRow(image, mapRow) : null);
            });

            _constant = new LazyValue <Constant>(() =>
            {
                var table       = (ConstantTable)image.Header.GetStream <TableStream>().GetTable(MetadataTokenType.Constant);
                var constantRow = table.FindConstantOfOwner(row.MetadataToken);
                return(constantRow != null ? (Constant)table.GetMemberFromRow(image, constantRow) : null);
            });

            CustomAttributes = new CustomAttributeCollection(this);
            Semantics        = new MethodSemanticsCollection(this);
        }
Ejemplo n.º 2
0
        internal EventDefinition(MetadataImage image, MetadataRow <EventAttributes, uint, uint> row)
            : base(row.MetadataToken)
        {
            _image     = image;
            Attributes = row.Column1;
            _name      = new LazyValue <string>(() => image.Header.GetStream <StringStream>().GetStringByOffset(row.Column2));

            _eventType = new LazyValue <ITypeDefOrRef>(() =>
            {
                var enoder         = image.Header.GetStream <TableStream>().GetIndexEncoder(CodedIndex.TypeDefOrRef);
                var eventTypeToken = enoder.DecodeIndex(row.Column3);
                IMetadataMember member;
                return(image.TryResolveMember(eventTypeToken, out member) ? (ITypeDefOrRef)member : null);
            });

            _eventMap = new LazyValue <EventMap>(() =>
            {
                var table  = image.Header.GetStream <TableStream>().GetTable(MetadataTokenType.EventMap);
                var mapRow = table.GetRowClosestToKey(1, row.MetadataToken.Rid);
                return(mapRow != null ? (EventMap)table.GetMemberFromRow(image, mapRow) : null);
            });

            CustomAttributes = new CustomAttributeCollection(this);
            Semantics        = new MethodSemanticsCollection(this);
        }
Ejemplo n.º 3
0
        public EventDefinition(string name, ITypeDefOrRef eventType)
            : base(new MetadataToken(MetadataTokenType.Event))
        {
            _name      = new LazyValue <string>(name);
            _eventType = new LazyValue <ITypeDefOrRef>(eventType);

            _eventMap = new LazyValue <EventMap>();

            CustomAttributes = new CustomAttributeCollection(this);
            Semantics        = new MethodSemanticsCollection(this);
        }
Ejemplo n.º 4
0
        public PropertyDefinition(string name, PropertySignature signature)
            : base(new MetadataToken(MetadataTokenType.Property))
        {
            _name      = new LazyValue <string>(name);
            _signature = new LazyValue <PropertySignature>(signature);

            _propertyMap = new LazyValue <PropertyMap>();
            _constant    = new LazyValue <Constant>();

            CustomAttributes = new CustomAttributeCollection(this);
            Semantics        = new MethodSemanticsCollection(this);
        }
        /// <inheritdoc />
        protected override IList <MethodSemantics> GetSemantics()
        {
            var result = new MethodSemanticsCollection(this);

            result.ValidateMembership = false;

            foreach (uint rid in _parentModule.GetMethodSemantics(MetadataToken))
            {
                var semanticsToken = new MetadataToken(TableIndex.MethodSemantics, rid);
                result.Add((MethodSemantics)_parentModule.LookupMember(semanticsToken));
            }

            result.ValidateMembership = true;
            return(result);
        }
Ejemplo n.º 6
0
        public EventDefinition(string name, ITypeDefOrRef eventType)
            : base(new MetadataToken(MetadataTokenType.Event))
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (eventType == null)
            {
                throw new ArgumentNullException(nameof(eventType));
            }

            _name      = new LazyValue <string>(name);
            _eventType = new LazyValue <ITypeDefOrRef>(eventType);

            _eventMap = new LazyValue <EventMap>();

            CustomAttributes = new CustomAttributeCollection(this);
            Semantics        = new MethodSemanticsCollection(this);
        }