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

DomCR / ACadSharp / 18709888830

22 Oct 2025 08:18AM UTC coverage: 78.038% (+0.1%) from 77.923%
18709888830

Pull #831

github

web-flow
Merge 9e240c894 into f84cb1d2a
Pull Request #831: Table entity refactor

7165 of 9974 branches covered (71.84%)

Branch coverage included in aggregate %.

409 of 472 new or added lines in 13 files covered. (86.65%)

7 existing lines in 4 files now uncovered.

27036 of 33852 relevant lines covered (79.87%)

108431.63 hits per line

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

85.06
/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.Diagnostics;
9
using System.IO;
10
using System.Linq;
11
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
12
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
13

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

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

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

30
                        //Loop until the section ends
31
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
71,316✔
32
                        {
71,074✔
33
                                CadTemplate template = null;
71,074✔
34

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

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

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

50
                                if (template == null)
71,074✔
51
                                        continue;
242✔
52

53
                                //Add the object and the template to the builder
54
                                this._builder.AddTemplate(template);
70,832✔
55
                        }
70,832✔
56
                }
242✔
57

58
                private CadTemplate readObject()
59
                {
71,074✔
60
                        switch (this._reader.ValueAsString)
71,074!
61
                        {
62
                                case DxfFileToken.ObjectPlaceholder:
63
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
230✔
64
                                case DxfFileToken.ObjectDBColor:
65
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
228✔
66
                                case DxfFileToken.ObjectDictionary:
67
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
22,920✔
68
                                case DxfFileToken.ObjectDictionaryWithDefault:
69
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
230✔
70
                                case DxfFileToken.ObjectLayout:
71
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
942✔
72
                                case DxfFileToken.ObjectPlotSettings:
73
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
74
                                case DxfFileToken.ObjectEvalGraph:
75
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
532✔
76
                                case DxfFileToken.ObjectImageDefinition:
77
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
228✔
78
                                case DxfFileToken.ObjectDictionaryVar:
79
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
3,282✔
80
                                case DxfFileToken.ObjectPdfDefinition:
81
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
228✔
82
                                case DxfFileToken.ObjectSortEntsTable:
83
                                        return this.readSortentsTable();
684✔
84
                                case DxfFileToken.ObjectImageDefinitionReactor:
85
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
228✔
86
                                case DxfFileToken.ObjectProxyObject:
87
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
88
                                case DxfFileToken.ObjectRasterVariables:
89
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
228✔
90
                                case DxfFileToken.ObjectGroup:
91
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
456✔
92
                                case DxfFileToken.ObjectGeoData:
93
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
94
                                case DxfFileToken.ObjectScale:
95
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,794✔
96
                                case DxfFileToken.ObjectTableContent:
97
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
380✔
98
                                case DxfFileToken.ObjectVisualStyle:
99
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,520✔
100
                                case DxfFileToken.ObjectSpatialFilter:
101
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
228✔
102
                                case DxfFileToken.ObjectMLeaderStyle:
103
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
472✔
104
                                case DxfFileToken.ObjectXRecord:
105
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
18,632✔
106
                                default:
107
                                        DxfMap map = DxfMap.Create<CadObject>();
7,630✔
108
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
7,630✔
109
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
7,630✔
110
                                        {
7,388✔
111
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
7,388✔
112
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
7,388✔
113
                                        }
7,388✔
114
                                        else
115
                                        {
242✔
116
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
242✔
117
                                        }
242✔
118

119
                                        this._reader.ReadNext();
7,630✔
120

121
                                        do
122
                                        {
288,510✔
123
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
288,510✔
124
                                                {
28,452✔
125
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
28,452✔
126
                                                        if (isExtendedData)
28,452✔
127
                                                                continue;
48✔
128
                                                }
28,404✔
129

130
                                                this._reader.ReadNext();
288,462✔
131
                                        }
288,462✔
132
                                        while (this._reader.DxfCode != DxfCode.Start);
288,510✔
133

134
                                        return unknownEntityTemplate;
7,630✔
135
                        }
136
                }
71,074✔
137

138
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
139
                        where T : CadObject
140
                {
62,760✔
141
                        this._reader.ReadNext();
62,760✔
142

143
                        DxfMap map = DxfMap.Create<T>();
62,760✔
144

145
                        while (this._reader.DxfCode != DxfCode.Start)
963,453✔
146
                        {
900,693✔
147
                                if (!readObject(template, map))
900,693✔
148
                                {
304,057✔
149
                                        this.readCommonCodes(template, out bool isExtendedData, map);
304,057✔
150
                                        if (isExtendedData)
304,057✔
151
                                                continue;
6,069✔
152
                                }
297,988✔
153

154
                                if (this._reader.DxfCode != DxfCode.Start)
894,624✔
155
                                        this._reader.ReadNext();
875,080✔
156
                        }
894,624✔
157

158
                        return template;
62,760✔
159
                }
62,760✔
160

161
                private bool readProxyObject(CadTemplate template, DxfMap map)
162
                {
×
163
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
164

165
                        switch (this._reader.Code)
×
166
                        {
167
                                case 90:
168
                                case 94:
169
                                //Undocumented
170
                                case 97:
171
                                case 71:
172
                                        return true;
×
173
                                case 95:
174
                                        int format = this._reader.ValueAsInt;
×
175
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
176
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
177
                                        return true;
×
178
                                case 91:
179
                                        var classId = this._reader.ValueAsShort;
×
180
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
181
                                        {
×
182
                                                proxy.DxfClass = dxfClass;
×
183
                                        }
×
184
                                        return true;
×
185
                                case 161:
186
                                        return true;
×
187
                                case 162:
188
                                        return true;
×
189
                                case 310:
190
                                        if (proxy.BinaryData == null)
×
191
                                        {
×
192
                                                proxy.BinaryData = new MemoryStream();
×
193
                                        }
×
194
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
195
                                        return true;
×
196
                                case 311:
197
                                        if (proxy.Data == null)
×
198
                                        {
×
199
                                                proxy.Data = new MemoryStream();
×
200
                                        }
×
201
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
202
                                        return true;
×
203
                                default:
204
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
205
                        }
206
                }
×
207

208
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
209
                {
27,438✔
210
                        switch (this._reader.Code)
27,438✔
211
                        {
212
                                default:
213
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,438✔
214
                        }
215
                }
27,438✔
216

217
                private bool readPlotSettings(CadTemplate template, DxfMap map)
218
                {
29,830✔
219
                        switch (this._reader.Code)
29,830✔
220
                        {
221
                                default:
222
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
29,830✔
223
                        }
224
                }
29,830✔
225

226
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
227
                {
3,648✔
228
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,648✔
229
                        EvaluationGraph evGraph = tmp.CadObject;
3,648✔
230

231
                        switch (this._reader.Code)
3,648✔
232
                        {
233
                                case 91:
234
                                        while (this._reader.Code == 91)
3,572✔
235
                                        {
3,040✔
236
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
3,040✔
237
                                                EvaluationGraph.Node node = nodeTemplate.Node;
3,040✔
238

239
                                                node.Index = this._reader.ValueAsInt;
3,040✔
240

241
                                                this._reader.ExpectedCode(93);
3,040✔
242
                                                node.Flags = this._reader.ValueAsInt;
3,040✔
243

244
                                                this._reader.ExpectedCode(95);
3,040✔
245
                                                node.NextNodeIndex = this._reader.ValueAsInt;
3,040✔
246

247
                                                this._reader.ExpectedCode(360);
3,040✔
248
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
3,040✔
249

250
                                                this._reader.ExpectedCode(92);
3,040✔
251
                                                node.Data1 = this._reader.ValueAsInt;
3,040✔
252
                                                this._reader.ExpectedCode(92);
3,040✔
253
                                                node.Data2 = this._reader.ValueAsInt;
3,040✔
254
                                                this._reader.ExpectedCode(92);
3,040✔
255
                                                node.Data3 = this._reader.ValueAsInt;
3,040✔
256
                                                this._reader.ExpectedCode(92);
3,040✔
257
                                                node.Data4 = this._reader.ValueAsInt;
3,040✔
258

259
                                                this._reader.ReadNext();
3,040✔
260

261
                                                tmp.NodeTemplates.Add(nodeTemplate);
3,040✔
262
                                        }
3,040✔
263

264
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
532✔
265
                                case 92:
266
                                        //Edges
267
                                        while (this._reader.Code == 92)
2,508✔
268
                                        {
2,280✔
269
                                                this._reader.ExpectedCode(93);
2,280✔
270
                                                this._reader.ExpectedCode(94);
2,280✔
271
                                                this._reader.ExpectedCode(91);
2,280✔
272
                                                this._reader.ExpectedCode(91);
2,280✔
273
                                                this._reader.ExpectedCode(92);
2,280✔
274
                                                this._reader.ExpectedCode(92);
2,280✔
275
                                                this._reader.ExpectedCode(92);
2,280✔
276
                                                this._reader.ExpectedCode(92);
2,280✔
277
                                                this._reader.ExpectedCode(92);
2,280✔
278

279
                                                this._reader.ReadNext();
2,280✔
280
                                        }
2,280✔
281

282
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
228✔
283
                                default:
284
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,888✔
285
                        }
286
                }
3,648✔
287

288
                private bool readLayout(CadTemplate template, DxfMap map)
289
                {
60,712✔
290
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
60,712✔
291

292
                        switch (this._reader.Code)
60,712✔
293
                        {
294
                                case 330:
295
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,884✔
296
                                        return true;
1,884✔
297
                                case 331:
298
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
914✔
299
                                        return true;
914✔
300
                                default:
301
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
57,914✔
302
                                        {
29,830✔
303
                                                return this.readPlotSettings(template, map);
29,830✔
304
                                        }
305
                                        return true;
28,084✔
306
                        }
307
                }
60,712✔
308

309
                private bool readGroup(CadTemplate template, DxfMap map)
310
                {
5,928✔
311
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,928✔
312

313
                        switch (this._reader.Code)
5,928✔
314
                        {
315
                                case 70:
316
                                        return true;
456✔
317
                                case 340:
318
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,736✔
319
                                        return true;
2,736✔
320
                                default:
321
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,736✔
322
                        }
323
                }
5,928✔
324

325
                private bool readGeoData(CadTemplate template, DxfMap map)
326
                {
102✔
327
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
328

329
                        switch (this._reader.Code)
102✔
330
                        {
331
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
332
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
333
                                                tmp.CadObject.ReferencePoint.X,
1✔
334
                                                this._reader.ValueAsDouble,
1✔
335
                                                tmp.CadObject.ReferencePoint.Z
1✔
336
                                                );
1✔
337
                                        return true;
1✔
338
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
339
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
340
                                                this._reader.ValueAsDouble,
1✔
341
                                                tmp.CadObject.ReferencePoint.Y,
1✔
342
                                                tmp.CadObject.ReferencePoint.Z
1✔
343
                                                );
1✔
344
                                        return true;
1✔
345
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
346
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
347
                                                tmp.CadObject.ReferencePoint.X,
1✔
348
                                                tmp.CadObject.ReferencePoint.Y,
1✔
349
                                                this._reader.ValueAsDouble
1✔
350
                                                );
1✔
351
                                        return true;
1✔
352
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
353
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
354
                                        return true;
1✔
355
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
356
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
357
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
358
                                        return true;
1✔
359
                                // Number of Geo-Mesh points
360
                                case 93:
361
                                        var npts = this._reader.ValueAsInt;
3✔
362
                                        for (int i = 0; i < npts; i++)
54✔
363
                                        {
24✔
364
                                                this._reader.ReadNext();
24✔
365
                                                double sourceX = this._reader.ValueAsDouble;
24✔
366
                                                this._reader.ReadNext();
24✔
367
                                                double sourceY = this._reader.ValueAsDouble;
24✔
368

369
                                                this._reader.ReadNext();
24✔
370
                                                double destX = this._reader.ValueAsDouble;
24✔
371
                                                this._reader.ReadNext();
24✔
372
                                                double destY = this._reader.ValueAsDouble;
24✔
373

374
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
375
                                                {
24✔
376
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
377
                                                        Destination = new CSMath.XY(destX, destY)
24✔
378
                                                });
24✔
379
                                        }
24✔
380
                                        return true;
3✔
381
                                // Number of Geo-Mesh points
382
                                case 96:
383
                                        var nfaces = this._reader.ValueAsInt;
2✔
384
                                        for (int i = 0; i < nfaces; i++)
4!
385
                                        {
×
386
                                                this._reader.ReadNext();
×
387
                                                Debug.Assert(this._reader.Code == 97);
×
388
                                                int index1 = this._reader.ValueAsInt;
×
389
                                                this._reader.ReadNext();
×
390
                                                Debug.Assert(this._reader.Code == 98);
×
391
                                                int index2 = this._reader.ValueAsInt;
×
392
                                                this._reader.ReadNext();
×
393
                                                Debug.Assert(this._reader.Code == 99);
×
394
                                                int index3 = this._reader.ValueAsInt;
×
395

396
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
397
                                                {
×
398
                                                        Index1 = index1,
×
399
                                                        Index2 = index2,
×
400
                                                        Index3 = index3
×
401
                                                });
×
402
                                        }
×
403
                                        return true;
2✔
404
                                case 303:
405
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
406
                                        return true;
13✔
407
                                //Obsolete codes for version GeoDataVersion.R2009
408
                                case 3:
409
                                case 4:
410
                                case 14:
411
                                case 24:
412
                                case 15:
413
                                case 25:
414
                                case 43:
415
                                case 44:
416
                                case 45:
417
                                case 94:
418
                                case 293:
419
                                case 16:
420
                                case 26:
421
                                case 17:
422
                                case 27:
423
                                case 54:
424
                                case 140:
425
                                case 304:
426
                                case 292:
427
                                        return true;
19✔
428
                                default:
429
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
430
                        }
431
                }
102✔
432

433
                private bool readScale(CadTemplate template, DxfMap map)
434
                {
69,942✔
435
                        switch (this._reader.Code)
69,942✔
436
                        {
437
                                // Undocumented codes
438
                                case 70:
439
                                        //Always 0
440
                                        return true;
7,794✔
441
                                default:
442
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
62,148✔
443
                        }
444
                }
69,942✔
445

446
                private bool readLinkedData(CadTemplate template, DxfMap map)
447
                {
2,280✔
448
                        switch (this._reader.Code)
2,280✔
449
                        {
450
                                default:
451
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.LinkedData]);
2,280✔
452
                        }
453
                }
2,280✔
454

455
                private bool readTableContent(CadTemplate template, DxfMap map)
456
                {
4,864✔
457
                        switch (this._reader.Code)
4,864✔
458
                        {
459
                                case 90:
460
                                        //Column count
461
                                        return true;
380✔
462
                                case 91:
463
                                        //Row count
464
                                        return true;
380✔
465
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,824✔
466
                                        //Read Column
467
                                        this.readTableColumn();
1,444✔
468
                                        return true;
1,444✔
469
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
380✔
470
                                        //Read Row
471
                                        this.readTableRow();
380✔
472
                                        return true;
380✔
473
                                default:
474
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.TableLinkedTableData]))
2,280!
475
                                        {
2,280✔
476
                                                return this.readLinkedData(template, map);
2,280✔
477
                                        }
NEW
478
                                        return true;
×
479
                        }
480
                }
4,864✔
481

482
                private TableEntity.Column readTableColumn()
483
                {
1,444✔
484
                        this._reader.ReadNext();
1,444✔
485

486
                        TableEntity.Column column = new TableEntity.Column();
1,444✔
487

488
                        bool end = false;
1,444✔
489
                        while (this._reader.DxfCode != DxfCode.Start)
4,332!
490
                        {
4,332✔
491
                                switch (this._reader.Code)
4,332!
492
                                {
493
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,332✔
494
                                                this.readLinkedTableColumn(column);
1,444✔
495
                                                break;
1,444✔
496
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,888✔
497
                                                this.readFormattedTableColumn(column);
1,444✔
498
                                                break;
1,444✔
499
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,444!
500
                                                this.readTableColumn(column);
1,444✔
501
                                                end = true;
1,444✔
502
                                                break;
1,444✔
503
                                        default:
NEW
504
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
505
                                                break;
×
506
                                }
507

508
                                if (end)
4,332✔
509
                                {
1,444✔
510
                                        return column;
1,444✔
511
                                }
512

513
                                this._reader.ReadNext();
2,888✔
514
                        }
2,888✔
515

NEW
516
                        return column;
×
517
                }
1,444✔
518

519
                private TableEntity.Row readTableRow()
520
                {
380✔
521
                        this._reader.ReadNext();
380✔
522

523
                        TableEntity.Row row = new TableEntity.Row();
380✔
524

525
                        bool end = false;
380✔
526
                        while (this._reader.DxfCode != DxfCode.Start)
12,920✔
527
                        {
12,540✔
528
                                switch (this._reader.Code)
12,540✔
529
                                {
530
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
531
                                                this.readLinkedTableRow(row);
456✔
532
                                                break;
456✔
533
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
1,976✔
534
                                        //break;
535
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
1,976✔
536
                                        //end = true;
537
                                        //break;
538
                                        default:
539
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
12,084✔
540
                                                break;
12,084✔
541
                                }
542

543
                                if (end)
12,540!
NEW
544
                                {
×
NEW
545
                                        return row;
×
546
                                }
547

548
                                this._reader.ReadNext();
12,540✔
549
                        }
12,540✔
550

551
                        return row;
380✔
552
                }
380✔
553

554
                private void readTableColumn(TableEntity.Column column)
555
                {
1,444✔
556
                        this._reader.ReadNext();
1,444✔
557

558
                        bool end = false;
1,444✔
559
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
560
                        {
4,332✔
561
                                switch (this._reader.Code)
4,332!
562
                                {
NEW
563
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
564
                                                break;
×
565
                                        case 1:
NEW
566
                                                end = true;
×
NEW
567
                                                break;
×
568
                                        case 40:
569
                                                column.Width = this._reader.ValueAsDouble;
1,444✔
570
                                                break;
1,444✔
571
                                        case 90:
572
                                                //StyleId
573
                                                break;
1,444✔
574
                                        case 309:
575
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,444✔
576
                                                break;
1,444✔
577
                                        default:
NEW
578
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
579
                                                break;
×
580
                                }
581

582
                                if (end)
4,332✔
583
                                {
1,444✔
584
                                        break;
1,444✔
585
                                }
586

587
                                this._reader.ReadNext();
2,888✔
588
                        }
2,888✔
589
                }
1,444✔
590

591
                private void readLinkedTableColumn(TableEntity.Column column)
592
                {
1,444✔
593
                        this._reader.ReadNext();
1,444✔
594

595
                        bool end = false;
1,444✔
596
                        while (this._reader.DxfCode != DxfCode.Start)
5,776✔
597
                        {
5,776✔
598
                                switch (this._reader.Code)
5,776!
599
                                {
NEW
600
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
NEW
601
                                                break;
×
602
                                        case 1:
NEW
603
                                                end = true;
×
NEW
604
                                                break;
×
605
                                        case 91:
606
                                                column.CustomData = this._reader.ValueAsInt;
1,444✔
607
                                                break;
1,444✔
608
                                        case 300:
609
                                                column.Name = this._reader.ValueAsString;
1,444✔
610
                                                break;
1,444✔
611
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,444!
612
                                                this.readCustomData();
1,444✔
613
                                                break;
1,444✔
614
                                        case 309:
615
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
616
                                                break;
1,444✔
617
                                        default:
NEW
618
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
NEW
619
                                                break;
×
620
                                }
621

622
                                if (end)
5,776✔
623
                                {
1,444✔
624
                                        break;
1,444✔
625
                                }
626

627
                                this._reader.ReadNext();
4,332✔
628
                        }
4,332✔
629
                }
1,444✔
630

631
                private void readLinkedTableRow(TableEntity.Row column)
632
                {
456✔
633
                        this._reader.ReadNext();
456✔
634

635
                        bool end = false;
456✔
636
                        while (this._reader.DxfCode != DxfCode.Start)
5,472✔
637
                        {
5,016✔
638
                                switch (this._reader.Code)
5,016!
639
                                {
NEW
640
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
NEW
641
                                                break;
×
642
                                        case 1:
NEW
643
                                                end = true;
×
NEW
644
                                                break;
×
645
                                        case 90:
646
                                                column.CustomData = this._reader.ValueAsInt;
456✔
647
                                                break;
456✔
648
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
456✔
649
                                                this.readCell();
456✔
650
                                                break;
456✔
NEW
651
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
×
NEW
652
                                                this.readCustomData();
×
NEW
653
                                                break;
×
654
                                        case 309:
NEW
655
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
×
NEW
656
                                                break;
×
657
                                        default:
658
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
4,104✔
659
                                                break;
4,104✔
660
                                }
661

662
                                if (end)
5,016!
NEW
663
                                {
×
NEW
664
                                        break;
×
665
                                }
666

667
                                this._reader.ReadNext();
5,016✔
668
                        }
5,016✔
669
                }
456✔
670

671
                private TableEntity.Cell readCell()
672
                {
456✔
673
                        this._reader.ReadNext();
456✔
674

675
                        TableEntity.Cell cell = new TableEntity.Cell();
456✔
676

677
                        bool end = false;
456✔
678
                        while (this._reader.DxfCode != DxfCode.Start)
96,900✔
679
                        {
96,444✔
680
                                switch (this._reader.Code)
96,444!
681
                                {
682
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
456✔
683
                                                this.readLinkedTableCell(cell);
456✔
684
                                                break;
456✔
685
                                        case 309:
NEW
686
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
×
NEW
687
                                                break;
×
688
                                        default:
689
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
95,988✔
690
                                                break;
95,988✔
691
                                }
692

693
                                if (end)
96,444!
NEW
694
                                {
×
NEW
695
                                        return cell;
×
696
                                }
697

698
                                this._reader.ReadNext();
96,444✔
699
                        }
96,444✔
700

701
                        return cell;
456✔
702
                }
456✔
703

704
                private void readLinkedTableCell(TableEntity.Cell cell)
705
                {
456✔
706
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
456✔
707

708
                        this._reader.ReadNext();
456✔
709

710
                        bool end = false;
456✔
711
                        while (this._reader.DxfCode != DxfCode.Start)
487,616✔
712
                        {
487,160✔
713
                                switch (this._reader.Code)
487,160✔
714
                                {
715
                                        case 95:
716
                                                //BL 95 Number of cell contents
717
                                                break;
20,216✔
718
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
12,768✔
719
                                                this.readCustomData();
8,056✔
720
                                                break;
8,056✔
721
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
18,544✔
722
                                                this.readLinkedTableCellContent();
4,560✔
723
                                                break;
4,560✔
724
                                        default:
725
                                                if (!this.tryAssignCurrentValue(cell, map))
454,328✔
726
                                                {
292,448✔
727
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} method.", NotificationType.None);
292,448✔
728
                                                }
292,448✔
729
                                                break;
454,328✔
730
                                }
731

732
                                if (end)
487,160!
NEW
733
                                {
×
NEW
734
                                        break;
×
735
                                }
736

737
                                this._reader.ReadNext();
487,160✔
738
                        }
487,160✔
739
                }
456✔
740

741
                private void readLinkedTableCellContent()
742
                {
4,560✔
743
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,560✔
744
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,560✔
745

746
                        this._reader.ReadNext();
4,560✔
747

748
                        bool end = false;
4,560✔
749
                        while (this._reader.DxfCode != DxfCode.Start)
14,592✔
750
                        {
14,592✔
751
                                switch (this._reader.Code)
14,592✔
752
                                {
753
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,728✔
754
                                                readCellContent();
4,864✔
755
                                                break;
4,864✔
756
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,864✔
757
                                                readFormattedCellContent();
4,864✔
758
                                                break;
4,864✔
759
                                        case 309:
760
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
4,560✔
761
                                                break;
4,560✔
762
                                        default:
763
                                                if (!this.tryAssignCurrentValue(content, map))
304✔
764
                                                {
304✔
765
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} method.", NotificationType.None);
304✔
766
                                                }
304✔
767
                                                break;
304✔
768
                                }
769

770
                                if (end)
14,592✔
771
                                {
4,560✔
772
                                        break;
4,560✔
773
                                }
774

775
                                this._reader.ReadNext();
10,032✔
776
                        }
10,032✔
777
                }
4,560✔
778

779
                private void readCellContent()
780
                {
4,864✔
781
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,864✔
782
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,864✔
783

784
                        this._reader.ReadNext();
4,864✔
785

786
                        bool end = false;
4,864✔
787
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
788
                        {
19,456✔
789
                                switch (this._reader.Code)
19,456✔
790
                                {
791
                                        case 91:
792
                                                break;
4,864✔
793
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
4,408✔
794
                                                this.readDataMapValue();
4,408✔
795
                                                break;
4,408✔
796
                                        case 309:
797
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
798
                                                break;
4,864✔
799
                                        default:
800
                                                if (!this.tryAssignCurrentValue(content, map))
5,320✔
801
                                                {
456✔
802
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} method.", NotificationType.None);
456✔
803
                                                }
456✔
804
                                                break;
5,320✔
805
                                }
806

807
                                if (end)
19,456✔
808
                                {
4,864✔
809
                                        break;
4,864✔
810
                                }
811

812
                                this._reader.ReadNext();
14,592✔
813
                        }
14,592✔
814
                }
4,864✔
815

816
                private void readFormattedCellContent()
817
                {
4,864✔
818
                        TableEntity.ContentFormat format = new();
4,864✔
819
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,864✔
820
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,864✔
821

822
                        this._reader.ReadNext();
4,864✔
823

824
                        bool end = false;
4,864✔
825
                        while (this._reader.DxfCode != DxfCode.Start)
14,592✔
826
                        {
14,592✔
827
                                switch (this._reader.Code)
14,592✔
828
                                {
829
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
830
                                                readContentFormat(template);
4,864✔
831
                                                break;
4,864✔
832
                                        case 309:
833
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
834
                                                break;
4,864✔
835
                                        default:
836
                                                if (!this.tryAssignCurrentValue(format, map))
4,864!
NEW
837
                                                {
×
NEW
838
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
NEW
839
                                                }
×
840
                                                break;
4,864✔
841
                                }
842

843
                                if (end)
14,592✔
844
                                {
4,864✔
845
                                        break;
4,864✔
846
                                }
847

848
                                this._reader.ReadNext();
9,728✔
849
                        }
9,728✔
850
                }
4,864✔
851

852
                private void readContentFormat(CadTableCellContentFormatTemplate template)
853
                {
4,864✔
854
                        var format = template.Format;
4,864✔
855
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,864✔
856

857
                        this._reader.ReadNext();
4,864✔
858

859
                        bool end = false;
4,864✔
860
                        while (this._reader.DxfCode != DxfCode.Start)
63,232✔
861
                        {
63,232✔
862
                                switch (this._reader.Code)
63,232✔
863
                                {
864
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,864✔
865
                                                break;
4,864✔
866
                                        case 309:
867
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
868
                                                break;
4,864✔
869
                                        case 340:
870
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
4,864✔
871
                                                break;
4,864✔
872
                                        default:
873
                                                if (!this.tryAssignCurrentValue(format, map))
48,640!
NEW
874
                                                {
×
NEW
875
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
NEW
876
                                                }
×
877
                                                break;
48,640✔
878
                                }
879

880
                                if (end)
63,232✔
881
                                {
4,864✔
882
                                        break;
4,864✔
883
                                }
884

885
                                this._reader.ReadNext();
58,368✔
886
                        }
58,368✔
887
                }
4,864✔
888

889
                private void readFormattedTableColumn(TableEntity.Column column)
890
                {
1,444✔
891
                        this._reader.ReadNext();
1,444✔
892

893
                        bool end = false;
1,444✔
894
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
895
                        {
4,332✔
896
                                switch (this._reader.Code)
4,332!
897
                                {
898
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,444!
899
                                                break;
1,444✔
900
                                        case 300:
NEW
901
                                                end = true;
×
NEW
902
                                                break;
×
903
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,444!
904
                                                this.readStyleOverride(column.StyleOverride);
1,444✔
905
                                                break;
1,444✔
906
                                        case 309:
907
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
908
                                                break;
1,444✔
909
                                        default:
NEW
910
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
NEW
911
                                                break;
×
912
                                }
913

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

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

923
                private void readStyleOverride(TableEntity.CellStyle style)
924
                {
1,444✔
925
                        this._reader.ReadNext();
1,444✔
926

927
                        bool end = false;
1,444✔
928
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
929
                        {
4,332✔
930
                                switch (this._reader.Code)
4,332!
931
                                {
NEW
932
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
933
                                                break;
×
934
                                        case 1:
NEW
935
                                                end = true;
×
NEW
936
                                                break;
×
937
                                        case 90:
938
                                                style.Type = (TableEntity.CellStyleTypeType)this._reader.ValueAsInt;
1,444✔
939
                                                break;
1,444✔
940
                                        case 170:
941
                                                //Has data
942
                                                break;
1,444✔
943
                                        case 309:
944
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
1,444✔
945
                                                break;
1,444✔
946
                                        default:
NEW
947
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
NEW
948
                                                break;
×
949
                                }
950

951
                                if (end)
4,332✔
952
                                {
1,444✔
953
                                        break;
1,444✔
954
                                }
955

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

960
                private void readCustomData()
961
                {
9,500✔
962
                        this._reader.ReadNext();
9,500✔
963

964
                        int ndata = 0;
9,500✔
965
                        bool end = false;
9,500✔
966
                        while (this._reader.DxfCode != DxfCode.Start)
88,388✔
967
                        {
88,236✔
968
                                switch (this._reader.Code)
88,236✔
969
                                {
970
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,500!
971
                                                break;
9,500✔
972
                                        case 1:
NEW
973
                                                end = true;
×
NEW
974
                                                break;
×
975
                                        case 90:
976
                                                ndata = this._reader.ValueAsInt;
9,652✔
977
                                                break;
9,652✔
978
                                        case 300:
979
                                                //Name
980
                                                break;
6,232✔
981
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
6,232✔
982
                                                this.readDataMapValue();
6,232✔
983
                                                break;
6,232✔
984
                                        case 309:
985
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
9,348✔
986
                                                break;
9,348✔
987
                                        default:
988
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
47,272✔
989
                                                break;
47,272✔
990
                                }
991

992
                                if (end)
88,236✔
993
                                {
9,348✔
994
                                        break;
9,348✔
995
                                }
996

997
                                this._reader.ReadNext();
78,888✔
998
                        }
78,888✔
999
                }
9,500✔
1000

1001
                private void readDataMapValue()
1002
                {
10,640✔
1003
                        TableEntity.CellValue value = new TableEntity.CellValue();
10,640✔
1004
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
10,640✔
1005

1006
                        this._reader.ReadNext();
10,640✔
1007

1008
                        bool end = false;
10,640✔
1009
                        while (this._reader.DxfCode != DxfCode.Start)
392,160✔
1010
                        {
392,008✔
1011
                                switch (this._reader.Code)
392,008✔
1012
                                {
1013
                                        case 140:
1014
                                                break;
15,732✔
1015
                                        case 304:
1016
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1017
                                                break;
10,488✔
1018
                                        default:
1019
                                                if (!this.tryAssignCurrentValue(value, map))
365,788✔
1020
                                                {
174,344✔
1021
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
174,344✔
1022
                                                }
174,344✔
1023
                                                break;
365,788✔
1024
                                }
1025

1026
                                if (end)
392,008✔
1027
                                {
10,488✔
1028
                                        break;
10,488✔
1029
                                }
1030

1031
                                this._reader.ReadNext();
381,520✔
1032
                        }
381,520✔
1033
                }
10,640✔
1034

1035
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1036
                {
411,192✔
1037
                        switch (this._reader.Code)
411,192✔
1038
                        {
1039
                                // Undocumented codes
1040
                                case 176:
1041
                                case 177:
1042
                                case 420:
1043
                                        return true;
141,178✔
1044
                                default:
1045
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
270,014✔
1046
                        }
1047
                }
411,192✔
1048

1049
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1050
                {
4,788✔
1051
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,788✔
1052
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,788✔
1053

1054
                        switch (this._reader.Code)
4,788✔
1055
                        {
1056
                                case 10:
1057
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
456✔
1058
                                        return true;
456✔
1059
                                case 20:
1060
                                        var pt = filter.BoundaryPoints.LastOrDefault();
456✔
1061
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
456✔
1062
                                        return true;
456✔
1063
                                case 40:
1064
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
456!
1065
                                        {
×
1066
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1067
                                                tmp.HasFrontPlane = true;
×
1068
                                        }
×
1069

1070
                                        double[] array = new double[16]
456✔
1071
                                        {
456✔
1072
                                                0.0, 0.0, 0.0, 0.0,
456✔
1073
                                                0.0, 0.0, 0.0, 0.0,
456✔
1074
                                                0.0, 0.0, 0.0, 0.0,
456✔
1075
                                                0.0, 0.0, 0.0, 1.0
456✔
1076
                                        };
456✔
1077

1078
                                        for (int i = 0; i < 12; i++)
11,856✔
1079
                                        {
5,472✔
1080
                                                array[i] = this._reader.ValueAsDouble;
5,472✔
1081

1082
                                                if (i < 11)
5,472✔
1083
                                                {
5,016✔
1084
                                                        this._reader.ReadNext();
5,016✔
1085
                                                }
5,016✔
1086
                                        }
5,472✔
1087

1088
                                        if (tmp.InsertTransformRead)
456!
1089
                                        {
×
1090
                                                filter.InsertTransform = new Matrix4(array);
×
1091
                                                tmp.InsertTransformRead = true;
×
1092
                                        }
×
1093
                                        else
1094
                                        {
456✔
1095
                                                filter.InverseInsertTransform = new Matrix4(array);
456✔
1096
                                        }
456✔
1097

1098
                                        return true;
456✔
1099
                                case 73:
1100
                                default:
1101
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,420✔
1102
                        }
1103
                }
4,788✔
1104

1105
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1106
                {
21,648✔
1107
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1108

1109
                        switch (this._reader.Code)
21,648✔
1110
                        {
1111
                                case 179:
1112
                                        return true;
242✔
1113
                                case 340:
1114
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1115
                                        return true;
472✔
1116
                                case 342:
1117
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1118
                                        return true;
472✔
1119
                                default:
1120
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1121
                        }
1122
                }
21,648✔
1123

1124
                private bool readXRecord(CadTemplate template, DxfMap map)
1125
                {
71,640✔
1126
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
71,640✔
1127

1128
                        switch (this._reader.Code)
71,640✔
1129
                        {
1130
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
18,632✔
1131
                                        this.readXRecordEntries(tmp);
18,632✔
1132
                                        return true;
18,632✔
1133
                                default:
1134
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
53,008✔
1135
                        }
1136
                }
71,640✔
1137

1138
                private void readXRecordEntries(CadXRecordTemplate template)
1139
                {
18,632✔
1140
                        this._reader.ReadNext();
18,632✔
1141

1142
                        while (this._reader.DxfCode != DxfCode.Start)
993,532✔
1143
                        {
974,900✔
1144
                                switch (this._reader.GroupCodeValue)
974,900!
1145
                                {
1146
                                        case GroupCodeValueType.Handle:
1147
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1148
                                                break;
×
1149
                                        default:
1150
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
974,900✔
1151
                                                break;
974,900✔
1152
                                }
1153

1154
                                this._reader.ReadNext();
974,900✔
1155
                        }
974,900✔
1156
                }
18,632✔
1157

1158
                private bool readBookColor(CadTemplate template, DxfMap map)
1159
                {
1,634✔
1160
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1161
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1162

1163
                        switch (this._reader.Code)
1,634✔
1164
                        {
1165
                                case 430:
1166
                                        color.Name = this._reader.ValueAsString;
190✔
1167
                                        return true;
190✔
1168
                                default:
1169
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1170
                        }
1171
                }
1,634✔
1172

1173
                private bool readDictionary(CadTemplate template, DxfMap map)
1174
                {
217,155✔
1175
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
217,155✔
1176
                        CadDictionary cadDictionary = tmp.CadObject;
217,155✔
1177

1178
                        switch (this._reader.Code)
217,155✔
1179
                        {
1180
                                case 280:
1181
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,855✔
1182
                                        return true;
15,855✔
1183
                                case 281:
1184
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,150✔
1185
                                        return true;
23,150✔
1186
                                case 3:
1187
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
49,657✔
1188
                                        return true;
49,657✔
1189
                                case 350: // Soft-owner ID/handle to entry object 
1190
                                case 360: // Hard-owner ID/handle to entry object
1191
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
49,657✔
1192
                                        return true;
49,657✔
1193
                                default:
1194
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
78,836✔
1195
                        }
1196
                }
217,155✔
1197

1198
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1199
                {
2,070✔
1200
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1201

1202
                        switch (this._reader.Code)
2,070✔
1203
                        {
1204
                                case 340:
1205
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1206
                                        return true;
230✔
1207
                                default:
1208
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1209
                                        {
1,840✔
1210
                                                return this.readDictionary(template, map);
1,840✔
1211
                                        }
1212
                                        return true;
×
1213
                        }
1214
                }
2,070✔
1215

1216
                private CadTemplate readSortentsTable()
1217
                {
684✔
1218
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1219
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1220

1221
                        //Jump the 0 marker
1222
                        this._reader.ReadNext();
684✔
1223

1224
                        this.readCommonObjectData(template);
684✔
1225

1226
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
684✔
1227

1228
                        //Jump the 100 marker
1229
                        this._reader.ReadNext();
684✔
1230

1231
                        (ulong?, ulong?) pair = (null, null);
684✔
1232

1233
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1234
                        {
4,332✔
1235
                                switch (this._reader.Code)
4,332!
1236
                                {
1237
                                        case 5:
1238
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1239
                                                break;
1,824✔
1240
                                        case 330:
1241
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1242
                                                break;
684✔
1243
                                        case 331:
1244
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1245
                                                break;
1,824✔
1246
                                        default:
1247
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1248
                                                break;
×
1249
                                }
1250

1251
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1252
                                {
1,824✔
1253
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1254
                                        pair = (null, null);
1,824✔
1255
                                }
1,824✔
1256

1257
                                this._reader.ReadNext();
4,332✔
1258
                        }
4,332✔
1259

1260
                        return template;
684✔
1261
                }
684✔
1262
        }
1263
}
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