-
-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathSerializedStringIdentifier.cs
More file actions
39 lines (33 loc) · 1.33 KB
/
SerializedStringIdentifier.cs
File metadata and controls
39 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using AsmResolver.IO;
namespace AsmResolver.Symbols.Pdb.Leaves.Serialized;
/// <summary>
/// Provides a lazily initialized implementation of <see cref="StringIdentifier"/> that is read from a PDB image.
/// </summary>
public class SerializedStringIdentifier : StringIdentifier
{
private readonly PdbReaderContext _context;
private readonly BinaryStreamReader _reader;
private readonly uint _subStringsIndex;
/// <summary>
/// Reads a string ID from the provided input stream.
/// </summary>
/// <param name="context">The reading context in which the member is situated in.</param>
/// <param name="typeIndex">The type index to assign to the member.</param>
/// <param name="reader">The input stream to read from.</param>
public SerializedStringIdentifier(PdbReaderContext context, uint typeIndex, BinaryStreamReader reader)
: base(typeIndex)
{
_context = context;
_subStringsIndex = reader.ReadUInt32();
_reader = reader;
}
/// <inheritdoc />
protected override Utf8String GetValue() => _reader.Fork().ReadUtf8String();
/// <inheritdoc />
protected override SubStringListLeaf? GetSubStrings()
{
if (_subStringsIndex == 0)
return null;
return _context.ParentImage.GetIdLeafRecord<SubStringListLeaf>(_subStringsIndex);
}
}