| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Reflection.Metadata |
| | | 5 | | { |
| | | 6 | | public readonly struct ManifestResource |
| | | 7 | | { |
| | | 8 | | private readonly MetadataReader _reader; |
| | | 9 | | |
| | | 10 | | // Workaround: JIT doesn't generate good code for nested structures, so use RowId. |
| | | 11 | | private readonly int _rowId; |
| | | 12 | | |
| | | 13 | | internal ManifestResource(MetadataReader reader, ManifestResourceHandle handle) |
| | 0 | 14 | | { |
| | 0 | 15 | | _reader = reader; |
| | 0 | 16 | | _rowId = handle.RowId; |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | private ManifestResourceHandle Handle |
| | | 20 | | { |
| | 0 | 21 | | get { return ManifestResourceHandle.FromRowId(_rowId); } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Specifies the byte offset within the referenced file at which this resource record begins. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <remarks> |
| | | 28 | | /// Corresponds to Offset field of ManifestResource table in ECMA-335 Standard. |
| | | 29 | | /// </remarks> |
| | | 30 | | public long Offset |
| | | 31 | | { |
| | 0 | 32 | | get { return _reader.ManifestResourceTable.GetOffset(Handle); } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Resource attributes. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <remarks> |
| | | 39 | | /// Corresponds to Flags field of ManifestResource table in ECMA-335 Standard. |
| | | 40 | | /// </remarks> |
| | | 41 | | public ManifestResourceAttributes Attributes |
| | | 42 | | { |
| | 0 | 43 | | get { return _reader.ManifestResourceTable.GetFlags(Handle); } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Name of the resource. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <remarks> |
| | | 50 | | /// Corresponds to Name field of ManifestResource table in ECMA-335 Standard. |
| | | 51 | | /// </remarks> |
| | | 52 | | public StringHandle Name |
| | | 53 | | { |
| | 0 | 54 | | get { return _reader.ManifestResourceTable.GetName(Handle); } |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// <see cref="AssemblyFileHandle"/>, <see cref="AssemblyReferenceHandle"/>, or nil handle. |
| | | 59 | | /// </summary> |
| | | 60 | | /// <remarks> |
| | | 61 | | /// Corresponds to Implementation field of ManifestResource table in ECMA-335 Standard. |
| | | 62 | | /// |
| | | 63 | | /// If nil then <see cref="Offset"/> is an offset in the PE image that contains the metadata, |
| | | 64 | | /// starting from the Resource entry in the CLI header. |
| | | 65 | | /// </remarks> |
| | | 66 | | public EntityHandle Implementation |
| | | 67 | | { |
| | 0 | 68 | | get { return _reader.ManifestResourceTable.GetImplementation(Handle); } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 72 | | { |
| | 0 | 73 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 74 | | } |
| | | 75 | | } |
| | | 76 | | } |
| | | 77 | | |