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

DomCR / ACadSharp / 22018280625

14 Feb 2026 01:30PM UTC coverage: 77.356% (-0.1%) from 77.463%
22018280625

Pull #978

github

web-flow
Merge cd1c403d2 into 4609c0caf
Pull Request #978: issue-976 context data

8148 of 11392 branches covered (71.52%)

Branch coverage included in aggregate %.

28 of 90 new or added lines in 6 files covered. (31.11%)

722 existing lines in 9 files now uncovered.

29481 of 37252 relevant lines covered (79.14%)

151138.57 hits per line

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

85.31
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.Classes;
2
using ACadSharp.Entities;
3
using ACadSharp.IO.Templates;
4
using ACadSharp.Objects;
5
using ACadSharp.Objects.Evaluations;
6
using CSMath;
7
using System;
8
using System.Collections.Generic;
9
using System.Diagnostics;
10
using System.IO;
11
using System.Linq;
12
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
13
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
14

15
namespace ACadSharp.IO.DXF
16
{
17
        internal class DxfObjectsSectionReader : DxfSectionReaderBase
18
        {
19
                public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
20

21
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
22
                        : base(reader, builder)
209✔
23
                {
209✔
24
                }
209✔
25

26
                public override void Read()
27
                {
209✔
28
                        //Advance to the first value in the section
29
                        this._reader.ReadNext();
209✔
30

31
                        //Loop until the section ends
32
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
77,599✔
33
                        {
77,390✔
34
                                CadTemplate template = null;
77,390✔
35

36
                                try
37
                                {
77,390✔
38
                                        template = this.readObject();
77,390✔
39
                                }
77,390✔
40
                                catch (Exception ex)
×
41
                                {
×
42
                                        if (!this._builder.Configuration.Failsafe)
×
43
                                                throw;
×
44

45
                                        this._builder.Notify($"Error while reading an object at line {this._reader.Position}", NotificationType.Error, ex);
×
46

47
                                        while (this._reader.DxfCode != DxfCode.Start)
×
48
                                                this._reader.ReadNext();
×
49
                                }
×
50

51
                                if (template == null)
77,390✔
52
                                        continue;
×
53

54
                                //Add the object and the template to the builder
55
                                this._builder.AddTemplate(template);
77,390✔
56
                        }
77,390✔
57
                }
209✔
58

59
                private CadTemplate readObject()
60
                {
77,390✔
61
                        this.currentSubclass = string.Empty;
77,390✔
62
                        switch (this._reader.ValueAsString)
77,390!
63
                        {
64
                                case DxfFileToken.ObjectPlaceholder:
65
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
197✔
66
                                case DxfFileToken.ObjectDBColor:
67
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
192✔
68
                                case DxfFileToken.ObjectDictionary:
69
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
21,325✔
70
                                case DxfFileToken.ObjectDictionaryWithDefault:
71
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
197✔
72
                                case DxfFileToken.ObjectLayout:
73
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
807✔
74
                                case DxfFileToken.ObjectPlotSettings:
UNCOV
75
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
76
                                case DxfFileToken.ObjectEvalGraph:
77
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
451✔
78
                                case DxfFileToken.ObjectImageDefinition:
79
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
192✔
80
                                case DxfFileToken.ObjectDictionaryVar:
81
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,814✔
82
                                case DxfFileToken.ObjectPdfDefinition:
83
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
192✔
84
                                case DxfFileToken.ObjectSortEntsTable:
85
                                        return this.readSortentsTable();
576✔
86
                                case DxfFileToken.ObjectImageDefinitionReactor:
87
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
192✔
88
                                case DxfFileToken.ObjectProxyObject:
UNCOV
89
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
90
                                case DxfFileToken.ObjectRasterVariables:
91
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
192✔
92
                                case DxfFileToken.ObjectGroup:
93
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
384✔
94
                                case DxfFileToken.ObjectGeoData:
95
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
96
                                case DxfFileToken.ObjectMaterial:
97
                                        return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,127✔
98
                                case DxfFileToken.ObjectScale:
99
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
6,705✔
100
                                case DxfFileToken.ObjectTableContent:
101
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
320✔
102
                                case DxfFileToken.ObjectVisualStyle:
103
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
4,728✔
104
                                case DxfFileToken.ObjectSpatialFilter:
105
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
192✔
106
                                case DxfFileToken.ObjectMLineStyle:
107
                                        return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
209✔
108
                                case DxfFileToken.ObjectMLeaderStyle:
109
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
406✔
110
                                case DxfFileToken.ObjectTableStyle:
111
                                        return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
197✔
112
                                case DxfFileToken.ObjectXRecord:
113
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
28,926✔
114
                                case DxfFileToken.ObjectBlockRepresentationData:
115
                                        return this.readObjectCodes<BlockRepresentationData>(new CadBlockRepresentationDataTemplate(), this.readBlockRepresentationData);
265✔
116
                                case DxfFileToken.ObjectBlockGripLocationComponent:
117
                                        return this.readObjectCodes<BlockGripExpression>(new CadBlockGripExpressionTemplate(), this.readBlockGripExpression);
1,158✔
118
                                case DxfFileToken.ObjectBlockVisibilityGrip:
119
                                        return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockVisibilityGripTemplate(), this.readBlockVisibilityGrip);
193✔
120
                                case DxfFileToken.ObjectBlockVisibilityParameter:
121
                                        return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
193✔
122
                                case DxfFileToken.ObjectBlockRotationParameter:
123
                                        return this.readObjectCodes<BlockRotationParameter>(new CadBlockRotationParameterTemplate(), this.readBlockRotationParameter);
1✔
124
                                case DxfFileToken.ObjectBlockRotationGrip:
125
                                        return this.readObjectCodes<BlockRotationGrip>(new CadBlockRotationGripTemplate(), this.readBlockRotationGrip);
1✔
126
                                case DxfFileToken.ObjectBlockRotateAction:
127
                                        return this.readObjectCodes<BlockRotationAction>(new CadBlockRotationActionTemplate(), this.readBlockRotationAction);
1✔
128
                                case DxfFileToken.ObjectField:
NEW
UNCOV
129
                                        return this.readObjectCodes<Field>(new CadFieldTemplate(new Field()), this.readField);
×
130
                                case DxfFileToken.ObjectFieldList:
NEW
UNCOV
131
                                        return this.readObjectCodes<FieldList>(new CadNonGraphicalObjectTemplate(new Field()), this.readFieldList);
×
132
                                default:
133
                                        DxfMap map = DxfMap.Create<CadObject>();
4,055✔
134
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
4,055✔
135
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
4,055!
136
                                        {
4,055✔
137
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
4,055✔
138
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
4,055✔
139
                                        }
4,055✔
140
                                        else
UNCOV
141
                                        {
×
UNCOV
142
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
UNCOV
143
                                        }
×
144

145
                                        this._reader.ReadNext();
4,055✔
146

147
                                        do
148
                                        {
252,879✔
149
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
252,879!
150
                                                {
30,576✔
151
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
30,576✔
152
                                                        if (isExtendedData)
30,576✔
153
                                                                continue;
24✔
154
                                                }
30,552✔
155

156
                                                this._reader.ReadNext();
252,855✔
157
                                        }
252,855✔
158
                                        while (this._reader.DxfCode != DxfCode.Start);
252,879✔
159

160
                                        return unknownEntityTemplate;
4,055✔
161
                        }
162
                }
77,390✔
163

164
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
165
                        where T : CadObject
166
                {
72,759✔
167
                        this._reader.ReadNext();
72,759✔
168

169
                        DxfMap map = DxfMap.Create<T>();
72,759✔
170

171
                        while (this._reader.DxfCode != DxfCode.Start)
1,043,139✔
172
                        {
970,380✔
173
                                if (!readObject(template, map))
970,380✔
174
                                {
233,126✔
175
                                        this.readCommonCodes(template, out bool isExtendedData, map);
233,126✔
176
                                        if (isExtendedData)
233,126✔
177
                                                continue;
2,985✔
178
                                }
230,141✔
179

180
                                if (this.lockPointer)
967,395✔
181
                                {
1,798✔
182
                                        this.lockPointer = false;
1,798✔
183
                                        continue;
1,798✔
184
                                }
185

186
                                if (this._reader.DxfCode != DxfCode.Start)
965,597✔
187
                                {
936,671✔
188
                                        this._reader.ReadNext();
936,671✔
189
                                }
936,671✔
190
                        }
965,597✔
191

192
                        return template;
72,759✔
193
                }
72,759✔
194

195
                private bool readFieldList(CadTemplate template, DxfMap map)
NEW
UNCOV
196
                {
×
NEW
UNCOV
197
                        switch (this._reader.Code)
×
198
                        {
199
                                default:
NEW
200
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.FieldList]);
×
201
                        }
NEW
202
                }
×
203

204
                private bool readField(CadTemplate template, DxfMap map)
NEW
205
                {
×
NEW
206
                        var tmp = template as CadFieldTemplate;
×
207

NEW
208
                        switch (this._reader.Code)
×
209
                        {
210
                                case 6:
211
                                case 7:
NEW
212
                                        readACadValue();
×
NEW
213
                                        return true;
×
214
                                case 331:
NEW
215
                                        tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
NEW
216
                                        return true;
×
217
                                case 360:
NEW
218
                                        tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
NEW
219
                                        return true;
×
220
                                default:
NEW
221
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
222
                        }
NEW
223
                }
×
224

225
                private void readACadValue()
NEW
226
                {
×
NEW
227
                        while (this._reader.Code != 304)
×
NEW
228
                        {
×
NEW
229
                        }
×
NEW
230
                }
×
231

232
                private bool readProxyObject(CadTemplate template, DxfMap map)
233
                {
×
234
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
235

236
                        switch (this._reader.Code)
×
237
                        {
238
                                case 90:
239
                                case 94:
240
                                //Undocumented
241
                                case 97:
242
                                case 71:
243
                                        return true;
×
244
                                case 95:
245
                                        int format = this._reader.ValueAsInt;
×
246
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
247
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
248
                                        return true;
×
249
                                case 91:
250
                                        var classId = this._reader.ValueAsShort;
×
251
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
252
                                        {
×
253
                                                proxy.DxfClass = dxfClass;
×
254
                                        }
×
255
                                        return true;
×
256
                                case 161:
257
                                        return true;
×
258
                                case 162:
259
                                        return true;
×
260
                                case 310:
261
                                        if (proxy.BinaryData == null)
×
262
                                        {
×
263
                                                proxy.BinaryData = new MemoryStream();
×
264
                                        }
×
265
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
266
                                        return true;
×
267
                                case 311:
268
                                        if (proxy.Data == null)
×
269
                                        {
×
270
                                                proxy.Data = new MemoryStream();
×
271
                                        }
×
272
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
273
                                        return true;
×
274
                                default:
UNCOV
275
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
276
                        }
277
                }
×
278

279
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
280
                {
23,355✔
281
                        switch (this._reader.Code)
23,355✔
282
                        {
283
                                default:
284
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,355✔
285
                        }
286
                }
23,355✔
287

288
                private bool readPlotSettings(CadTemplate template, DxfMap map)
289
                {
25,534✔
290
                        switch (this._reader.Code)
25,534✔
291
                        {
292
                                default:
293
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,534✔
294
                        }
295
                }
25,534✔
296

297
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
298
                {
3,096✔
299
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,096✔
300
                        EvaluationGraph evGraph = tmp.CadObject;
3,096✔
301

302
                        switch (this._reader.Code)
3,096✔
303
                        {
304
                                case 91:
305
                                        while (this._reader.Code == 91)
3,025✔
306
                                        {
2,574✔
307
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,574✔
308
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,574✔
309

310
                                                node.Index = this._reader.ValueAsInt;
2,574✔
311

312
                                                this._reader.ExpectedCode(93);
2,574✔
313
                                                node.Flags = this._reader.ValueAsInt;
2,574✔
314

315
                                                this._reader.ExpectedCode(95);
2,574✔
316
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,574✔
317

318
                                                this._reader.ExpectedCode(360);
2,574✔
319
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,574✔
320

321
                                                this._reader.ExpectedCode(92);
2,574✔
322
                                                node.Data1 = this._reader.ValueAsInt;
2,574✔
323
                                                this._reader.ExpectedCode(92);
2,574✔
324
                                                node.Data2 = this._reader.ValueAsInt;
2,574✔
325
                                                this._reader.ExpectedCode(92);
2,574✔
326
                                                node.Data3 = this._reader.ValueAsInt;
2,574✔
327
                                                this._reader.ExpectedCode(92);
2,574✔
328
                                                node.Data4 = this._reader.ValueAsInt;
2,574✔
329

330
                                                this._reader.ReadNext();
2,574✔
331

332
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
333
                                        }
2,574✔
334

335
                                        this.lockPointer = true;
451✔
336
                                        return true;
451✔
337
                                case 92:
338
                                        //Edges
339
                                        while (this._reader.Code == 92)
2,126✔
340
                                        {
1,931✔
341
                                                this._reader.ExpectedCode(93);
1,931✔
342
                                                this._reader.ExpectedCode(94);
1,931✔
343
                                                this._reader.ExpectedCode(91);
1,931✔
344
                                                this._reader.ExpectedCode(91);
1,931✔
345
                                                this._reader.ExpectedCode(92);
1,931✔
346
                                                this._reader.ExpectedCode(92);
1,931✔
347
                                                this._reader.ExpectedCode(92);
1,931✔
348
                                                this._reader.ExpectedCode(92);
1,931✔
349
                                                this._reader.ExpectedCode(92);
1,931✔
350

351
                                                this._reader.ReadNext();
1,931✔
352
                                        }
1,931✔
353

354
                                        this.lockPointer = true;
195✔
355
                                        return true;
195✔
356
                                default:
357
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,450✔
358
                        }
359
                }
3,096✔
360

361
                private bool readLayout(CadTemplate template, DxfMap map)
362
                {
51,979✔
363
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,979✔
364

365
                        switch (this._reader.Code)
51,979✔
366
                        {
367
                                case 330:
368
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,614✔
369
                                        return true;
1,614✔
370
                                case 331:
371
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
773✔
372
                                        return true;
773✔
373
                                default:
374
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,592✔
375
                                        {
25,534✔
376
                                                return this.readPlotSettings(template, map);
25,534✔
377
                                        }
378
                                        return true;
24,058✔
379
                        }
380
                }
51,979✔
381

382
                private bool readGroup(CadTemplate template, DxfMap map)
383
                {
4,992✔
384
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
385

386
                        switch (this._reader.Code)
4,992✔
387
                        {
388
                                case 70:
389
                                        return true;
384✔
390
                                case 340:
391
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
392
                                        return true;
2,304✔
393
                                default:
394
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
395
                        }
396
                }
4,992✔
397

398
                private bool readGeoData(CadTemplate template, DxfMap map)
399
                {
102✔
400
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
401

402
                        switch (this._reader.Code)
102✔
403
                        {
404
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
405
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
406
                                                tmp.CadObject.ReferencePoint.X,
1✔
407
                                                this._reader.ValueAsDouble,
1✔
408
                                                tmp.CadObject.ReferencePoint.Z
1✔
409
                                                );
1✔
410
                                        return true;
1✔
411
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
412
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
413
                                                this._reader.ValueAsDouble,
1✔
414
                                                tmp.CadObject.ReferencePoint.Y,
1✔
415
                                                tmp.CadObject.ReferencePoint.Z
1✔
416
                                                );
1✔
417
                                        return true;
1✔
418
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
419
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
420
                                                tmp.CadObject.ReferencePoint.X,
1✔
421
                                                tmp.CadObject.ReferencePoint.Y,
1✔
422
                                                this._reader.ValueAsDouble
1✔
423
                                                );
1✔
424
                                        return true;
1✔
425
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
426
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
427
                                        return true;
1✔
428
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
429
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
430
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
431
                                        return true;
1✔
432
                                // Number of Geo-Mesh points
433
                                case 93:
434
                                        var npts = this._reader.ValueAsInt;
3✔
435
                                        for (int i = 0; i < npts; i++)
54✔
436
                                        {
24✔
437
                                                this._reader.ReadNext();
24✔
438
                                                double sourceX = this._reader.ValueAsDouble;
24✔
439
                                                this._reader.ReadNext();
24✔
440
                                                double sourceY = this._reader.ValueAsDouble;
24✔
441

442
                                                this._reader.ReadNext();
24✔
443
                                                double destX = this._reader.ValueAsDouble;
24✔
444
                                                this._reader.ReadNext();
24✔
445
                                                double destY = this._reader.ValueAsDouble;
24✔
446

447
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
448
                                                {
24✔
449
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
450
                                                        Destination = new CSMath.XY(destX, destY)
24✔
451
                                                });
24✔
452
                                        }
24✔
453
                                        return true;
3✔
454
                                // Number of Geo-Mesh points
455
                                case 96:
456
                                        var nfaces = this._reader.ValueAsInt;
2✔
457
                                        for (int i = 0; i < nfaces; i++)
4!
UNCOV
458
                                        {
×
UNCOV
459
                                                this._reader.ReadNext();
×
UNCOV
460
                                                Debug.Assert(this._reader.Code == 97);
×
UNCOV
461
                                                int index1 = this._reader.ValueAsInt;
×
UNCOV
462
                                                this._reader.ReadNext();
×
UNCOV
463
                                                Debug.Assert(this._reader.Code == 98);
×
UNCOV
464
                                                int index2 = this._reader.ValueAsInt;
×
UNCOV
465
                                                this._reader.ReadNext();
×
UNCOV
466
                                                Debug.Assert(this._reader.Code == 99);
×
UNCOV
467
                                                int index3 = this._reader.ValueAsInt;
×
468

UNCOV
469
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
UNCOV
470
                                                {
×
UNCOV
471
                                                        Index1 = index1,
×
UNCOV
472
                                                        Index2 = index2,
×
UNCOV
473
                                                        Index3 = index3
×
UNCOV
474
                                                });
×
UNCOV
475
                                        }
×
476
                                        return true;
2✔
477
                                case 303:
478
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
479
                                        return true;
13✔
480
                                //Obsolete codes for version GeoDataVersion.R2009
481
                                case 3:
482
                                case 4:
483
                                case 14:
484
                                case 24:
485
                                case 15:
486
                                case 25:
487
                                case 43:
488
                                case 44:
489
                                case 45:
490
                                case 94:
491
                                case 293:
492
                                case 16:
493
                                case 26:
494
                                case 17:
495
                                case 27:
496
                                case 54:
497
                                case 140:
498
                                case 304:
499
                                case 292:
500
                                        return true;
19✔
501
                                default:
502
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
503
                        }
504
                }
102✔
505

506
                private bool readMaterial(CadTemplate template, DxfMap map)
507
                {
42,114✔
508
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,114✔
509
                        List<double> arr = null;
42,114✔
510

511
                        switch (this._reader.Code)
42,114!
512
                        {
513
                                case 43:
514
                                        arr = new();
1,349✔
515
                                        for (int i = 0; i < 16; i++)
45,866✔
516
                                        {
21,584✔
517
                                                Debug.Assert(this._reader.Code == 43);
21,584✔
518

519
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
520

521
                                                this._reader.ReadNext();
21,584✔
522
                                        }
21,584✔
523

524
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,349✔
525
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,349✔
526
                                case 47:
UNCOV
527
                                        arr = new();
×
UNCOV
528
                                        for (int i = 0; i < 16; i++)
×
UNCOV
529
                                        {
×
UNCOV
530
                                                Debug.Assert(this._reader.Code == 47);
×
531

532
                                                arr.Add(this._reader.ValueAsDouble);
×
533

534
                                                this._reader.ReadNext();
×
535
                                        }
×
536

537
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
538
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
539
                                case 49:
540
                                        arr = new();
197✔
541
                                        for (int i = 0; i < 16; i++)
6,698✔
542
                                        {
3,152✔
543
                                                Debug.Assert(this._reader.Code == 49);
3,152✔
544

545
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
546

547
                                                this._reader.ReadNext();
3,152✔
548
                                        }
3,152✔
549

550
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
551
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
552
                                case 142:
553
                                        arr = new();
197✔
554
                                        for (int i = 0; i < 16; i++)
6,698✔
555
                                        {
3,152✔
556
                                                Debug.Assert(this._reader.Code == 142);
3,152✔
557

558
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
559

560
                                                this._reader.ReadNext();
3,152✔
561
                                        }
3,152✔
562

563
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
564
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
565
                                case 144:
566
                                        arr = new();
1,157✔
567
                                        for (int i = 0; i < 16; i++)
39,338✔
568
                                        {
18,512✔
569
                                                Debug.Assert(this._reader.Code == 144);
18,512✔
570

571
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
572

573
                                                this._reader.ReadNext();
18,512✔
574
                                        }
18,512✔
575

576
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,157✔
577
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,157✔
578
                                case 147:
UNCOV
579
                                        arr = new();
×
UNCOV
580
                                        for (int i = 0; i < 16; i++)
×
UNCOV
581
                                        {
×
UNCOV
582
                                                Debug.Assert(this._reader.Code == 147);
×
583

UNCOV
584
                                                arr.Add(this._reader.ValueAsDouble);
×
585

UNCOV
586
                                                this._reader.ReadNext();
×
UNCOV
587
                                        }
×
588

UNCOV
589
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
UNCOV
590
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
591
                                default:
592
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,214✔
593
                        }
594
                }
42,114✔
595

596
                private bool readScale(CadTemplate template, DxfMap map)
597
                {
60,141✔
598
                        switch (this._reader.Code)
60,141✔
599
                        {
600
                                // Undocumented codes
601
                                case 70:
602
                                        //Always 0
603
                                        return true;
6,705✔
604
                                default:
605
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
53,436✔
606
                        }
607
                }
60,141✔
608

609
                private void readLinkedData(CadTemplate template, DxfMap map)
610
                {
320✔
611
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
612
                        LinkedData linkedData = tmp.CadObject;
320✔
613

614
                        this._reader.ReadNext();
320✔
615

616
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
617
                        {
640✔
618
                                switch (this._reader.Code)
640✔
619
                                {
620
                                        default:
621
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
UNCOV
622
                                                {
×
UNCOV
623
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
624
                                                }
×
625
                                                break;
640✔
626
                                }
627

628
                                this._reader.ReadNext();
640✔
629
                        }
640✔
630
                }
320✔
631

632
                private bool readTableContent(CadTemplate template, DxfMap map)
633
                {
2,368✔
634
                        switch (this._reader.Code)
2,368✔
635
                        {
636
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
637
                                        this.readTableContentSubclass(template, map);
256✔
638
                                        this.lockPointer = true;
256✔
639
                                        return true;
256✔
640
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
641
                                        this.readFormattedTableDataSubclass(template, map);
256✔
642
                                        this.lockPointer = true;
256✔
643
                                        return true;
256✔
644
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
645
                                        this.readLinkedTableDataSubclass(template, map);
320✔
646
                                        this.lockPointer = true;
320✔
647
                                        return true;
320✔
648
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
649
                                        this.readLinkedData(template, map);
320✔
650
                                        this.lockPointer = true;
320✔
651
                                        return true;
320✔
652
                                default:
653
                                        return false;
1,216✔
654
                        }
655
                }
2,368✔
656

657
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
658
                {
256✔
659
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
660
                        TableContent tableContent = tmp.CadObject;
256✔
661

662
                        this._reader.ReadNext();
256✔
663

664
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
665
                        {
256✔
666
                                switch (this._reader.Code)
256!
667
                                {
668
                                        case 340:
669
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
670
                                                break;
256✔
671
                                        default:
UNCOV
672
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
UNCOV
673
                                                {
×
UNCOV
674
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
675
                                                }
×
UNCOV
676
                                                break;
×
677
                                }
678

679
                                this._reader.ReadNext();
256✔
680
                        }
256✔
681
                }
256✔
682

683
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
684
                {
256✔
685
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
686
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
687

688
                        this._reader.ReadNext();
256✔
689

690
                        TableEntity.CellRange cellRange = null;
256✔
691
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
692
                        {
2,048✔
693
                                switch (this._reader.Code)
2,048!
694
                                {
695
                                        case 90:
696
                                                break;
256✔
697
                                        case 91:
698
                                                if (cellRange == null)
384✔
699
                                                {
384✔
700
                                                        cellRange = new();
384✔
701
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
702
                                                }
384✔
703
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
704
                                                break;
384✔
705
                                        case 92:
706
                                                if (cellRange == null)
384!
UNCOV
707
                                                {
×
UNCOV
708
                                                        cellRange = new();
×
UNCOV
709
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
UNCOV
710
                                                }
×
711
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
712
                                                break;
384✔
713
                                        case 93:
714
                                                if (cellRange == null)
384!
UNCOV
715
                                                {
×
UNCOV
716
                                                        cellRange = new();
×
UNCOV
717
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
UNCOV
718
                                                }
×
719
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
720
                                                break;
384✔
721
                                        case 94:
722
                                                if (cellRange == null)
384!
UNCOV
723
                                                {
×
UNCOV
724
                                                        cellRange = new();
×
UNCOV
725
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
UNCOV
726
                                                }
×
727
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
728
                                                cellRange = null;
384✔
729
                                                break;
384✔
730
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
731
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
732
                                                break;
256✔
733
                                        default:
UNCOV
734
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
UNCOV
735
                                                {
×
UNCOV
736
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
737
                                                }
×
UNCOV
738
                                                break;
×
739
                                }
740

741
                                this._reader.ReadNext();
2,048✔
742
                        }
2,048✔
743
                }
256✔
744

745
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
746
                {
320✔
747
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
748
                        TableContent tableContent = tmp.CadObject;
320✔
749

750
                        this._reader.ReadNext();
320✔
751

752
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
753
                        {
3,904✔
754
                                switch (this._reader.Code)
3,904✔
755
                                {
756
                                        case 90:
757
                                                //Column count
758
                                                break;
320✔
759
                                        case 91:
760
                                                //Row count
761
                                                break;
320✔
762
                                        //Unknown
763
                                        case 92:
764
                                                break;
256✔
765
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
766
                                                //Read Column
767
                                                this.readTableColumn();
1,216✔
768
                                                break;
1,216✔
769
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
770
                                                //Read Row
771
                                                this.readTableRow();
1,472✔
772
                                                break;
1,472✔
773
                                        default:
774
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
775
                                                {
320✔
776
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
777
                                                }
320✔
778
                                                break;
320✔
779
                                }
780

781
                                this._reader.ReadNext();
3,904✔
782
                        }
3,904✔
783
                }
320✔
784

785

786
                private TableEntity.Column readTableColumn()
787
                {
1,216✔
788
                        this._reader.ReadNext();
1,216✔
789

790
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
791

792
                        bool end = false;
1,216✔
793
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
794
                        {
3,648✔
795
                                switch (this._reader.Code)
3,648!
796
                                {
797
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
798
                                                this.readLinkedTableColumn(column);
1,216✔
799
                                                break;
1,216✔
800
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
801
                                                this.readFormattedTableColumn(column);
1,216✔
802
                                                break;
1,216✔
803
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
804
                                                this.readTableColumn(column);
1,216✔
805
                                                end = true;
1,216✔
806
                                                break;
1,216✔
807
                                        default:
808
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
809
                                                break;
×
810
                                }
811

812
                                if (end)
3,648✔
813
                                {
1,216✔
814
                                        return column;
1,216✔
815
                                }
816

817
                                this._reader.ReadNext();
2,432✔
818
                        }
2,432✔
819

UNCOV
820
                        return column;
×
821
                }
1,216✔
822

823
                private TableEntity.Row readTableRow()
824
                {
1,472✔
825
                        this._reader.ReadNext();
1,472✔
826

827
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
828

829
                        bool end = false;
1,472✔
830
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
831
                        {
11,840✔
832
                                switch (this._reader.Code)
11,840✔
833
                                {
834
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
835
                                                this.readLinkedTableRow(row);
1,536✔
836
                                                break;
1,536✔
837
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
838
                                                this.readFormattedTableRow(row);
1,408✔
839
                                                break;
1,408✔
840
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
841
                                                this.readTableRow(row);
1,408✔
842
                                                end = true;
1,408✔
843
                                                break;
1,408✔
844
                                        default:
845
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
846
                                                break;
7,488✔
847
                                }
848

849
                                if (end)
11,840✔
850
                                {
1,408✔
851
                                        return row;
1,408✔
852
                                }
853

854
                                this._reader.ReadNext();
10,432✔
855
                        }
10,432✔
856

857
                        return row;
64✔
858
                }
1,472✔
859

860
                private void readTableRow(TableEntity.Row row)
861
                {
1,408✔
862
                        this._reader.ReadNext();
1,408✔
863

864
                        bool end = false;
1,408✔
865
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
866
                        {
4,224✔
867
                                switch (this._reader.Code)
4,224!
868
                                {
869
                                        case 40:
870
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
871
                                                break;
1,408✔
872
                                        case 90:
873
                                                //styleID
874
                                                break;
1,408✔
875
                                        case 309:
876
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
877
                                                break;
1,408✔
878
                                        default:
UNCOV
879
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
UNCOV
880
                                                break;
×
881
                                }
882

883
                                if (end)
4,224✔
884
                                {
1,408✔
885
                                        break;
1,408✔
886
                                }
887

888
                                this._reader.ReadNext();
2,816✔
889
                        }
2,816✔
890
                }
1,408✔
891

892
                private void readFormattedTableRow(TableEntity.Row row)
893
                {
1,408✔
894
                        this._reader.ReadNext();
1,408✔
895

896
                        bool end = false;
1,408✔
897
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
898
                        {
4,224✔
899
                                switch (this._reader.Code)
4,224!
900
                                {
901
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
902
                                                break;
1,408✔
903
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
904
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
905
                                                break;
1,408✔
906
                                        case 309:
907
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
908
                                                break;
1,408✔
909
                                        default:
UNCOV
910
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
UNCOV
911
                                                break;
×
912
                                }
913

914
                                if (end)
4,224✔
915
                                {
1,408✔
916
                                        break;
1,408✔
917
                                }
918

919
                                this._reader.ReadNext();
2,816✔
920
                        }
2,816✔
921
                }
1,408✔
922

923
                private void readTableColumn(TableEntity.Column column)
924
                {
1,216✔
925
                        this._reader.ReadNext();
1,216✔
926

927
                        bool end = false;
1,216✔
928
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
929
                        {
3,648✔
930
                                switch (this._reader.Code)
3,648!
931
                                {
UNCOV
932
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
933
                                                break;
×
934
                                        case 1:
UNCOV
935
                                                end = true;
×
UNCOV
936
                                                break;
×
937
                                        case 40:
938
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
939
                                                break;
1,216✔
940
                                        case 90:
941
                                                //StyleId
942
                                                break;
1,216✔
943
                                        case 309:
944
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
945
                                                break;
1,216✔
946
                                        default:
UNCOV
947
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
UNCOV
948
                                                break;
×
949
                                }
950

951
                                if (end)
3,648✔
952
                                {
1,216✔
953
                                        break;
1,216✔
954
                                }
955

956
                                this._reader.ReadNext();
2,432✔
957
                        }
2,432✔
958
                }
1,216✔
959

960
                private void readLinkedTableColumn(TableEntity.Column column)
961
                {
1,216✔
962
                        this._reader.ReadNext();
1,216✔
963

964
                        bool end = false;
1,216✔
965
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
966
                        {
4,864✔
967
                                switch (this._reader.Code)
4,864!
968
                                {
UNCOV
969
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
970
                                                break;
×
971
                                        case 1:
UNCOV
972
                                                end = true;
×
UNCOV
973
                                                break;
×
974
                                        case 91:
975
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
976
                                                break;
1,216✔
977
                                        case 300:
978
                                                column.Name = this._reader.ValueAsString;
1,216✔
979
                                                break;
1,216✔
980
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
981
                                                this.readCustomData();
1,216✔
982
                                                break;
1,216✔
983
                                        case 309:
984
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
985
                                                break;
1,216✔
986
                                        default:
UNCOV
987
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
UNCOV
988
                                                break;
×
989
                                }
990

991
                                if (end)
4,864✔
992
                                {
1,216✔
993
                                        break;
1,216✔
994
                                }
995

996
                                this._reader.ReadNext();
3,648✔
997
                        }
3,648✔
998
                }
1,216✔
999

1000
                private void readLinkedTableRow(TableEntity.Row row)
1001
                {
1,536✔
1002
                        this._reader.ReadNext();
1,536✔
1003

1004
                        bool end = false;
1,536✔
1005
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
1006
                        {
12,480✔
1007
                                switch (this._reader.Code)
12,480!
1008
                                {
1009
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
1010
                                                break;
×
1011
                                        case 90:
1012
                                                break;
1,536✔
1013
                                        case 91:
1014
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
1015
                                                break;
1,408✔
1016
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1017
                                                this.readCell();
5,376✔
1018
                                                break;
5,376✔
1019
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
1020
                                                this.readCustomData();
1,408✔
1021
                                                break;
1,408✔
1022
                                        case 309:
1023
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
1024
                                                break;
1,408✔
1025
                                        default:
1026
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
1027
                                                break;
1,344✔
1028
                                }
1029

1030
                                if (end)
12,480✔
1031
                                {
1,408✔
1032
                                        break;
1,408✔
1033
                                }
1034

1035
                                this._reader.ReadNext();
11,072✔
1036
                        }
11,072✔
1037
                }
1,536✔
1038

1039
                private TableEntity.Cell readCell()
1040
                {
5,376✔
1041
                        this._reader.ReadNext();
5,376✔
1042

1043
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
1044
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
1045

1046
                        bool end = false;
5,376✔
1047
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
1048
                        {
16,832✔
1049
                                switch (this._reader.Code)
16,832✔
1050
                                {
1051
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
1052
                                                this.readLinkedTableCell(cell);
5,376✔
1053
                                                break;
5,376✔
1054
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
1055
                                                this.readFormattedTableCell(cell);
5,248✔
1056
                                                break;
5,248✔
1057
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1058
                                                this.readTableCell(cell);
5,248✔
1059
                                                end = true;
5,248✔
1060
                                                break;
5,248✔
1061
                                        default:
1062
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1063
                                                break;
960✔
1064
                                }
1065

1066
                                if (end)
16,832✔
1067
                                {
5,248✔
1068
                                        return cell;
5,248✔
1069
                                }
1070

1071
                                this._reader.ReadNext();
11,584✔
1072
                        }
11,584✔
1073

1074
                        return cell;
128✔
1075
                }
5,376✔
1076

1077
                private void readTableCell(TableEntity.Cell cell)
1078
                {
5,248✔
1079
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1080

1081
                        this._reader.ReadNext();
5,248✔
1082

1083
                        bool end = false;
5,248✔
1084
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1085
                        {
16,384✔
1086
                                switch (this._reader.Code)
16,384✔
1087
                                {
1088
                                        //Unknown
1089
                                        case 40:
1090
                                        case 41:
1091
                                                break;
256✔
1092
                                        case 309:
1093
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1094
                                                break;
5,248✔
1095
                                        case 330:
1096
                                                //Unknown handle
1097
                                                break;
128✔
1098
                                        default:
1099
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
UNCOV
1100
                                                {
×
UNCOV
1101
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1102
                                                }
×
1103
                                                break;
10,752✔
1104
                                }
1105

1106
                                if (end)
16,384✔
1107
                                {
5,248✔
1108
                                        break;
5,248✔
1109
                                }
1110

1111
                                this._reader.ReadNext();
11,136✔
1112
                        }
11,136✔
1113
                }
5,248✔
1114

1115
                private void readFormattedTableCell(TableEntity.Cell cell)
1116
                {
5,248✔
1117
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1118

1119
                        this._reader.ReadNext();
5,248✔
1120

1121
                        bool end = false;
5,248✔
1122
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1123
                        {
10,496✔
1124
                                switch (this._reader.Code)
10,496!
1125
                                {
1126
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1127
                                                this.readCellTableFormat(cell);
5,248✔
1128
                                                continue;
5,248✔
1129
                                        case 309:
1130
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1131
                                                break;
5,248✔
1132
                                        default:
UNCOV
1133
                                                if (!this.tryAssignCurrentValue(cell, map))
×
UNCOV
1134
                                                {
×
UNCOV
1135
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1136
                                                }
×
UNCOV
1137
                                                break;
×
1138
                                }
1139

1140
                                if (end)
5,248!
1141
                                {
5,248✔
1142
                                        break;
5,248✔
1143
                                }
1144

UNCOV
1145
                                this._reader.ReadNext();
×
UNCOV
1146
                        }
×
1147
                }
5,248✔
1148

1149
                private void readCellTableFormat(TableEntity.Cell cell)
1150
                {
5,248✔
1151
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1152

1153
                        this._reader.ReadNext();
5,248✔
1154

1155
                        bool end = false;
5,248✔
1156
                        while (this._reader.Code == 1)
10,496✔
1157
                        {
5,248✔
1158
                                switch (this._reader.Code)
5,248!
1159
                                {
1160
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1161
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1162
                                                break;
5,248✔
UNCOV
1163
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1164
                                                this.readCellStyle(new CadCellStyleTemplate());
×
UNCOV
1165
                                                break;
×
1166
                                        default:
UNCOV
1167
                                                if (!this.tryAssignCurrentValue(cell, map))
×
UNCOV
1168
                                                {
×
UNCOV
1169
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1170
                                                }
×
UNCOV
1171
                                                break;
×
1172
                                }
1173

1174
                                if (end)
5,248!
1175
                                {
×
1176
                                        break;
×
1177
                                }
1178

1179
                                this._reader.ReadNext();
5,248✔
1180
                        }
5,248✔
1181
                }
5,248✔
1182

1183
                private void readCellStyle(CadCellStyleTemplate template)
UNCOV
1184
                {
×
1185
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1186

UNCOV
1187
                        this._reader.ReadNext();
×
1188

UNCOV
1189
                        bool end = false;
×
UNCOV
1190
                        while (this._reader.Code != 1)
×
UNCOV
1191
                        {
×
UNCOV
1192
                                switch (this._reader.Code)
×
1193
                                {
1194
                                        case 309:
UNCOV
1195
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1196
                                                break;
×
1197
                                        default:
1198
                                                //if (!this.tryAssignCurrentValue(cell, map))
UNCOV
1199
                                                {
×
UNCOV
1200
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1201
                                                }
×
UNCOV
1202
                                                break;
×
1203
                                }
1204

UNCOV
1205
                                if (end)
×
UNCOV
1206
                                {
×
1207
                                        break;
×
1208
                                }
1209

1210
                                this._reader.ReadNext();
×
1211
                        }
×
UNCOV
1212
                }
×
1213

1214
                private void readLinkedTableCell(TableEntity.Cell cell)
1215
                {
5,376✔
1216
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1217

1218
                        this._reader.ReadNext();
5,376✔
1219

1220
                        bool end = false;
5,376✔
1221
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1222
                        {
53,760✔
1223
                                switch (this._reader.Code)
53,760✔
1224
                                {
1225
                                        case 95:
1226
                                                //BL 95 Number of cell contents
1227
                                                break;
5,248✔
1228
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1229
                                                this.readCustomData();
5,376✔
1230
                                                break;
5,376✔
1231
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1232
                                                var c = this.readLinkedTableCellContent();
4,096✔
1233
                                                break;
4,096✔
1234
                                        case 309:
1235
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1236
                                                break;
5,248✔
1237
                                        default:
1238
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1239
                                                {
11,648✔
1240
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1241
                                                }
11,648✔
1242
                                                break;
33,792✔
1243
                                }
1244

1245
                                if (end)
53,760✔
1246
                                {
5,248✔
1247
                                        break;
5,248✔
1248
                                }
1249

1250
                                this._reader.ReadNext();
48,512✔
1251
                        }
48,512✔
1252
                }
5,376✔
1253

1254
                private CadTableCellContentTemplate readLinkedTableCellContent()
1255
                {
4,096✔
1256
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1257
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1258
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1259

1260
                        this._reader.ReadNext();
4,096✔
1261

1262
                        bool end = false;
4,096✔
1263
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1264
                        {
8,192✔
1265
                                switch (this._reader.Code)
8,192!
1266
                                {
1267
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1268
                                                readFormattedCellContent();
4,096✔
1269
                                                end = true;
4,096✔
1270
                                                break;
4,096✔
1271
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1272
                                                readCellContent(template);
4,096✔
1273
                                                break;
4,096✔
1274
                                        default:
1275
                                                if (!this.tryAssignCurrentValue(content, map))
×
1276
                                                {
×
UNCOV
1277
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1278
                                                }
×
1279
                                                break;
×
1280
                                }
1281

1282
                                if (end)
8,192✔
1283
                                {
4,096✔
1284
                                        break;
4,096✔
1285
                                }
1286

1287
                                this._reader.ReadNext();
4,096✔
1288
                        }
4,096✔
1289

1290
                        return template;
4,096✔
1291
                }
4,096✔
1292

1293
                private void readCellContent(CadTableCellContentTemplate template)
1294
                {
4,096✔
1295
                        TableEntity.CellContent content = template.Content;
4,096✔
1296
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1297

1298
                        this._reader.ReadNext();
4,096✔
1299

1300
                        bool end = false;
4,096✔
1301
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1302
                        {
16,384✔
1303
                                switch (this._reader.Code)
16,384✔
1304
                                {
1305
                                        case 91:
1306
                                                break;
4,096✔
1307
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1308
                                                this.readDataMapValue();
3,712✔
1309
                                                break;
3,712✔
1310
                                        case 309:
1311
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1312
                                                break;
4,096✔
1313
                                        case 340:
1314
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1315
                                                break;
384✔
1316
                                        default:
1317
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
UNCOV
1318
                                                {
×
UNCOV
1319
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1320
                                                }
×
1321
                                                break;
4,096✔
1322
                                }
1323

1324
                                if (end)
16,384✔
1325
                                {
4,096✔
1326
                                        break;
4,096✔
1327
                                }
1328

1329
                                this._reader.ReadNext();
12,288✔
1330
                        }
12,288✔
1331
                }
4,096✔
1332

1333
                private void readFormattedCellContent()
1334
                {
4,096✔
1335
                        TableEntity.ContentFormat format = new();
4,096✔
1336
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1337
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1338

1339
                        this._reader.ReadNext();
4,096✔
1340

1341
                        bool end = false;
4,096✔
1342
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1343
                        {
12,288✔
1344
                                switch (this._reader.Code)
12,288✔
1345
                                {
1346
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1347
                                                readContentFormat(template);
4,096✔
1348
                                                break;
4,096✔
1349
                                        case 309:
1350
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1351
                                                break;
4,096✔
1352
                                        default:
1353
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
UNCOV
1354
                                                {
×
UNCOV
1355
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
UNCOV
1356
                                                }
×
1357
                                                break;
4,096✔
1358
                                }
1359

1360
                                if (end)
12,288✔
1361
                                {
4,096✔
1362
                                        break;
4,096✔
1363
                                }
1364

1365
                                this._reader.ReadNext();
8,192✔
1366
                        }
8,192✔
1367
                }
4,096✔
1368

1369
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1370
                {
9,600✔
1371
                        var format = template.Format;
9,600✔
1372
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1373

1374
                        this._reader.ReadNext();
9,600✔
1375

1376
                        bool end = false;
9,600✔
1377
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1378
                        {
124,800✔
1379
                                switch (this._reader.Code)
124,800✔
1380
                                {
1381
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1382
                                                break;
9,600✔
1383
                                        case 309:
1384
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1385
                                                break;
9,600✔
1386
                                        case 340:
1387
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1388
                                                break;
9,600✔
1389
                                        default:
1390
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
UNCOV
1391
                                                {
×
1392
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1393
                                                }
×
1394
                                                break;
96,000✔
1395
                                }
1396

1397
                                if (end)
124,800✔
1398
                                {
9,600✔
1399
                                        break;
9,600✔
1400
                                }
1401

1402
                                this._reader.ReadNext();
115,200✔
1403
                        }
115,200✔
1404
                }
9,600✔
1405

1406
                private void readFormattedTableColumn(TableEntity.Column column)
1407
                {
1,216✔
1408
                        this._reader.ReadNext();
1,216✔
1409

1410
                        bool end = false;
1,216✔
1411
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1412
                        {
3,648✔
1413
                                switch (this._reader.Code)
3,648!
1414
                                {
1415
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1416
                                                break;
1,216✔
1417
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1418
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1419
                                                break;
1,216✔
1420
                                        case 309:
1421
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1422
                                                break;
1,216✔
1423
                                        default:
UNCOV
1424
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
UNCOV
1425
                                                break;
×
1426
                                }
1427

1428
                                if (end)
3,648✔
1429
                                {
1,216✔
1430
                                        break;
1,216✔
1431
                                }
1432

1433
                                this._reader.ReadNext();
2,432✔
1434
                        }
2,432✔
1435
                }
1,216✔
1436

1437
                private void readStyleOverride(CadCellStyleTemplate template)
1438
                {
8,128✔
1439
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1440
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1441
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1442

1443
                        this._reader.ReadNext();
8,128✔
1444

1445
                        bool end = false;
8,128✔
1446
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1447
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1448
                        {
89,536✔
1449
                                switch (this._reader.Code)
89,536✔
1450
                                {
1451
                                        case 95:
1452
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1453
                                                break;
11,776✔
1454
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1455
                                                break;
256✔
1456
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1457
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1458
                                                break;
5,504✔
1459
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1460
                                                this.readCellMargin(template);
2,816✔
1461
                                                break;
2,816✔
1462
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1463
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1464
                                                this.readGridFormat(template, border);
11,776✔
1465
                                                break;
11,776✔
1466
                                        case 309:
1467
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1468
                                                break;
8,128✔
1469
                                        default:
1470
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
UNCOV
1471
                                                {
×
UNCOV
1472
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
UNCOV
1473
                                                }
×
1474
                                                break;
49,280✔
1475
                                }
1476

1477
                                if (end)
89,536✔
1478
                                {
8,128✔
1479
                                        break;
8,128✔
1480
                                }
1481

1482
                                this._reader.ReadNext();
81,408✔
1483
                        }
81,408✔
1484
                }
8,128✔
1485

1486
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1487
                {
11,776✔
1488
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1489

1490
                        this._reader.ReadNext();
11,776✔
1491

1492
                        bool end = false;
11,776✔
1493
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1494
                        {
105,984✔
1495
                                switch (this._reader.Code)
105,984✔
1496
                                {
1497
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1498
                                                break;
11,776✔
1499
                                        case 62:
1500
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1501
                                                break;
11,776✔
1502
                                        case 92:
1503
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1504
                                                break;
11,776✔
1505
                                        case 93:
1506
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1507
                                                break;
11,776✔
1508
                                        case 340:
1509
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1510
                                                break;
11,776✔
1511
                                        case 309:
1512
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1513
                                                break;
11,776✔
1514
                                        default:
1515
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
UNCOV
1516
                                                {
×
UNCOV
1517
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
UNCOV
1518
                                                }
×
1519
                                                break;
35,328✔
1520
                                }
1521

1522
                                if (end)
105,984✔
1523
                                {
11,776✔
1524
                                        break;
11,776✔
1525
                                }
1526

1527
                                this._reader.ReadNext();
94,208✔
1528
                        }
94,208✔
1529
                }
11,776✔
1530

1531
                private void readCellMargin(CadCellStyleTemplate template)
1532
                {
2,816✔
1533
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1534

1535
                        this._reader.ReadNext();
2,816✔
1536

1537
                        bool end = false;
2,816✔
1538
                        int i = 0;
2,816✔
1539
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1540
                        {
22,528✔
1541
                                switch (this._reader.Code)
22,528!
1542
                                {
1543
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1544
                                                break;
2,816✔
1545
                                        case 40:
1546
                                                switch (i)
16,896✔
1547
                                                {
1548
                                                        case 0:
1549
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1550
                                                                break;
2,816✔
1551
                                                        case 1:
1552
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1553
                                                                break;
2,816✔
1554
                                                        case 2:
1555
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1556
                                                                break;
2,816✔
1557
                                                        case 3:
1558
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1559
                                                                break;
2,816✔
1560
                                                        case 4:
1561
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1562
                                                                break;
2,816✔
1563
                                                        case 5:
1564
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1565
                                                                break;
2,816✔
1566
                                                }
1567

1568
                                                i++;
16,896✔
1569
                                                break;
16,896✔
1570
                                        case 309:
1571
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1572
                                                break;
2,816✔
1573
                                        default:
UNCOV
1574
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
UNCOV
1575
                                                break;
×
1576
                                }
1577

1578
                                if (end)
22,528✔
1579
                                {
2,816✔
1580
                                        break;
2,816✔
1581
                                }
1582

1583
                                this._reader.ReadNext();
19,712✔
1584
                        }
19,712✔
1585
                }
2,816✔
1586

1587
                private void readCustomData()
1588
                {
8,000✔
1589
                        this._reader.ReadNext();
8,000✔
1590

1591
                        int ndata = 0;
8,000✔
1592
                        bool end = false;
8,000✔
1593
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1594
                        {
74,304✔
1595
                                switch (this._reader.Code)
74,304✔
1596
                                {
1597
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1598
                                                break;
8,000✔
1599
                                        case 90:
1600
                                                ndata = this._reader.ValueAsInt;
8,128✔
1601
                                                break;
8,128✔
1602
                                        case 300:
1603
                                                //Name
1604
                                                break;
5,248✔
1605
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1606
                                                this.readDataMapValue();
5,248✔
1607
                                                break;
5,248✔
1608
                                        case 309:
1609
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1610
                                                break;
7,872✔
1611
                                        default:
1612
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1613
                                                break;
39,808✔
1614
                                }
1615

1616
                                if (end)
74,304✔
1617
                                {
7,872✔
1618
                                        break;
7,872✔
1619
                                }
1620

1621
                                this._reader.ReadNext();
66,432✔
1622
                        }
66,432✔
1623
                }
8,000✔
1624

1625
                private void readDataMapValue()
1626
                {
8,960✔
1627
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1628
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1629

1630
                        this._reader.ReadNext();
8,960✔
1631

1632
                        bool end = false;
8,960✔
1633
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1634
                        {
330,112✔
1635
                                switch (this._reader.Code)
330,112✔
1636
                                {
1637
                                        case 11:
1638
                                        case 21:
1639
                                        case 31:
1640
                                                //Value as point
1641
                                                break;
768✔
1642
                                        case 91:
1643
                                        case 92:
1644
                                                //Value as int
1645
                                                break;
38,912✔
1646
                                        case 140:
1647
                                                //Value as double
1648
                                                break;
13,248✔
1649
                                        case 310:
1650
                                                //Value as byte array
1651
                                                break;
256✔
1652
                                        case 304:
1653
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1654
                                                break;
8,832✔
1655
                                        default:
1656
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1657
                                                {
106,880✔
1658
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1659
                                                }
106,880✔
1660
                                                break;
268,096✔
1661
                                }
1662

1663
                                if (end)
330,112✔
1664
                                {
8,832✔
1665
                                        break;
8,832✔
1666
                                }
1667

1668
                                this._reader.ReadNext();
321,280✔
1669
                        }
321,280✔
1670
                }
8,960✔
1671

1672
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1673
                {
379,506✔
1674
                        switch (this._reader.Code)
379,506✔
1675
                        {
1676
                                // Undocumented codes
1677
                                case 176:
1678
                                case 177:
1679
                                case 420:
1680
                                        return true;
123,592✔
1681
                                default:
1682
                                        //Avoid noise while is not implemented
1683
                                        return true;
255,914✔
1684
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1685
                        }
1686
                }
379,506✔
1687

1688
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1689
                {
4,032✔
1690
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1691
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1692

1693
                        switch (this._reader.Code)
4,032✔
1694
                        {
1695
                                case 10:
1696
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1697
                                        return true;
384✔
1698
                                case 20:
1699
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1700
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1701
                                        return true;
384✔
1702
                                case 40:
1703
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
UNCOV
1704
                                        {
×
UNCOV
1705
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
UNCOV
1706
                                                tmp.HasFrontPlane = true;
×
UNCOV
1707
                                        }
×
1708

1709
                                        double[] array = new double[16]
384✔
1710
                                        {
384✔
1711
                                                0.0, 0.0, 0.0, 0.0,
384✔
1712
                                                0.0, 0.0, 0.0, 0.0,
384✔
1713
                                                0.0, 0.0, 0.0, 0.0,
384✔
1714
                                                0.0, 0.0, 0.0, 1.0
384✔
1715
                                        };
384✔
1716

1717
                                        for (int i = 0; i < 12; i++)
9,984✔
1718
                                        {
4,608✔
1719
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1720

1721
                                                if (i < 11)
4,608✔
1722
                                                {
4,224✔
1723
                                                        this._reader.ReadNext();
4,224✔
1724
                                                }
4,224✔
1725
                                        }
4,608✔
1726

1727
                                        if (tmp.InsertTransformRead)
384!
UNCOV
1728
                                        {
×
UNCOV
1729
                                                filter.InsertTransform = new Matrix4(array);
×
UNCOV
1730
                                                tmp.InsertTransformRead = true;
×
UNCOV
1731
                                        }
×
1732
                                        else
1733
                                        {
384✔
1734
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1735
                                        }
384✔
1736

1737
                                        return true;
384✔
1738
                                case 73:
1739
                                default:
1740
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1741
                        }
1742
                }
4,032✔
1743

1744
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1745
                {
3,529✔
1746
                        var tmp = template as CadMLineStyleTemplate;
3,529✔
1747
                        var mLineStyle = template.CadObject as MLineStyle;
3,529✔
1748

1749
                        switch (this._reader.Code)
3,529✔
1750
                        {
1751
                                case 6:
1752
                                        var t = tmp.ElementTemplates.LastOrDefault();
418✔
1753
                                        if (t == null)
418!
UNCOV
1754
                                        {
×
UNCOV
1755
                                                return true;
×
1756
                                        }
1757
                                        t.LineTypeName = this._reader.ValueAsString;
418✔
1758
                                        return true;
418✔
1759
                                case 49:
1760
                                        MLineStyle.Element element = new MLineStyle.Element();
418✔
1761
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
418✔
1762
                                        element.Offset = this._reader.ValueAsDouble;
418✔
1763

1764
                                        tmp.ElementTemplates.Add(elementTemplate);
418✔
1765
                                        mLineStyle.AddElement(element);
418✔
1766
                                        return true;
418✔
1767
                                default:
1768
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,693✔
1769
                        }
1770
                }
3,529✔
1771

1772
                private bool readTableStyle(CadTemplate template, DxfMap map)
1773
                {
17,845✔
1774
                        var tmp = template as CadTableStyleTemplate;
17,845✔
1775
                        var style = tmp.CadObject;
17,845✔
1776
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,845✔
1777

1778
                        switch (this._reader.Code)
17,845!
1779
                        {
1780
                                case 7:
1781
                                        tmp.CreateCurrentCellStyleTemplate();
591✔
1782
                                        tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
591✔
1783
                                        return true;
591✔
1784
                                case 94:
UNCOV
1785
                                        cellStyle.Alignment = this._reader.ValueAsInt;
×
UNCOV
1786
                                        return true;
×
1787
                                case 62:
1788
                                        cellStyle.Color = new Color(this._reader.ValueAsShort);
591✔
1789
                                        return true;
591✔
1790
                                case 63:
1791
                                        cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
591✔
1792
                                        return true;
591✔
1793
                                case 140:
1794
                                        cellStyle.TextHeight = this._reader.ValueAsDouble;
591✔
1795
                                        return true;
591✔
1796
                                case 170:
1797
                                        cellStyle.CellAlignment = (TableEntity.Cell.CellAlignmentType)this._reader.ValueAsShort;
591✔
1798
                                        return true;
591✔
1799
                                case 283:
1800
                                        cellStyle.IsFillColorOn = this._reader.ValueAsBool;
591✔
1801
                                        return true;
591✔
1802
                                case 90:
1803
                                        cellStyle.Type = (TableEntity.CellStyleType)this._reader.ValueAsShort;
399✔
1804
                                        return true;
399✔
1805
                                case 91:
1806
                                        cellStyle.StyleClass = (TableEntity.CellStyleClass)this._reader.ValueAsShort;
399✔
1807
                                        return true;
399✔
1808
                                case 1:
1809
                                        //Undocumented
1810
                                        return true;
399✔
1811
                                case 274:
1812
                                        cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1813
                                        return true;
591✔
1814
                                case 275:
1815
                                        cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1816
                                        return true;
591✔
1817
                                case 276:
1818
                                        cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1819
                                        return true;
591✔
1820
                                case 277:
1821
                                        cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1822
                                        return true;
591✔
1823
                                case 278:
1824
                                        cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1825
                                        return true;
591✔
1826
                                case 279:
1827
                                        cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1828
                                        return true;
591✔
1829
                                case 284:
1830
                                        cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1831
                                        return true;
591✔
1832
                                case 285:
1833
                                        cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1834
                                        return true;
591✔
1835
                                case 286:
1836
                                        cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1837
                                        return true;
591✔
1838
                                case 287:
1839
                                        cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1840
                                        return true;
591✔
1841
                                case 288:
1842
                                        cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1843
                                        return true;
591✔
1844
                                case 289:
1845
                                        cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1846
                                        return true;
591✔
1847
                                case 64:
1848
                                        cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1849
                                        return true;
591✔
1850
                                case 65:
1851
                                        cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1852
                                        return true;
591✔
1853
                                case 66:
1854
                                        cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1855
                                        return true;
591✔
1856
                                case 67:
1857
                                        cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1858
                                        return true;
591✔
1859
                                case 68:
1860
                                        cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1861
                                        return true;
591✔
1862
                                case 69:
1863
                                        cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1864
                                        return true;
591✔
1865
                                default:
1866
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,464✔
1867
                        }
1868
                }
17,845✔
1869

1870
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1871
                {
18,636✔
1872
                        var tmp = template as CadMLeaderStyleTemplate;
18,636✔
1873

1874
                        switch (this._reader.Code)
18,636✔
1875
                        {
1876
                                case 179:
1877
                                        return true;
212✔
1878
                                case 340:
1879
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
406✔
1880
                                        return true;
406✔
1881
                                case 342:
1882
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
406✔
1883
                                        return true;
406✔
1884
                                default:
1885
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,612✔
1886
                        }
1887
                }
18,636✔
1888

1889
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1890
                {
13,737✔
1891
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,737✔
1892

1893
                        switch (this._reader.Code)
13,737✔
1894
                        {
1895
                                case 1:
1896
                                        this._reader.ExpectedCode(70);
1,158✔
1897
                                        this._reader.ExpectedCode(140);
1,158✔
1898
                                        return true;
1,158✔
1899
                                default:
1900
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,579✔
1901
                        }
1902
                }
13,737✔
1903

1904
                private bool readBlockElement(CadTemplate template, DxfMap map)
1905
                {
5,249✔
1906
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,249✔
1907

1908
                        switch (this._reader.Code)
5,249✔
1909
                        {
1910
                                default:
1911
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,249✔
1912
                                        {
4,473✔
1913
                                                return this.readEvaluationExpression(template, map);
4,473✔
1914
                                        }
1915
                                        return true;
776✔
1916
                        }
1917
                }
5,249✔
1918

1919
                private bool readBlockAction(CadTemplate template, DxfMap map)
1920
                {
20✔
1921
                        CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
20✔
1922

1923
                        switch (this._reader.Code)
20✔
1924
                        {
1925
                                default:
1926
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
20✔
1927
                                        {
15✔
1928
                                                return this.readBlockElement(template, map);
15✔
1929
                                        }
1930
                                        return true;
5✔
1931
                        }
1932
                }
20✔
1933

1934
                private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
1935
                {
31✔
1936
                        CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
31✔
1937

1938
                        switch (this._reader.Code)
31✔
1939
                        {
1940
                                default:
1941
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
31✔
1942
                                        {
20✔
1943
                                                return this.readBlockAction(template, map);
20✔
1944
                                        }
1945
                                        return true;
11✔
1946
                        }
1947
                }
31✔
1948

1949
                private bool readBlockRotationAction(CadTemplate template, DxfMap map)
1950
                {
33✔
1951
                        CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
33✔
1952

1953
                        switch (this._reader.Code)
33✔
1954
                        {
1955
                                default:
1956
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
33✔
1957
                                        {
31✔
1958
                                                return this.readBlockActionBasePt(template, map);
31✔
1959
                                        }
1960
                                        return true;
2✔
1961
                        }
1962
                }
33✔
1963

1964
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1965
                {
3,291✔
1966
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,291✔
1967

1968
                        switch (this._reader.Code)
3,291✔
1969
                        {
1970
                                default:
1971
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,291✔
1972
                                        {
2,712✔
1973
                                                return this.readBlockElement(template, map);
2,712✔
1974
                                        }
1975
                                        return true;
579✔
1976
                        }
1977
                }
3,291✔
1978

1979
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1980
                {
4,246✔
1981
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1982

1983
                        switch (this._reader.Code)
4,246✔
1984
                        {
1985
                                default:
1986
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
1987
                                        {
3,281✔
1988
                                                return this.readBlockParameter(template, map);
3,281✔
1989
                                        }
1990
                                        return true;
965✔
1991
                        }
1992
                }
4,246✔
1993

1994
                private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
1995
                {
14✔
1996
                        var tmp = template as CadBlock2PtParameterTemplate;
14✔
1997

1998
                        switch (this._reader.Code)
14✔
1999
                        {
2000
                                //Stores always 4 entries using this code
2001
                                case 91:
2002
                                        return true;
4✔
2003
                                default:
2004
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
10!
2005
                                        {
10✔
2006
                                                return this.readBlockParameter(template, map);
10✔
2007
                                        }
UNCOV
2008
                                        return true;
×
2009
                        }
2010
                }
14✔
2011

2012
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
2013
                {
5,404✔
2014
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
2015

2016
                        switch (this._reader.Code)
5,404✔
2017
                        {
2018
                                case 92:
2019
                                        var stateCount = this._reader.ValueAsInt;
193✔
2020
                                        for (int i = 0; i < stateCount; i++)
1,930✔
2021
                                        {
772✔
2022
                                                this._reader.ReadNext();
772✔
2023
                                                tmp.StateTemplates.Add(this.readState());
772✔
2024
                                        }
772✔
2025
                                        return true;
193✔
2026
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
2027
                                        var entityCount = this._reader.ValueAsInt;
193✔
2028
                                        for (int i = 0; i < entityCount; i++)
780✔
2029
                                        {
197✔
2030
                                                this._reader.ReadNext();
197✔
2031
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
197✔
2032
                                        }
197✔
2033
                                        return true;
193✔
2034
                                default:
2035
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
2036
                                        {
4,246✔
2037
                                                return this.readBlock1PtParameter(template, map);
4,246✔
2038
                                        }
2039
                                        return true;
772✔
2040
                        }
2041
                }
5,404✔
2042

2043
                private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2044
                {
49✔
2045
                        var tmp = template as CadBlockRotationParameterTemplate;
49✔
2046

2047
                        switch (this._reader.Code)
49✔
2048
                        {
2049
                                default:
2050
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
49✔
2051
                                        {
14✔
2052
                                                return this.readBlock2PtParameter(template, map);
14✔
2053
                                        }
2054
                                        return true;
35✔
2055
                        }
2056
                }
49✔
2057

2058
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2059
                {
772✔
2060
                        var state = new BlockVisibilityParameter.State();
772✔
2061
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
2062

2063
                        List<int> expectedCodes = new List<int>();
772✔
2064
                        expectedCodes.Add(303);
772✔
2065
                        expectedCodes.Add(94);
772✔
2066
                        expectedCodes.Add(95);
772✔
2067

2068
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
2069
                        {
2,316✔
2070
                                expectedCodes.Remove(this._reader.Code);
2,316✔
2071

2072
                                switch (this._reader.Code)
2,316!
2073
                                {
2074
                                        case 303:
2075
                                                state.Name = this._reader.ValueAsString;
772✔
2076
                                                break;
772✔
2077
                                        case 94:
2078
                                                var count = this._reader.ValueAsInt;
772✔
2079
                                                for (int i = 0; i < count; i++)
2,720✔
2080
                                                {
588✔
2081
                                                        this._reader.ReadNext();
588✔
2082
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
2083
                                                }
588✔
2084
                                                break;
772✔
2085
                                        case 95:
2086
                                                count = this._reader.ValueAsInt;
772✔
2087
                                                for (int i = 0; i < count; i++)
6,152✔
2088
                                                {
2,304✔
2089
                                                        this._reader.ReadNext();
2,304✔
2090
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2091
                                                }
2,304✔
2092
                                                break;
772✔
2093
                                        default:
UNCOV
2094
                                                return template;
×
2095
                                }
2096

2097
                                if (!expectedCodes.Any())
2,316✔
2098
                                {
772✔
2099
                                        break;
772✔
2100
                                }
2101

2102
                                this._reader.ReadNext();
1,544✔
2103
                        }
1,544✔
2104

2105
                        return template;
772✔
2106
                }
772✔
2107

2108
                private bool readBlockGrip(CadTemplate template, DxfMap map)
2109
                {
3,880✔
2110
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,880✔
2111

2112
                        switch (this._reader.Code)
3,880✔
2113
                        {
2114
                                default:
2115
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,880✔
2116
                                        {
2,522✔
2117
                                                return this.readBlockElement(template, map);
2,522✔
2118
                                        }
2119
                                        return true;
1,358✔
2120
                        }
2121
                }
3,880✔
2122

2123
                private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
2124
                {
20✔
2125
                        CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
20✔
2126

2127
                        switch (this._reader.Code)
20✔
2128
                        {
2129
                                default:
2130
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
20!
2131
                                        {
20✔
2132
                                                return this.readBlockGrip(template, map);
20✔
2133
                                        }
UNCOV
2134
                                        return true;
×
2135
                        }
2136
                }
20✔
2137

2138
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
2139
                {
3,860✔
2140
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2141

2142
                        switch (this._reader.Code)
3,860✔
2143
                        {
2144
                                default:
2145
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2146
                                        {
3,860✔
2147
                                                return this.readBlockGrip(template, map);
3,860✔
2148
                                        }
UNCOV
2149
                                        return true;
×
2150
                        }
2151
                }
3,860✔
2152

2153
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2154
                {
1,590✔
2155
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,590✔
2156

2157
                        switch (this._reader.Code)
1,590✔
2158
                        {
2159
                                case 340:
2160
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
265✔
2161
                                        return true;
265✔
2162
                                default:
2163
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,325✔
2164
                        }
2165
                }
1,590✔
2166

2167
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2168
                {
11,580✔
2169
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,580✔
2170

2171
                        switch (this._reader.Code)
11,580✔
2172
                        {
2173
                                default:
2174
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,580✔
2175
                                        {
9,264✔
2176
                                                return this.readEvaluationExpression(template, map);
9,264✔
2177
                                        }
2178
                                        return true;
2,316✔
2179
                        }
2180
                }
11,580✔
2181

2182
                private bool readXRecord(CadTemplate template, DxfMap map)
2183
                {
113,272✔
2184
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,272✔
2185

2186
                        switch (this._reader.Code)
113,272✔
2187
                        {
2188
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,926✔
2189
                                        this.readXRecordEntries(tmp);
28,926✔
2190
                                        return true;
28,926✔
2191
                                default:
2192
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,346✔
2193
                        }
2194
                }
113,272✔
2195

2196
                private void readXRecordEntries(CadXRecordTemplate template)
2197
                {
28,926✔
2198
                        this._reader.ReadNext();
28,926✔
2199

2200
                        while (this._reader.DxfCode != DxfCode.Start)
2,409,286✔
2201
                        {
2,380,360✔
2202
                                switch (this._reader.GroupCodeValue)
2,380,360✔
2203
                                {
2204
                                        case GroupCodeValueType.Point3D:
2205
                                                var code = this._reader.Code;
2,901✔
2206
                                                var x = this._reader.ValueAsDouble;
2,901✔
2207
                                                this._reader.ReadNext();
2,901✔
2208
                                                var y = this._reader.ValueAsDouble;
2,901✔
2209
                                                this._reader.ReadNext();
2,901✔
2210
                                                var z = this._reader.ValueAsDouble;
2,901✔
2211
                                                XYZ pt = new XYZ(x, y, z);
2,901✔
2212
                                                template.CadObject.CreateEntry(code, pt);
2,901✔
2213
                                                break;
2,901✔
2214
                                        case GroupCodeValueType.Handle:
2215
                                        case GroupCodeValueType.ObjectId:
2216
                                        case GroupCodeValueType.ExtendedDataHandle:
2217
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,041✔
2218
                                                break;
12,041✔
2219
                                        default:
2220
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,418✔
2221
                                                break;
2,365,418✔
2222
                                }
2223

2224
                                this._reader.ReadNext();
2,380,360✔
2225
                        }
2,380,360✔
2226
                }
28,926✔
2227

2228
                private bool readBookColor(CadTemplate template, DxfMap map)
2229
                {
1,376✔
2230
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2231
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2232

2233
                        switch (this._reader.Code)
1,376✔
2234
                        {
2235
                                case 430:
2236
                                        color.Name = this._reader.ValueAsString;
160✔
2237
                                        return true;
160✔
2238
                                default:
2239
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2240
                        }
2241
                }
1,376✔
2242

2243
                private bool readDictionary(CadTemplate template, DxfMap map)
2244
                {
224,204✔
2245
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
224,204✔
2246
                        CadDictionary cadDictionary = tmp.CadObject;
224,204✔
2247

2248
                        switch (this._reader.Code)
224,204✔
2249
                        {
2250
                                case 280:
2251
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,069✔
2252
                                        return true;
15,069✔
2253
                                case 281:
2254
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,522✔
2255
                                        return true;
21,522✔
2256
                                case 3:
2257
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,371✔
2258
                                        return true;
57,371✔
2259
                                case 350: // Soft-owner ID/handle to entry object 
2260
                                case 360: // Hard-owner ID/handle to entry object
2261
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,371✔
2262
                                        return true;
57,371✔
2263
                                default:
2264
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,871✔
2265
                        }
2266
                }
224,204✔
2267

2268
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2269
                {
1,773✔
2270
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,773✔
2271

2272
                        switch (this._reader.Code)
1,773✔
2273
                        {
2274
                                case 340:
2275
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
197✔
2276
                                        return true;
197✔
2277
                                default:
2278
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,576!
2279
                                        {
1,576✔
2280
                                                return this.readDictionary(template, map);
1,576✔
2281
                                        }
UNCOV
2282
                                        return true;
×
2283
                        }
2284
                }
1,773✔
2285

2286
                private CadTemplate readSortentsTable()
2287
                {
576✔
2288
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2289
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2290

2291
                        //Jump the 0 marker
2292
                        this._reader.ReadNext();
576✔
2293

2294
                        this.readCommonObjectData(template);
576✔
2295

2296
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
576✔
2297

2298
                        //Jump the 100 marker
2299
                        this._reader.ReadNext();
576✔
2300

2301
                        (ulong?, ulong?) pair = (null, null);
576✔
2302

2303
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2304
                        {
3,648✔
2305
                                switch (this._reader.Code)
3,648!
2306
                                {
2307
                                        case 5:
2308
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2309
                                                break;
1,536✔
2310
                                        case 330:
2311
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2312
                                                break;
576✔
2313
                                        case 331:
2314
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2315
                                                break;
1,536✔
2316
                                        default:
UNCOV
2317
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
UNCOV
2318
                                                break;
×
2319
                                }
2320

2321
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2322
                                {
1,536✔
2323
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2324
                                        pair = (null, null);
1,536✔
2325
                                }
1,536✔
2326

2327
                                this._reader.ReadNext();
3,648✔
2328
                        }
3,648✔
2329

2330
                        return template;
576✔
2331
                }
576✔
2332
        }
2333
}
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