Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MdBinaryReader.cs « NativeFormat « Metadata « Internal « Common « tools « coreclr « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 660c2f5d20d363907c4e2121a2be935aba7eb3e2 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using Debug = System.Diagnostics.Debug;
using System.Threading;
using System.Text;
using Internal.NativeFormat;

namespace Internal.Metadata.NativeFormat
{
    internal static partial class MdBinaryReader
    {
        public static uint Read(this NativeReader reader, uint offset, out bool value)
        {
            value = (reader.ReadUInt8(offset) != 0) ? true : false;
            return offset + 1;
        }

        public static uint Read(this NativeReader reader, uint offset, out string value)
        {
            return reader.DecodeString(offset, out value);
        }

        public static uint Read(this NativeReader reader, uint offset, out char value)
        {
            uint val;
            offset = reader.DecodeUnsigned(offset, out val);
            value = (char)val;
            return offset;
        }

        public static uint Read(this NativeReader reader, uint offset, out short value)
        {
            int val;
            offset = reader.DecodeSigned(offset, out val);
            value = (short)val;
            return offset;
        }

        public static uint Read(this NativeReader reader, uint offset, out sbyte value)
        {
            value = (sbyte)reader.ReadUInt8(offset);
            return offset + 1;
        }

        public static uint Read(this NativeReader reader, uint offset, out ulong value)
        {
            return reader.DecodeUnsignedLong(offset, out value);
        }

        public static uint Read(this NativeReader reader, uint offset, out int value)
        {
            return reader.DecodeSigned(offset, out value);
        }

        public static uint Read(this NativeReader reader, uint offset, out uint value)
        {
            return reader.DecodeUnsigned(offset, out value);
        }

        public static uint Read(this NativeReader reader, uint offset, out byte value)
        {
            value = reader.ReadUInt8(offset);
            return offset + 1;
        }

        public static uint Read(this NativeReader reader, uint offset, out ushort value)
        {
            uint val;
            offset = reader.DecodeUnsigned(offset, out val);
            value = (ushort)val;
            return offset;
        }

        public static uint Read(this NativeReader reader, uint offset, out long value)
        {
            return reader.DecodeSignedLong(offset, out value);
        }

        public static uint Read(this NativeReader reader, uint offset, out Handle handle)
        {
            uint rawValue;
            offset = reader.DecodeUnsigned(offset, out rawValue);
            handle = new Handle((HandleType)(byte)rawValue, (int)(rawValue >> 8));
            return offset;
        }

        public static uint Read(this NativeReader reader, uint offset, out float value)
        {
            value = reader.ReadFloat(offset);
            return offset + 4;
        }

        public static uint Read(this NativeReader reader, uint offset, out double value)
        {
            value = reader.ReadDouble(offset);
            return offset + 8;
        }
    }
}