示例#1
0
        internal CustomAttribute(MetadataImage image, MetadataRow <uint, uint, uint> row)
            : base(row.MetadataToken)
        {
            var tableStream = image.Header.GetStream <TableStream>();

            _parent = new LazyValue <IHasCustomAttribute>(() =>
            {
                var parentToken = tableStream.GetIndexEncoder(CodedIndex.HasCustomAttribute).DecodeIndex(row.Column1);
                IMetadataMember member;
                return(image.TryResolveMember(parentToken, out member)
                    ? (IHasCustomAttribute)member
                    : null);
            });

            _constructor = new LazyValue <ICustomAttributeType>(() =>
            {
                var ctorToken = tableStream.GetIndexEncoder(CodedIndex.CustomAttributeType).DecodeIndex(row.Column2);
                IMetadataMember member;
                return(image.TryResolveMember(ctorToken, out member)
                    ? (ICustomAttributeType)member
                    : null);
            });

            _signature = new LazyValue <CustomAttributeSignature>(() => CustomAttributeSignature.FromReader(
                                                                      this,
                                                                      tableStream.MetadataHeader.GetStream <BlobStream>().CreateBlobReader(row.Column3),
                                                                      true));
        }
示例#2
0
        internal CustomAttribute(MetadataHeader header, MetadataToken token, MetadataRow <uint, uint, uint> row)
            : base(header, token, row)
        {
            var tableStream = header.GetStream <TableStream>();

            _parent = new LazyValue <IHasCustomAttribute>(() =>
            {
                var parentToken = tableStream.GetIndexEncoder(CodedIndex.HasCustomAttribute).DecodeIndex(row.Column1);
                return(parentToken.Rid != 0 ? (IHasCustomAttribute)tableStream.ResolveMember(parentToken) : null);
            });

            _constructor = new LazyValue <ICustomAttributeType>(() =>
            {
                var ctorToken = tableStream.GetIndexEncoder(CodedIndex.CustomAttributeType).DecodeIndex(row.Column2);
                return(ctorToken.Rid != 0 ? (ICustomAttributeType)tableStream.ResolveMember(ctorToken) : null);
            });

            _signature = new LazyValue <CustomAttributeSignature>(() => CustomAttributeSignature.FromReader(this,
                                                                                                            Header.GetStream <BlobStream>().CreateBlobReader(MetadataRow.Column3)));
        }
 /// <inheritdoc />
 protected override CustomAttributeSignature GetSignature()
 {
     return(CustomAttributeSignature.FromReader(_parentModule, Constructor,
                                                _parentModule.DotNetDirectory.Metadata.GetStream <BlobStream>().GetBlobReaderByIndex(_row.Value)));
 }