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

DomCR / ACadSharp / 12612533277

04 Jan 2025 05:51PM UTC coverage: 75.623% (+0.6%) from 75.001%
12612533277

push

github

web-flow
Merge pull request #486 from DomCR/dynamic-blocks

Dynamic blocks

5196 of 7588 branches covered (68.48%)

Branch coverage included in aggregate %.

276 of 360 new or added lines in 21 files covered. (76.67%)

3 existing lines in 1 file now uncovered.

20797 of 26784 relevant lines covered (77.65%)

36308.12 hits per line

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

88.64
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs
1
using ACadSharp.Exceptions;
2
using System;
3
using System.IO;
4

5
namespace ACadSharp.IO.DXF
6
{
7
        internal abstract class DxfStreamReaderBase : IDxfStreamReader
8
        {
9
                public DxfCode DxfCode { get; protected set; }
17,099,138✔
10

11
                public GroupCodeValueType GroupCodeValue { get; protected set; }
6,676,273✔
12

13
                public int Code { get { return (int)this.DxfCode; } }
28,343,907✔
14

15
                public object Value { get; protected set; }
6,183,447✔
16

17
                public virtual int Position { get; protected set; }
3,207,520✔
18

19
                public string ValueRaw { get; protected set; }
7,605,464✔
20

21
                public string ValueAsString
22
                {
23
                        get
24
                        {
1,336,750✔
25
                                return this.Value.ToString()
1,336,750✔
26
                                        .Replace("^J", "\n")
1,336,750✔
27
                                        .Replace("^M", "\r")
1,336,750✔
28
                                        .Replace("^I", "\t")
1,336,750✔
29
                                        .Replace("^ ", "^");
1,336,750✔
30
                        }
1,336,750✔
31
                }
32

33
                public bool ValueAsBool { get { return Convert.ToBoolean(this.Value); } }
53,547✔
34

35
                public short ValueAsShort { get { return Convert.ToInt16(this.Value); } }
85,611✔
36

37
                public ushort ValueAsUShort { get { return Convert.ToUInt16(this.Value); } }
19,719✔
38

39
                public int ValueAsInt { get { return Convert.ToInt32(this.Value); } }
516,696✔
40

41
                public long ValueAsLong { get { return Convert.ToInt64(this.Value); } }
×
42

43
                public double ValueAsDouble { get { return Convert.ToDouble(this.Value); } }
393,327✔
44

45
                public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * MathUtils.RadToDegFactor); } }
2,160✔
46

47
                public ulong ValueAsHandle { get { return (ulong)this.Value; } }
640,791✔
48

49
                public byte[] ValueAsBinaryChunk { get { return this.Value as byte[]; } }
6✔
50

51
                protected abstract Stream baseStream { get; }
52

53
                public virtual void ReadNext()
54
                {
3,101,562✔
55
                        this.DxfCode = this.readCode();
3,101,562✔
56
                        this.GroupCodeValue = ACadSharp.GroupCodeValue.TransformValue(this.Code);
3,101,562✔
57
                        this.Value = this.transformValue(this.GroupCodeValue);
3,101,562✔
58
                }
3,101,562✔
59

60
                public bool Find(string dxfEntry)
61
                {
262✔
62
                        this.Start();
262✔
63

64
                        do
65
                        {
96,593✔
66
                                this.ReadNext();
96,593✔
67
                        }
96,593✔
68
                        while (this.ValueAsString != dxfEntry && (this.ValueAsString != DxfFileToken.EndOfFile));
96,593✔
69

70
                        return this.ValueAsString == dxfEntry;
262✔
71
                }
262✔
72

73
                public void ExpectedCode(int code)
74
                {
174✔
75
                        this.ReadNext();
174✔
76

77
                        if (this.Code != code)
174!
NEW
78
                        {
×
NEW
79
                                throw new DxfException(code, this.Position);
×
80
                        }
81
                }
174✔
82

83
                public override string ToString()
84
                {
×
85
                        return $"{Code} | {Value}";
×
86
                }
×
87

88
                public virtual void Start()
89
                {
674✔
90
                        this.DxfCode = DxfCode.Invalid;
674✔
91
                        this.Value = string.Empty;
674✔
92

93
                        this.baseStream.Position = 0;
674✔
94

95
                        this.Position = 0;
674✔
96
                }
674✔
97

98
                protected abstract DxfCode readCode();
99

100
                protected abstract string readStringLine();
101

102
                protected abstract double lineAsDouble();
103

104
                protected abstract short lineAsShort();
105

106
                protected abstract int lineAsInt();
107

108
                protected abstract long lineAsLong();
109

110
                protected abstract ulong lineAsHandle();
111

112
                protected abstract byte[] lineAsBinaryChunk();
113

114
                protected abstract bool lineAsBool();
115

116
                private object transformValue(GroupCodeValueType code)
117
                {
3,101,562✔
118
                        switch (code)
3,101,562!
119
                        {
120
                                case GroupCodeValueType.String:
121
                                case GroupCodeValueType.Comment:
122
                                case GroupCodeValueType.ExtendedDataString:
123
                                        return this.readStringLine();
946,666✔
124
                                case GroupCodeValueType.Point3D:
125
                                case GroupCodeValueType.Double:
126
                                case GroupCodeValueType.ExtendedDataDouble:
127
                                        return this.lineAsDouble();
783,442✔
128
                                case GroupCodeValueType.Byte:
129
                                case GroupCodeValueType.Int16:
130
                                case GroupCodeValueType.ExtendedDataInt16:
131
                                        return this.lineAsShort();
594,279✔
132
                                case GroupCodeValueType.Int32:
133
                                case GroupCodeValueType.ExtendedDataInt32:
134
                                        return this.lineAsInt();
411,488✔
135
                                case GroupCodeValueType.Int64:
136
                                        return this.lineAsLong();
419✔
137
                                case GroupCodeValueType.Handle:
138
                                case GroupCodeValueType.ObjectId:
139
                                case GroupCodeValueType.ExtendedDataHandle:
140
                                        return this.lineAsHandle();
290,783✔
141
                                case GroupCodeValueType.Bool:
142
                                        return this.lineAsBool();
29,761✔
143
                                case GroupCodeValueType.Chunk:
144
                                case GroupCodeValueType.ExtendedDataChunk:
145
                                        return this.lineAsBinaryChunk();
44,724✔
146
                                case GroupCodeValueType.None:
147
                                default:
148
                                        throw new DxfException((int)code, this.Position);
×
149
                        }
150
                }
3,101,562✔
151
        }
152
}
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