• 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/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; }
×
10

11
                public GroupCodeValueType GroupCodeValue { get; protected set; }
×
12

13
                public int Code { get { return (int)this.DxfCode; } }
×
14

15
                public object Value { get; protected set; }
×
16

17
                public virtual int Position { get; protected set; }
×
18

19
                public string ValueRaw { get; protected set; }
×
20

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

33
                public bool ValueAsBool { get { return Convert.ToBoolean(this.Value); } }
×
34

35
                public short ValueAsShort { get { return Convert.ToInt16(this.Value); } }
×
36

37
                public ushort ValueAsUShort { get { return Convert.ToUInt16(this.Value); } }
×
38

39
                public int ValueAsInt { get { return Convert.ToInt32(this.Value); } }
×
40

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

43
                public double ValueAsDouble { get { return Convert.ToDouble(this.Value); } }
×
44

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

47
                public ulong ValueAsHandle { get { return (ulong)this.Value; } }
×
48

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

51
                protected abstract Stream baseStream { get; }
52

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

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

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

70
                        return this.ValueAsString == dxfEntry;
×
71
                }
×
72

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

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

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

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

93
                        this.baseStream.Position = 0;
×
94

95
                        this.Position = 0;
×
96
                }
×
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
                {
×
118
                        switch (code)
×
119
                        {
120
                                case GroupCodeValueType.String:
121
                                case GroupCodeValueType.Comment:
122
                                case GroupCodeValueType.ExtendedDataString:
123
                                        return this.readStringLine();
×
124
                                case GroupCodeValueType.Point3D:
125
                                case GroupCodeValueType.Double:
126
                                case GroupCodeValueType.ExtendedDataDouble:
127
                                        return this.lineAsDouble();
×
128
                                case GroupCodeValueType.Byte:
129
                                case GroupCodeValueType.Int16:
130
                                case GroupCodeValueType.ExtendedDataInt16:
131
                                        return this.lineAsShort();
×
132
                                case GroupCodeValueType.Int32:
133
                                case GroupCodeValueType.ExtendedDataInt32:
134
                                        return this.lineAsInt();
×
135
                                case GroupCodeValueType.Int64:
136
                                        return this.lineAsLong();
×
137
                                case GroupCodeValueType.Handle:
138
                                case GroupCodeValueType.ObjectId:
139
                                case GroupCodeValueType.ExtendedDataHandle:
140
                                        return this.lineAsHandle();
×
141
                                case GroupCodeValueType.Bool:
142
                                        return this.lineAsBool();
×
143
                                case GroupCodeValueType.Chunk:
144
                                case GroupCodeValueType.ExtendedDataChunk:
145
                                        return this.lineAsBinaryChunk();
×
146
                                case GroupCodeValueType.None:
147
                                default:
148
                                        throw new DxfException((int)code, this.Position);
×
149
                        }
150
                }
×
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