• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfTextReader.cs
1
using System.Globalization;
2
using System.IO;
3
using System.Text;
4

5
namespace ACadSharp.IO.DXF
6
{
7
        internal class DxfTextReader : DxfStreamReaderBase
8
        {
9
                protected override Stream baseStream { get { return this._stream.BaseStream; } }
×
10

11
                private StreamReader _stream;
12

13
                public DxfTextReader(Stream stream, Encoding encoding)
×
14
                {
×
15
                        this._stream = new StreamReader(stream, encoding);
×
16
                        this.Start();
×
17
                }
×
18

19
                public override void Start()
20
                {
×
21
                        base.Start();
×
22

23
                        this._stream.DiscardBufferedData();
×
24
                }
×
25

26
                public override void ReadNext()
27
                {
×
28
                        base.ReadNext();
×
29
                        this.Position += 2;
×
30
                }
×
31

32
                protected override string readStringLine()
33
                {
×
34
                        this.ValueRaw = this._stream.ReadLine();
×
35
                        return this.ValueRaw;
×
36
                }
×
37

38
                protected override DxfCode readCode()
39
                {
×
40
                        string line = this.readStringLine();
×
41

42
                        if (int.TryParse(line, NumberStyles.Integer, CultureInfo.InvariantCulture, out int value))
×
43
                        {
×
44
                                return (DxfCode)value;
×
45
                        }
46

47
                        this.Position++;
×
48

49
                        return DxfCode.Invalid;
×
50
                }
×
51

52
                protected override bool lineAsBool()
53
                {
×
54
                        var str = this.readStringLine();
×
55

56
                        if (byte.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out byte result))
×
57
                        {
×
58
                                return result > 0;
×
59
                        }
60

61
                        return false;
×
62
                }
×
63

64
                protected override double lineAsDouble()
65
                {
×
66
                        var str = this.readStringLine();
×
67

68
                        if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
×
69
                        {
×
70
                                return result;
×
71
                        }
72

73
                        return 0.0;
×
74
                }
×
75

76
                protected override short lineAsShort()
77
                {
×
78
                        var str = this.readStringLine();
×
79

80
                        if (short.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out short result))
×
81
                        {
×
82
                                return result;
×
83
                        }
84

85
                        return 0;
×
86
                }
×
87

88
                protected override int lineAsInt()
89
                {
×
90
                        var str = this.readStringLine();
×
91

92
                        if (int.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out int result))
×
93
                        {
×
94
                                return result;
×
95
                        }
96

97
                        return 0;
×
98
                }
×
99

100
                protected override long lineAsLong()
101
                {
×
102
                        var str = this.readStringLine();
×
103

104
                        if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long result))
×
105
                        {
×
106
                                return result;
×
107
                        }
108

109
                        return 0;
×
110
                }
×
111

112
                protected override ulong lineAsHandle()
113
                {
×
114
                        var str = this.readStringLine();
×
115

116
                        if (ulong.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong result))
×
117
                        {
×
118
                                return result;
×
119
                        }
120

121
                        return 0;
×
122
                }
×
123

124
                protected override byte[] lineAsBinaryChunk()
125
                {
×
126
                        var str = this.readStringLine();
×
127

128
                        byte[] bytes = new byte[str.Length];
×
129

130
                        for (int i = 0; i < str.Length; i++)
×
131
                        {
×
132
                                //Create a byte value
133
                                string hex = $"{str[i]}{str[++i]}";
×
134

135
                                if (byte.TryParse(hex, NumberStyles.AllowHexSpecifier | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out byte result))
×
136
                                {
×
137
                                        bytes[i] = result;
×
138
                                }
×
139
                                else
140
                                {
×
141
                                        return new byte[0];
×
142
                                }
143
                        }
×
144

145
                        return bytes;
×
146
                }
×
147
        }
148
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc