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

DomCR / ACadSharp / 20972171329

13 Jan 2026 08:52PM UTC coverage: 76.955% (+0.06%) from 76.896%
20972171329

Pull #949

github

web-flow
Merge 7e322d9c6 into 024480147
Pull Request #949: issue-948 dynamic properties

7968 of 11209 branches covered (71.09%)

Branch coverage included in aggregate %.

130 of 134 new or added lines in 10 files covered. (97.01%)

14 existing lines in 3 files now uncovered.

28969 of 36789 relevant lines covered (78.74%)

148864.37 hits per line

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

85.81
/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)
207✔
23
                {
207✔
24
                }
207✔
25

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

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

36
                                try
37
                                {
77,098✔
38
                                        template = this.readObject();
77,098✔
39
                                }
77,098✔
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,098✔
52
                                        continue;
×
53

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

59
                private CadTemplate readObject()
60
                {
77,098✔
61
                        switch (this._reader.ValueAsString)
77,098!
62
                        {
63
                                case DxfFileToken.ObjectPlaceholder:
64
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
195✔
65
                                case DxfFileToken.ObjectDBColor:
66
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
192✔
67
                                case DxfFileToken.ObjectDictionary:
68
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
21,244✔
69
                                case DxfFileToken.ObjectDictionaryWithDefault:
70
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
195✔
71
                                case DxfFileToken.ObjectLayout:
72
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
801✔
73
                                case DxfFileToken.ObjectPlotSettings:
74
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
75
                                case DxfFileToken.ObjectEvalGraph:
76
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
449✔
77
                                case DxfFileToken.ObjectImageDefinition:
78
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
192✔
79
                                case DxfFileToken.ObjectDictionaryVar:
80
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,796✔
81
                                case DxfFileToken.ObjectPdfDefinition:
82
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
192✔
83
                                case DxfFileToken.ObjectSortEntsTable:
84
                                        return this.readSortentsTable();
576✔
85
                                case DxfFileToken.ObjectImageDefinitionReactor:
86
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
192✔
87
                                case DxfFileToken.ObjectProxyObject:
88
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
89
                                case DxfFileToken.ObjectRasterVariables:
90
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
192✔
91
                                case DxfFileToken.ObjectGroup:
92
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
384✔
93
                                case DxfFileToken.ObjectGeoData:
94
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
95
                                case DxfFileToken.ObjectMaterial:
96
                                        return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,121✔
97
                                case DxfFileToken.ObjectScale:
98
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
6,639✔
99
                                case DxfFileToken.ObjectTableContent:
100
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
320✔
101
                                case DxfFileToken.ObjectVisualStyle:
102
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
4,680✔
103
                                case DxfFileToken.ObjectSpatialFilter:
104
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
192✔
105
                                case DxfFileToken.ObjectMLineStyle:
106
                                        return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
207✔
107
                                case DxfFileToken.ObjectMLeaderStyle:
108
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
402✔
109
                                case DxfFileToken.ObjectTableStyle:
110
                                        return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
195✔
111
                                case DxfFileToken.ObjectXRecord:
112
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
28,896✔
113
                                case DxfFileToken.ObjectBlockVisibilityParameter:
114
                                        return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
193✔
115
                                default:
116
                                        DxfMap map = DxfMap.Create<CadObject>();
5,651✔
117
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
5,651✔
118
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
5,651!
119
                                        {
5,651✔
120
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
5,651✔
121
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
5,651✔
122
                                        }
5,651✔
123
                                        else
124
                                        {
×
125
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
126
                                        }
×
127

128
                                        this._reader.ReadNext();
5,651✔
129

130
                                        do
131
                                        {
271,650✔
132
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
271,650!
133
                                                {
32,976✔
134
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
32,976✔
135
                                                        if (isExtendedData)
32,976✔
136
                                                                continue;
24✔
137
                                                }
32,952✔
138

139
                                                this._reader.ReadNext();
271,626✔
140
                                        }
271,626✔
141
                                        while (this._reader.DxfCode != DxfCode.Start);
271,650✔
142

143
                                        return unknownEntityTemplate;
5,651✔
144
                        }
145
                }
77,098✔
146

147
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
148
                        where T : CadObject
149
                {
70,871✔
150
                        this._reader.ReadNext();
70,871✔
151

152
                        DxfMap map = DxfMap.Create<T>();
70,871✔
153

154
                        while (this._reader.DxfCode != DxfCode.Start)
1,015,078✔
155
                        {
944,207✔
156
                                if (!readObject(template, map))
944,207✔
157
                                {
225,426✔
158
                                        this.readCommonCodes(template, out bool isExtendedData, map);
225,426✔
159
                                        if (isExtendedData)
225,426✔
160
                                                continue;
2,982✔
161
                                }
222,444✔
162

163
                                if (this.lockPointer)
941,225✔
164
                                {
1,152✔
165
                                        this.lockPointer = false;
1,152✔
166
                                        continue;
1,152✔
167
                                }
168

169
                                if (this._reader.DxfCode != DxfCode.Start)
940,073✔
170
                                {
910,728✔
171
                                        this._reader.ReadNext();
910,728✔
172
                                }
910,728✔
173
                        }
940,073✔
174

175
                        return template;
70,871✔
176
                }
70,871✔
177

178
                private bool readProxyObject(CadTemplate template, DxfMap map)
179
                {
×
180
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
181

182
                        switch (this._reader.Code)
×
183
                        {
184
                                case 90:
185
                                case 94:
186
                                //Undocumented
187
                                case 97:
188
                                case 71:
189
                                        return true;
×
190
                                case 95:
191
                                        int format = this._reader.ValueAsInt;
×
192
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
193
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
194
                                        return true;
×
195
                                case 91:
196
                                        var classId = this._reader.ValueAsShort;
×
197
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
198
                                        {
×
199
                                                proxy.DxfClass = dxfClass;
×
200
                                        }
×
201
                                        return true;
×
202
                                case 161:
203
                                        return true;
×
204
                                case 162:
205
                                        return true;
×
206
                                case 310:
207
                                        if (proxy.BinaryData == null)
×
208
                                        {
×
209
                                                proxy.BinaryData = new MemoryStream();
×
210
                                        }
×
211
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
212
                                        return true;
×
213
                                case 311:
214
                                        if (proxy.Data == null)
×
215
                                        {
×
216
                                                proxy.Data = new MemoryStream();
×
217
                                        }
×
218
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
219
                                        return true;
×
220
                                default:
221
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
222
                        }
223
                }
×
224

225
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
226
                {
23,241✔
227
                        switch (this._reader.Code)
23,241✔
228
                        {
229
                                default:
230
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,241✔
231
                        }
232
                }
23,241✔
233

234
                private bool readPlotSettings(CadTemplate template, DxfMap map)
235
                {
25,346✔
236
                        switch (this._reader.Code)
25,346✔
237
                        {
238
                                default:
239
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,346✔
240
                        }
241
                }
25,346✔
242

243
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
244
                {
3,080✔
245
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,080✔
246
                        EvaluationGraph evGraph = tmp.CadObject;
3,080✔
247

248
                        switch (this._reader.Code)
3,080✔
249
                        {
250
                                case 91:
251
                                        while (this._reader.Code == 91)
3,013✔
252
                                        {
2,564✔
253
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,564✔
254
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,564✔
255

256
                                                node.Index = this._reader.ValueAsInt;
2,564✔
257

258
                                                this._reader.ExpectedCode(93);
2,564✔
259
                                                node.Flags = this._reader.ValueAsInt;
2,564✔
260

261
                                                this._reader.ExpectedCode(95);
2,564✔
262
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,564✔
263

264
                                                this._reader.ExpectedCode(360);
2,564✔
265
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,564✔
266

267
                                                this._reader.ExpectedCode(92);
2,564✔
268
                                                node.Data1 = this._reader.ValueAsInt;
2,564✔
269
                                                this._reader.ExpectedCode(92);
2,564✔
270
                                                node.Data2 = this._reader.ValueAsInt;
2,564✔
271
                                                this._reader.ExpectedCode(92);
2,564✔
272
                                                node.Data3 = this._reader.ValueAsInt;
2,564✔
273
                                                this._reader.ExpectedCode(92);
2,564✔
274
                                                node.Data4 = this._reader.ValueAsInt;
2,564✔
275

276
                                                this._reader.ReadNext();
2,564✔
277

278
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,564✔
279
                                        }
2,564✔
280

281
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
449✔
282
                                case 92:
283
                                        //Edges
284
                                        while (this._reader.Code == 92)
2,116✔
285
                                        {
1,923✔
286
                                                this._reader.ExpectedCode(93);
1,923✔
287
                                                this._reader.ExpectedCode(94);
1,923✔
288
                                                this._reader.ExpectedCode(91);
1,923✔
289
                                                this._reader.ExpectedCode(91);
1,923✔
290
                                                this._reader.ExpectedCode(92);
1,923✔
291
                                                this._reader.ExpectedCode(92);
1,923✔
292
                                                this._reader.ExpectedCode(92);
1,923✔
293
                                                this._reader.ExpectedCode(92);
1,923✔
294
                                                this._reader.ExpectedCode(92);
1,923✔
295

296
                                                this._reader.ReadNext();
1,923✔
297
                                        }
1,923✔
298

299
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
193✔
300
                                default:
301
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,438✔
302
                        }
303
                }
3,080✔
304

305
                private bool readLayout(CadTemplate template, DxfMap map)
306
                {
51,597✔
307
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,597✔
308

309
                        switch (this._reader.Code)
51,597✔
310
                        {
311
                                case 330:
312
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,602✔
313
                                        return true;
1,602✔
314
                                case 331:
315
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
771✔
316
                                        return true;
771✔
317
                                default:
318
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,224✔
319
                                        {
25,346✔
320
                                                return this.readPlotSettings(template, map);
25,346✔
321
                                        }
322
                                        return true;
23,878✔
323
                        }
324
                }
51,597✔
325

326
                private bool readGroup(CadTemplate template, DxfMap map)
327
                {
4,992✔
328
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
329

330
                        switch (this._reader.Code)
4,992✔
331
                        {
332
                                case 70:
333
                                        return true;
384✔
334
                                case 340:
335
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
336
                                        return true;
2,304✔
337
                                default:
338
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
339
                        }
340
                }
4,992✔
341

342
                private bool readGeoData(CadTemplate template, DxfMap map)
343
                {
102✔
344
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
345

346
                        switch (this._reader.Code)
102✔
347
                        {
348
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
349
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
350
                                                tmp.CadObject.ReferencePoint.X,
1✔
351
                                                this._reader.ValueAsDouble,
1✔
352
                                                tmp.CadObject.ReferencePoint.Z
1✔
353
                                                );
1✔
354
                                        return true;
1✔
355
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
356
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
357
                                                this._reader.ValueAsDouble,
1✔
358
                                                tmp.CadObject.ReferencePoint.Y,
1✔
359
                                                tmp.CadObject.ReferencePoint.Z
1✔
360
                                                );
1✔
361
                                        return true;
1✔
362
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
363
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
364
                                                tmp.CadObject.ReferencePoint.X,
1✔
365
                                                tmp.CadObject.ReferencePoint.Y,
1✔
366
                                                this._reader.ValueAsDouble
1✔
367
                                                );
1✔
368
                                        return true;
1✔
369
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
370
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
371
                                        return true;
1✔
372
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
373
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
374
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
375
                                        return true;
1✔
376
                                // Number of Geo-Mesh points
377
                                case 93:
378
                                        var npts = this._reader.ValueAsInt;
3✔
379
                                        for (int i = 0; i < npts; i++)
54✔
380
                                        {
24✔
381
                                                this._reader.ReadNext();
24✔
382
                                                double sourceX = this._reader.ValueAsDouble;
24✔
383
                                                this._reader.ReadNext();
24✔
384
                                                double sourceY = this._reader.ValueAsDouble;
24✔
385

386
                                                this._reader.ReadNext();
24✔
387
                                                double destX = this._reader.ValueAsDouble;
24✔
388
                                                this._reader.ReadNext();
24✔
389
                                                double destY = this._reader.ValueAsDouble;
24✔
390

391
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
392
                                                {
24✔
393
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
394
                                                        Destination = new CSMath.XY(destX, destY)
24✔
395
                                                });
24✔
396
                                        }
24✔
397
                                        return true;
3✔
398
                                // Number of Geo-Mesh points
399
                                case 96:
400
                                        var nfaces = this._reader.ValueAsInt;
2✔
401
                                        for (int i = 0; i < nfaces; i++)
4!
402
                                        {
×
403
                                                this._reader.ReadNext();
×
404
                                                Debug.Assert(this._reader.Code == 97);
×
405
                                                int index1 = this._reader.ValueAsInt;
×
406
                                                this._reader.ReadNext();
×
407
                                                Debug.Assert(this._reader.Code == 98);
×
408
                                                int index2 = this._reader.ValueAsInt;
×
409
                                                this._reader.ReadNext();
×
410
                                                Debug.Assert(this._reader.Code == 99);
×
411
                                                int index3 = this._reader.ValueAsInt;
×
412

413
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
414
                                                {
×
415
                                                        Index1 = index1,
×
416
                                                        Index2 = index2,
×
417
                                                        Index3 = index3
×
418
                                                });
×
419
                                        }
×
420
                                        return true;
2✔
421
                                case 303:
422
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
423
                                        return true;
13✔
424
                                //Obsolete codes for version GeoDataVersion.R2009
425
                                case 3:
426
                                case 4:
427
                                case 14:
428
                                case 24:
429
                                case 15:
430
                                case 25:
431
                                case 43:
432
                                case 44:
433
                                case 45:
434
                                case 94:
435
                                case 293:
436
                                case 16:
437
                                case 26:
438
                                case 17:
439
                                case 27:
440
                                case 54:
441
                                case 140:
442
                                case 304:
443
                                case 292:
444
                                        return true;
19✔
445
                                default:
446
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
447
                        }
448
                }
102✔
449

450
                private bool readMaterial(CadTemplate template, DxfMap map)
451
                {
42,062✔
452
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,062✔
453
                        List<double> arr = null;
42,062✔
454

455
                        switch (this._reader.Code)
42,062!
456
                        {
457
                                case 43:
458
                                        arr = new();
1,347✔
459
                                        for (int i = 0; i < 16; i++)
45,798✔
460
                                        {
21,552✔
461
                                                Debug.Assert(this._reader.Code == 43);
21,552✔
462

463
                                                arr.Add(this._reader.ValueAsDouble);
21,552✔
464

465
                                                this._reader.ReadNext();
21,552✔
466
                                        }
21,552✔
467

468
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,347✔
469
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,347✔
470
                                case 47:
471
                                        arr = new();
×
472
                                        for (int i = 0; i < 16; i++)
×
473
                                        {
×
474
                                                Debug.Assert(this._reader.Code == 47);
×
475

476
                                                arr.Add(this._reader.ValueAsDouble);
×
477

478
                                                this._reader.ReadNext();
×
479
                                        }
×
480

481
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
482
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
483
                                case 49:
484
                                        arr = new();
195✔
485
                                        for (int i = 0; i < 16; i++)
6,630✔
486
                                        {
3,120✔
487
                                                Debug.Assert(this._reader.Code == 49);
3,120✔
488

489
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
490

491
                                                this._reader.ReadNext();
3,120✔
492
                                        }
3,120✔
493

494
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
195✔
495
                                        return this.checkObjectEnd(template, map, this.readMaterial);
195✔
496
                                case 142:
497
                                        arr = new();
195✔
498
                                        for (int i = 0; i < 16; i++)
6,630✔
499
                                        {
3,120✔
500
                                                Debug.Assert(this._reader.Code == 142);
3,120✔
501

502
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
503

504
                                                this._reader.ReadNext();
3,120✔
505
                                        }
3,120✔
506

507
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
195✔
508
                                        return this.checkObjectEnd(template, map, this.readMaterial);
195✔
509
                                case 144:
510
                                        arr = new();
1,155✔
511
                                        for (int i = 0; i < 16; i++)
39,270✔
512
                                        {
18,480✔
513
                                                Debug.Assert(this._reader.Code == 144);
18,480✔
514

515
                                                arr.Add(this._reader.ValueAsDouble);
18,480✔
516

517
                                                this._reader.ReadNext();
18,480✔
518
                                        }
18,480✔
519

520
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,155✔
521
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,155✔
522
                                case 147:
523
                                        arr = new();
×
524
                                        for (int i = 0; i < 16; i++)
×
525
                                        {
×
526
                                                Debug.Assert(this._reader.Code == 147);
×
527

528
                                                arr.Add(this._reader.ValueAsDouble);
×
529

530
                                                this._reader.ReadNext();
×
531
                                        }
×
532

533
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
534
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
535
                                default:
536
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,170✔
537
                        }
538
                }
42,062✔
539

540
                private bool readScale(CadTemplate template, DxfMap map)
541
                {
59,547✔
542
                        switch (this._reader.Code)
59,547✔
543
                        {
544
                                // Undocumented codes
545
                                case 70:
546
                                        //Always 0
547
                                        return true;
6,639✔
548
                                default:
549
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
52,908✔
550
                        }
551
                }
59,547✔
552

553
                private void readLinkedData(CadTemplate template, DxfMap map)
554
                {
320✔
555
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
556
                        LinkedData linkedData = tmp.CadObject;
320✔
557

558
                        this._reader.ReadNext();
320✔
559

560
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
561
                        {
640✔
562
                                switch (this._reader.Code)
640✔
563
                                {
564
                                        default:
565
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
566
                                                {
×
567
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
568
                                                }
×
569
                                                break;
640✔
570
                                }
571

572
                                this._reader.ReadNext();
640✔
573
                        }
640✔
574
                }
320✔
575

576
                private bool readTableContent(CadTemplate template, DxfMap map)
577
                {
2,368✔
578
                        switch (this._reader.Code)
2,368✔
579
                        {
580
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
581
                                        this.readTableContentSubclass(template, map);
256✔
582
                                        this.lockPointer = true;
256✔
583
                                        return true;
256✔
584
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
585
                                        this.readFormattedTableDataSubclass(template, map);
256✔
586
                                        this.lockPointer = true;
256✔
587
                                        return true;
256✔
588
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
589
                                        this.readLinkedTableDataSubclass(template, map);
320✔
590
                                        this.lockPointer = true;
320✔
591
                                        return true;
320✔
592
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
593
                                        this.readLinkedData(template, map);
320✔
594
                                        this.lockPointer = true;
320✔
595
                                        return true;
320✔
596
                                default:
597
                                        return false;
1,216✔
598
                        }
599
                }
2,368✔
600

601
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
602
                {
256✔
603
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
604
                        TableContent tableContent = tmp.CadObject;
256✔
605

606
                        this._reader.ReadNext();
256✔
607

608
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
609
                        {
256✔
610
                                switch (this._reader.Code)
256!
611
                                {
612
                                        case 340:
613
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
614
                                                break;
256✔
615
                                        default:
616
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
617
                                                {
×
618
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
619
                                                }
×
620
                                                break;
×
621
                                }
622

623
                                this._reader.ReadNext();
256✔
624
                        }
256✔
625
                }
256✔
626

627
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
628
                {
256✔
629
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
630
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
631

632
                        this._reader.ReadNext();
256✔
633

634
                        TableEntity.CellRange cellRange = null;
256✔
635
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
636
                        {
2,048✔
637
                                switch (this._reader.Code)
2,048!
638
                                {
639
                                        case 90:
640
                                                break;
256✔
641
                                        case 91:
642
                                                if (cellRange == null)
384✔
643
                                                {
384✔
644
                                                        cellRange = new();
384✔
645
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
646
                                                }
384✔
647
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
648
                                                break;
384✔
649
                                        case 92:
650
                                                if (cellRange == null)
384!
651
                                                {
×
652
                                                        cellRange = new();
×
653
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
654
                                                }
×
655
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
656
                                                break;
384✔
657
                                        case 93:
658
                                                if (cellRange == null)
384!
659
                                                {
×
660
                                                        cellRange = new();
×
661
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
662
                                                }
×
663
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
664
                                                break;
384✔
665
                                        case 94:
666
                                                if (cellRange == null)
384!
667
                                                {
×
668
                                                        cellRange = new();
×
669
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
670
                                                }
×
671
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
672
                                                cellRange = null;
384✔
673
                                                break;
384✔
674
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
675
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
676
                                                break;
256✔
677
                                        default:
678
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
679
                                                {
×
680
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
681
                                                }
×
682
                                                break;
×
683
                                }
684

685
                                this._reader.ReadNext();
2,048✔
686
                        }
2,048✔
687
                }
256✔
688

689
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
690
                {
320✔
691
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
692
                        TableContent tableContent = tmp.CadObject;
320✔
693

694
                        this._reader.ReadNext();
320✔
695

696
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
697
                        {
3,904✔
698
                                switch (this._reader.Code)
3,904✔
699
                                {
700
                                        case 90:
701
                                                //Column count
702
                                                break;
320✔
703
                                        case 91:
704
                                                //Row count
705
                                                break;
320✔
706
                                        //Unknown
707
                                        case 92:
708
                                                break;
256✔
709
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
710
                                                //Read Column
711
                                                this.readTableColumn();
1,216✔
712
                                                break;
1,216✔
713
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
714
                                                //Read Row
715
                                                this.readTableRow();
1,472✔
716
                                                break;
1,472✔
717
                                        default:
718
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
719
                                                {
320✔
720
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
721
                                                }
320✔
722
                                                break;
320✔
723
                                }
724

725
                                this._reader.ReadNext();
3,904✔
726
                        }
3,904✔
727
                }
320✔
728

729

730
                private TableEntity.Column readTableColumn()
731
                {
1,216✔
732
                        this._reader.ReadNext();
1,216✔
733

734
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
735

736
                        bool end = false;
1,216✔
737
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
738
                        {
3,648✔
739
                                switch (this._reader.Code)
3,648!
740
                                {
741
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
742
                                                this.readLinkedTableColumn(column);
1,216✔
743
                                                break;
1,216✔
744
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
745
                                                this.readFormattedTableColumn(column);
1,216✔
746
                                                break;
1,216✔
747
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
748
                                                this.readTableColumn(column);
1,216✔
749
                                                end = true;
1,216✔
750
                                                break;
1,216✔
751
                                        default:
752
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
753
                                                break;
×
754
                                }
755

756
                                if (end)
3,648✔
757
                                {
1,216✔
758
                                        return column;
1,216✔
759
                                }
760

761
                                this._reader.ReadNext();
2,432✔
762
                        }
2,432✔
763

764
                        return column;
×
765
                }
1,216✔
766

767
                private TableEntity.Row readTableRow()
768
                {
1,472✔
769
                        this._reader.ReadNext();
1,472✔
770

771
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
772

773
                        bool end = false;
1,472✔
774
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
775
                        {
11,840✔
776
                                switch (this._reader.Code)
11,840✔
777
                                {
778
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
779
                                                this.readLinkedTableRow(row);
1,536✔
780
                                                break;
1,536✔
781
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
782
                                                this.readFormattedTableRow(row);
1,408✔
783
                                                break;
1,408✔
784
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
785
                                                this.readTableRow(row);
1,408✔
786
                                                end = true;
1,408✔
787
                                                break;
1,408✔
788
                                        default:
789
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
790
                                                break;
7,488✔
791
                                }
792

793
                                if (end)
11,840✔
794
                                {
1,408✔
795
                                        return row;
1,408✔
796
                                }
797

798
                                this._reader.ReadNext();
10,432✔
799
                        }
10,432✔
800

801
                        return row;
64✔
802
                }
1,472✔
803

804
                private void readTableRow(TableEntity.Row row)
805
                {
1,408✔
806
                        this._reader.ReadNext();
1,408✔
807

808
                        bool end = false;
1,408✔
809
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
810
                        {
4,224✔
811
                                switch (this._reader.Code)
4,224!
812
                                {
813
                                        case 40:
814
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
815
                                                break;
1,408✔
816
                                        case 90:
817
                                                //styleID
818
                                                break;
1,408✔
819
                                        case 309:
820
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
821
                                                break;
1,408✔
822
                                        default:
823
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
824
                                                break;
×
825
                                }
826

827
                                if (end)
4,224✔
828
                                {
1,408✔
829
                                        break;
1,408✔
830
                                }
831

832
                                this._reader.ReadNext();
2,816✔
833
                        }
2,816✔
834
                }
1,408✔
835

836
                private void readFormattedTableRow(TableEntity.Row row)
837
                {
1,408✔
838
                        this._reader.ReadNext();
1,408✔
839

840
                        bool end = false;
1,408✔
841
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
842
                        {
4,224✔
843
                                switch (this._reader.Code)
4,224!
844
                                {
845
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
846
                                                break;
1,408✔
847
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
848
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
849
                                                break;
1,408✔
850
                                        case 309:
851
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
852
                                                break;
1,408✔
853
                                        default:
854
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
855
                                                break;
×
856
                                }
857

858
                                if (end)
4,224✔
859
                                {
1,408✔
860
                                        break;
1,408✔
861
                                }
862

863
                                this._reader.ReadNext();
2,816✔
864
                        }
2,816✔
865
                }
1,408✔
866

867
                private void readTableColumn(TableEntity.Column column)
868
                {
1,216✔
869
                        this._reader.ReadNext();
1,216✔
870

871
                        bool end = false;
1,216✔
872
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
873
                        {
3,648✔
874
                                switch (this._reader.Code)
3,648!
875
                                {
876
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
877
                                                break;
×
878
                                        case 1:
879
                                                end = true;
×
880
                                                break;
×
881
                                        case 40:
882
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
883
                                                break;
1,216✔
884
                                        case 90:
885
                                                //StyleId
886
                                                break;
1,216✔
887
                                        case 309:
888
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
889
                                                break;
1,216✔
890
                                        default:
891
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
892
                                                break;
×
893
                                }
894

895
                                if (end)
3,648✔
896
                                {
1,216✔
897
                                        break;
1,216✔
898
                                }
899

900
                                this._reader.ReadNext();
2,432✔
901
                        }
2,432✔
902
                }
1,216✔
903

904
                private void readLinkedTableColumn(TableEntity.Column column)
905
                {
1,216✔
906
                        this._reader.ReadNext();
1,216✔
907

908
                        bool end = false;
1,216✔
909
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
910
                        {
4,864✔
911
                                switch (this._reader.Code)
4,864!
912
                                {
913
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
914
                                                break;
×
915
                                        case 1:
916
                                                end = true;
×
917
                                                break;
×
918
                                        case 91:
919
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
920
                                                break;
1,216✔
921
                                        case 300:
922
                                                column.Name = this._reader.ValueAsString;
1,216✔
923
                                                break;
1,216✔
924
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
925
                                                this.readCustomData();
1,216✔
926
                                                break;
1,216✔
927
                                        case 309:
928
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
929
                                                break;
1,216✔
930
                                        default:
931
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
932
                                                break;
×
933
                                }
934

935
                                if (end)
4,864✔
936
                                {
1,216✔
937
                                        break;
1,216✔
938
                                }
939

940
                                this._reader.ReadNext();
3,648✔
941
                        }
3,648✔
942
                }
1,216✔
943

944
                private void readLinkedTableRow(TableEntity.Row row)
945
                {
1,536✔
946
                        this._reader.ReadNext();
1,536✔
947

948
                        bool end = false;
1,536✔
949
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
950
                        {
12,480✔
951
                                switch (this._reader.Code)
12,480!
952
                                {
953
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
954
                                                break;
×
955
                                        case 90:
956
                                                break;
1,536✔
957
                                        case 91:
958
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
959
                                                break;
1,408✔
960
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
961
                                                this.readCell();
5,376✔
962
                                                break;
5,376✔
963
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
964
                                                this.readCustomData();
1,408✔
965
                                                break;
1,408✔
966
                                        case 309:
967
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
968
                                                break;
1,408✔
969
                                        default:
970
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
971
                                                break;
1,344✔
972
                                }
973

974
                                if (end)
12,480✔
975
                                {
1,408✔
976
                                        break;
1,408✔
977
                                }
978

979
                                this._reader.ReadNext();
11,072✔
980
                        }
11,072✔
981
                }
1,536✔
982

983
                private TableEntity.Cell readCell()
984
                {
5,376✔
985
                        this._reader.ReadNext();
5,376✔
986

987
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
988
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
989

990
                        bool end = false;
5,376✔
991
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
992
                        {
16,832✔
993
                                switch (this._reader.Code)
16,832✔
994
                                {
995
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
996
                                                this.readLinkedTableCell(cell);
5,376✔
997
                                                break;
5,376✔
998
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
999
                                                this.readFormattedTableCell(cell);
5,248✔
1000
                                                break;
5,248✔
1001
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1002
                                                this.readTableCell(cell);
5,248✔
1003
                                                end = true;
5,248✔
1004
                                                break;
5,248✔
1005
                                        default:
1006
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1007
                                                break;
960✔
1008
                                }
1009

1010
                                if (end)
16,832✔
1011
                                {
5,248✔
1012
                                        return cell;
5,248✔
1013
                                }
1014

1015
                                this._reader.ReadNext();
11,584✔
1016
                        }
11,584✔
1017

1018
                        return cell;
128✔
1019
                }
5,376✔
1020

1021
                private void readTableCell(TableEntity.Cell cell)
1022
                {
5,248✔
1023
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1024

1025
                        this._reader.ReadNext();
5,248✔
1026

1027
                        bool end = false;
5,248✔
1028
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1029
                        {
16,384✔
1030
                                switch (this._reader.Code)
16,384✔
1031
                                {
1032
                                        //Unknown
1033
                                        case 40:
1034
                                        case 41:
1035
                                                break;
256✔
1036
                                        case 309:
1037
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1038
                                                break;
5,248✔
1039
                                        case 330:
1040
                                                //Unknown handle
1041
                                                break;
128✔
1042
                                        default:
1043
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1044
                                                {
×
1045
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1046
                                                }
×
1047
                                                break;
10,752✔
1048
                                }
1049

1050
                                if (end)
16,384✔
1051
                                {
5,248✔
1052
                                        break;
5,248✔
1053
                                }
1054

1055
                                this._reader.ReadNext();
11,136✔
1056
                        }
11,136✔
1057
                }
5,248✔
1058

1059
                private void readFormattedTableCell(TableEntity.Cell cell)
1060
                {
5,248✔
1061
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1062

1063
                        this._reader.ReadNext();
5,248✔
1064

1065
                        bool end = false;
5,248✔
1066
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1067
                        {
10,496✔
1068
                                switch (this._reader.Code)
10,496!
1069
                                {
1070
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1071
                                                this.readCellTableFormat(cell);
5,248✔
1072
                                                continue;
5,248✔
1073
                                        case 309:
1074
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1075
                                                break;
5,248✔
1076
                                        default:
1077
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1078
                                                {
×
1079
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1080
                                                }
×
1081
                                                break;
×
1082
                                }
1083

1084
                                if (end)
5,248!
1085
                                {
5,248✔
1086
                                        break;
5,248✔
1087
                                }
1088

1089
                                this._reader.ReadNext();
×
1090
                        }
×
1091
                }
5,248✔
1092

1093
                private void readCellTableFormat(TableEntity.Cell cell)
1094
                {
5,248✔
1095
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1096

1097
                        this._reader.ReadNext();
5,248✔
1098

1099
                        bool end = false;
5,248✔
1100
                        while (this._reader.Code == 1)
10,496✔
1101
                        {
5,248✔
1102
                                switch (this._reader.Code)
5,248!
1103
                                {
1104
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1105
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1106
                                                break;
5,248✔
1107
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1108
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1109
                                                break;
×
1110
                                        default:
1111
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1112
                                                {
×
1113
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1114
                                                }
×
1115
                                                break;
×
1116
                                }
1117

1118
                                if (end)
5,248!
1119
                                {
×
1120
                                        break;
×
1121
                                }
1122

1123
                                this._reader.ReadNext();
5,248✔
1124
                        }
5,248✔
1125
                }
5,248✔
1126

1127
                private void readCellStyle(CadCellStyleTemplate template)
1128
                {
×
1129
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1130

1131
                        this._reader.ReadNext();
×
1132

1133
                        bool end = false;
×
1134
                        while (this._reader.Code != 1)
×
1135
                        {
×
1136
                                switch (this._reader.Code)
×
1137
                                {
1138
                                        case 309:
1139
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1140
                                                break;
×
1141
                                        default:
1142
                                                //if (!this.tryAssignCurrentValue(cell, map))
1143
                                                {
×
1144
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1145
                                                }
×
1146
                                                break;
×
1147
                                }
1148

1149
                                if (end)
×
1150
                                {
×
1151
                                        break;
×
1152
                                }
1153

1154
                                this._reader.ReadNext();
×
1155
                        }
×
1156
                }
×
1157

1158
                private void readLinkedTableCell(TableEntity.Cell cell)
1159
                {
5,376✔
1160
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1161

1162
                        this._reader.ReadNext();
5,376✔
1163

1164
                        bool end = false;
5,376✔
1165
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1166
                        {
53,760✔
1167
                                switch (this._reader.Code)
53,760✔
1168
                                {
1169
                                        case 95:
1170
                                                //BL 95 Number of cell contents
1171
                                                break;
5,248✔
1172
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1173
                                                this.readCustomData();
5,376✔
1174
                                                break;
5,376✔
1175
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1176
                                                var c = this.readLinkedTableCellContent();
4,096✔
1177
                                                break;
4,096✔
1178
                                        case 309:
1179
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1180
                                                break;
5,248✔
1181
                                        default:
1182
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1183
                                                {
11,648✔
1184
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1185
                                                }
11,648✔
1186
                                                break;
33,792✔
1187
                                }
1188

1189
                                if (end)
53,760✔
1190
                                {
5,248✔
1191
                                        break;
5,248✔
1192
                                }
1193

1194
                                this._reader.ReadNext();
48,512✔
1195
                        }
48,512✔
1196
                }
5,376✔
1197

1198
                private CadTableCellContentTemplate readLinkedTableCellContent()
1199
                {
4,096✔
1200
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1201
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1202
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1203

1204
                        this._reader.ReadNext();
4,096✔
1205

1206
                        bool end = false;
4,096✔
1207
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1208
                        {
8,192✔
1209
                                switch (this._reader.Code)
8,192!
1210
                                {
1211
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1212
                                                readFormattedCellContent();
4,096✔
1213
                                                end = true;
4,096✔
1214
                                                break;
4,096✔
1215
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1216
                                                readCellContent(template);
4,096✔
1217
                                                break;
4,096✔
1218
                                        default:
1219
                                                if (!this.tryAssignCurrentValue(content, map))
×
1220
                                                {
×
1221
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1222
                                                }
×
1223
                                                break;
×
1224
                                }
1225

1226
                                if (end)
8,192✔
1227
                                {
4,096✔
1228
                                        break;
4,096✔
1229
                                }
1230

1231
                                this._reader.ReadNext();
4,096✔
1232
                        }
4,096✔
1233

1234
                        return template;
4,096✔
1235
                }
4,096✔
1236

1237
                private void readCellContent(CadTableCellContentTemplate template)
1238
                {
4,096✔
1239
                        TableEntity.CellContent content = template.Content;
4,096✔
1240
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1241

1242
                        this._reader.ReadNext();
4,096✔
1243

1244
                        bool end = false;
4,096✔
1245
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1246
                        {
16,384✔
1247
                                switch (this._reader.Code)
16,384✔
1248
                                {
1249
                                        case 91:
1250
                                                break;
4,096✔
1251
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1252
                                                this.readDataMapValue();
3,712✔
1253
                                                break;
3,712✔
1254
                                        case 309:
1255
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1256
                                                break;
4,096✔
1257
                                        case 340:
1258
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1259
                                                break;
384✔
1260
                                        default:
1261
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1262
                                                {
×
1263
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1264
                                                }
×
1265
                                                break;
4,096✔
1266
                                }
1267

1268
                                if (end)
16,384✔
1269
                                {
4,096✔
1270
                                        break;
4,096✔
1271
                                }
1272

1273
                                this._reader.ReadNext();
12,288✔
1274
                        }
12,288✔
1275
                }
4,096✔
1276

1277
                private void readFormattedCellContent()
1278
                {
4,096✔
1279
                        TableEntity.ContentFormat format = new();
4,096✔
1280
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1281
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1282

1283
                        this._reader.ReadNext();
4,096✔
1284

1285
                        bool end = false;
4,096✔
1286
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1287
                        {
12,288✔
1288
                                switch (this._reader.Code)
12,288✔
1289
                                {
1290
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1291
                                                readContentFormat(template);
4,096✔
1292
                                                break;
4,096✔
1293
                                        case 309:
1294
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1295
                                                break;
4,096✔
1296
                                        default:
1297
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1298
                                                {
×
1299
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1300
                                                }
×
1301
                                                break;
4,096✔
1302
                                }
1303

1304
                                if (end)
12,288✔
1305
                                {
4,096✔
1306
                                        break;
4,096✔
1307
                                }
1308

1309
                                this._reader.ReadNext();
8,192✔
1310
                        }
8,192✔
1311
                }
4,096✔
1312

1313
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1314
                {
9,600✔
1315
                        var format = template.Format;
9,600✔
1316
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1317

1318
                        this._reader.ReadNext();
9,600✔
1319

1320
                        bool end = false;
9,600✔
1321
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1322
                        {
124,800✔
1323
                                switch (this._reader.Code)
124,800✔
1324
                                {
1325
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1326
                                                break;
9,600✔
1327
                                        case 309:
1328
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1329
                                                break;
9,600✔
1330
                                        case 340:
1331
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1332
                                                break;
9,600✔
1333
                                        default:
1334
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1335
                                                {
×
1336
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1337
                                                }
×
1338
                                                break;
96,000✔
1339
                                }
1340

1341
                                if (end)
124,800✔
1342
                                {
9,600✔
1343
                                        break;
9,600✔
1344
                                }
1345

1346
                                this._reader.ReadNext();
115,200✔
1347
                        }
115,200✔
1348
                }
9,600✔
1349

1350
                private void readFormattedTableColumn(TableEntity.Column column)
1351
                {
1,216✔
1352
                        this._reader.ReadNext();
1,216✔
1353

1354
                        bool end = false;
1,216✔
1355
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1356
                        {
3,648✔
1357
                                switch (this._reader.Code)
3,648!
1358
                                {
1359
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1360
                                                break;
1,216✔
1361
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1362
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1363
                                                break;
1,216✔
1364
                                        case 309:
1365
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1366
                                                break;
1,216✔
1367
                                        default:
1368
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1369
                                                break;
×
1370
                                }
1371

1372
                                if (end)
3,648✔
1373
                                {
1,216✔
1374
                                        break;
1,216✔
1375
                                }
1376

1377
                                this._reader.ReadNext();
2,432✔
1378
                        }
2,432✔
1379
                }
1,216✔
1380

1381
                private void readStyleOverride(CadCellStyleTemplate template)
1382
                {
8,128✔
1383
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1384
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1385
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1386

1387
                        this._reader.ReadNext();
8,128✔
1388

1389
                        bool end = false;
8,128✔
1390
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1391
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1392
                        {
89,536✔
1393
                                switch (this._reader.Code)
89,536✔
1394
                                {
1395
                                        case 95:
1396
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1397
                                                break;
11,776✔
1398
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1399
                                                break;
256✔
1400
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1401
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1402
                                                break;
5,504✔
1403
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1404
                                                this.readCellMargin(template);
2,816✔
1405
                                                break;
2,816✔
1406
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1407
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1408
                                                this.readGridFormat(template, border);
11,776✔
1409
                                                break;
11,776✔
1410
                                        case 309:
1411
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1412
                                                break;
8,128✔
1413
                                        default:
1414
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
1415
                                                {
×
1416
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1417
                                                }
×
1418
                                                break;
49,280✔
1419
                                }
1420

1421
                                if (end)
89,536✔
1422
                                {
8,128✔
1423
                                        break;
8,128✔
1424
                                }
1425

1426
                                this._reader.ReadNext();
81,408✔
1427
                        }
81,408✔
1428
                }
8,128✔
1429

1430
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1431
                {
11,776✔
1432
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1433

1434
                        this._reader.ReadNext();
11,776✔
1435

1436
                        bool end = false;
11,776✔
1437
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1438
                        {
105,984✔
1439
                                switch (this._reader.Code)
105,984✔
1440
                                {
1441
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1442
                                                break;
11,776✔
1443
                                        case 62:
1444
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1445
                                                break;
11,776✔
1446
                                        case 92:
1447
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1448
                                                break;
11,776✔
1449
                                        case 93:
1450
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1451
                                                break;
11,776✔
1452
                                        case 340:
1453
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1454
                                                break;
11,776✔
1455
                                        case 309:
1456
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1457
                                                break;
11,776✔
1458
                                        default:
1459
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
1460
                                                {
×
1461
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1462
                                                }
×
1463
                                                break;
35,328✔
1464
                                }
1465

1466
                                if (end)
105,984✔
1467
                                {
11,776✔
1468
                                        break;
11,776✔
1469
                                }
1470

1471
                                this._reader.ReadNext();
94,208✔
1472
                        }
94,208✔
1473
                }
11,776✔
1474

1475
                private void readCellMargin(CadCellStyleTemplate template)
1476
                {
2,816✔
1477
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1478

1479
                        this._reader.ReadNext();
2,816✔
1480

1481
                        bool end = false;
2,816✔
1482
                        int i = 0;
2,816✔
1483
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1484
                        {
22,528✔
1485
                                switch (this._reader.Code)
22,528!
1486
                                {
1487
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1488
                                                break;
2,816✔
1489
                                        case 40:
1490
                                                switch (i)
16,896✔
1491
                                                {
1492
                                                        case 0:
1493
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1494
                                                                break;
2,816✔
1495
                                                        case 1:
1496
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1497
                                                                break;
2,816✔
1498
                                                        case 2:
1499
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1500
                                                                break;
2,816✔
1501
                                                        case 3:
1502
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1503
                                                                break;
2,816✔
1504
                                                        case 4:
1505
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1506
                                                                break;
2,816✔
1507
                                                        case 5:
1508
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1509
                                                                break;
2,816✔
1510
                                                }
1511

1512
                                                i++;
16,896✔
1513
                                                break;
16,896✔
1514
                                        case 309:
1515
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1516
                                                break;
2,816✔
1517
                                        default:
1518
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1519
                                                break;
×
1520
                                }
1521

1522
                                if (end)
22,528✔
1523
                                {
2,816✔
1524
                                        break;
2,816✔
1525
                                }
1526

1527
                                this._reader.ReadNext();
19,712✔
1528
                        }
19,712✔
1529
                }
2,816✔
1530

1531
                private void readCustomData()
1532
                {
8,000✔
1533
                        this._reader.ReadNext();
8,000✔
1534

1535
                        int ndata = 0;
8,000✔
1536
                        bool end = false;
8,000✔
1537
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1538
                        {
74,304✔
1539
                                switch (this._reader.Code)
74,304✔
1540
                                {
1541
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1542
                                                break;
8,000✔
1543
                                        case 90:
1544
                                                ndata = this._reader.ValueAsInt;
8,128✔
1545
                                                break;
8,128✔
1546
                                        case 300:
1547
                                                //Name
1548
                                                break;
5,248✔
1549
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1550
                                                this.readDataMapValue();
5,248✔
1551
                                                break;
5,248✔
1552
                                        case 309:
1553
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1554
                                                break;
7,872✔
1555
                                        default:
1556
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1557
                                                break;
39,808✔
1558
                                }
1559

1560
                                if (end)
74,304✔
1561
                                {
7,872✔
1562
                                        break;
7,872✔
1563
                                }
1564

1565
                                this._reader.ReadNext();
66,432✔
1566
                        }
66,432✔
1567
                }
8,000✔
1568

1569
                private void readDataMapValue()
1570
                {
8,960✔
1571
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1572
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1573

1574
                        this._reader.ReadNext();
8,960✔
1575

1576
                        bool end = false;
8,960✔
1577
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1578
                        {
330,112✔
1579
                                switch (this._reader.Code)
330,112✔
1580
                                {
1581
                                        case 11:
1582
                                        case 21:
1583
                                        case 31:
1584
                                                //Value as point
1585
                                                break;
768✔
1586
                                        case 91:
1587
                                        case 92:
1588
                                                //Value as int
1589
                                                break;
38,912✔
1590
                                        case 140:
1591
                                                //Value as double
1592
                                                break;
13,248✔
1593
                                        case 310:
1594
                                                //Value as byte array
1595
                                                break;
256✔
1596
                                        case 304:
1597
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1598
                                                break;
8,832✔
1599
                                        default:
1600
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1601
                                                {
106,880✔
1602
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1603
                                                }
106,880✔
1604
                                                break;
268,096✔
1605
                                }
1606

1607
                                if (end)
330,112✔
1608
                                {
8,832✔
1609
                                        break;
8,832✔
1610
                                }
1611

1612
                                this._reader.ReadNext();
321,280✔
1613
                        }
321,280✔
1614
                }
8,960✔
1615

1616
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1617
                {
373,262✔
1618
                        switch (this._reader.Code)
373,262✔
1619
                        {
1620
                                // Undocumented codes
1621
                                case 176:
1622
                                case 177:
1623
                                case 420:
1624
                                        return true;
120,612✔
1625
                                default:
1626
                                        //Avoid noise while is not implemented
1627
                                        return true;
252,650✔
1628
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1629
                        }
1630
                }
373,262✔
1631

1632
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1633
                {
4,032✔
1634
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1635
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1636

1637
                        switch (this._reader.Code)
4,032✔
1638
                        {
1639
                                case 10:
1640
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1641
                                        return true;
384✔
1642
                                case 20:
1643
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1644
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1645
                                        return true;
384✔
1646
                                case 40:
1647
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1648
                                        {
×
1649
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1650
                                                tmp.HasFrontPlane = true;
×
1651
                                        }
×
1652

1653
                                        double[] array = new double[16]
384✔
1654
                                        {
384✔
1655
                                                0.0, 0.0, 0.0, 0.0,
384✔
1656
                                                0.0, 0.0, 0.0, 0.0,
384✔
1657
                                                0.0, 0.0, 0.0, 0.0,
384✔
1658
                                                0.0, 0.0, 0.0, 1.0
384✔
1659
                                        };
384✔
1660

1661
                                        for (int i = 0; i < 12; i++)
9,984✔
1662
                                        {
4,608✔
1663
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1664

1665
                                                if (i < 11)
4,608✔
1666
                                                {
4,224✔
1667
                                                        this._reader.ReadNext();
4,224✔
1668
                                                }
4,224✔
1669
                                        }
4,608✔
1670

1671
                                        if (tmp.InsertTransformRead)
384!
1672
                                        {
×
1673
                                                filter.InsertTransform = new Matrix4(array);
×
1674
                                                tmp.InsertTransformRead = true;
×
1675
                                        }
×
1676
                                        else
1677
                                        {
384✔
1678
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1679
                                        }
384✔
1680

1681
                                        return true;
384✔
1682
                                case 73:
1683
                                default:
1684
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1685
                        }
1686
                }
4,032✔
1687

1688
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1689
                {
3,495✔
1690
                        var tmp = template as CadMLineStyleTemplate;
3,495✔
1691
                        var mLineStyle = template.CadObject as MLineStyle;
3,495✔
1692

1693
                        switch (this._reader.Code)
3,495✔
1694
                        {
1695
                                case 6:
1696
                                        var t = tmp.ElementTemplates.LastOrDefault();
414✔
1697
                                        if (t == null)
414!
1698
                                        {
×
1699
                                                return true;
×
1700
                                        }
1701
                                        t.LineTypeName = this._reader.ValueAsString;
414✔
1702
                                        return true;
414✔
1703
                                case 49:
1704
                                        MLineStyle.Element element = new MLineStyle.Element();
414✔
1705
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
414✔
1706
                                        element.Offset = this._reader.ValueAsDouble;
414✔
1707

1708
                                        tmp.ElementTemplates.Add(elementTemplate);
414✔
1709
                                        mLineStyle.AddElement(element);
414✔
1710
                                        return true;
414✔
1711
                                default:
1712
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,667✔
1713
                        }
1714
                }
3,495✔
1715

1716
                private bool readTableStyle(CadTemplate template, DxfMap map)
1717
                {
17,657✔
1718
                        var tmp = template as CadTableStyleTemplate;
17,657✔
1719
                        var style = tmp.CadObject;
17,657✔
1720
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,657✔
1721

1722
                        switch (this._reader.Code)
17,657!
1723
                        {
1724
                                case 7:
1725
                                        tmp.CreateCurrentCellStyleTemplate();
585✔
1726
                                        tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
585✔
1727
                                        return true;
585✔
1728
                                case 94:
1729
                                        cellStyle.Alignment = this._reader.ValueAsInt;
×
1730
                                        return true;
×
1731
                                case 62:
1732
                                        cellStyle.Color = new Color(this._reader.ValueAsShort);
585✔
1733
                                        return true;
585✔
1734
                                case 63:
1735
                                        cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
585✔
1736
                                        return true;
585✔
1737
                                case 140:
1738
                                        cellStyle.TextHeight = this._reader.ValueAsDouble;
585✔
1739
                                        return true;
585✔
1740
                                case 170:
1741
                                        cellStyle.CellAlignment = (TableEntity.Cell.CellAlignmentType)this._reader.ValueAsShort;
585✔
1742
                                        return true;
585✔
1743
                                case 283:
1744
                                        cellStyle.IsFillColorOn = this._reader.ValueAsBool;
585✔
1745
                                        return true;
585✔
1746
                                case 90:
1747
                                        cellStyle.Type = (TableEntity.CellStyleType)this._reader.ValueAsShort;
393✔
1748
                                        return true;
393✔
1749
                                case 91:
1750
                                        cellStyle.StyleClass = (TableEntity.CellStyleClass)this._reader.ValueAsShort;
393✔
1751
                                        return true;
393✔
1752
                                case 1:
1753
                                        //Undocumented
1754
                                        return true;
393✔
1755
                                case 274:
1756
                                        cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1757
                                        return true;
585✔
1758
                                case 275:
1759
                                        cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1760
                                        return true;
585✔
1761
                                case 276:
1762
                                        cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1763
                                        return true;
585✔
1764
                                case 277:
1765
                                        cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1766
                                        return true;
585✔
1767
                                case 278:
1768
                                        cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1769
                                        return true;
585✔
1770
                                case 279:
1771
                                        cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
585✔
1772
                                        return true;
585✔
1773
                                case 284:
1774
                                        cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1775
                                        return true;
585✔
1776
                                case 285:
1777
                                        cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1778
                                        return true;
585✔
1779
                                case 286:
1780
                                        cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1781
                                        return true;
585✔
1782
                                case 287:
1783
                                        cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1784
                                        return true;
585✔
1785
                                case 288:
1786
                                        cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1787
                                        return true;
585✔
1788
                                case 289:
1789
                                        cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
585✔
1790
                                        return true;
585✔
1791
                                case 64:
1792
                                        cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1793
                                        return true;
585✔
1794
                                case 65:
1795
                                        cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1796
                                        return true;
585✔
1797
                                case 66:
1798
                                        cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1799
                                        return true;
585✔
1800
                                case 67:
1801
                                        cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1802
                                        return true;
585✔
1803
                                case 68:
1804
                                        cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1805
                                        return true;
585✔
1806
                                case 69:
1807
                                        cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
585✔
1808
                                        return true;
585✔
1809
                                default:
1810
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,438✔
1811
                        }
1812
                }
17,657✔
1813

1814
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1815
                {
18,444✔
1816
                        var tmp = template as CadMLeaderStyleTemplate;
18,444✔
1817

1818
                        switch (this._reader.Code)
18,444✔
1819
                        {
1820
                                case 179:
1821
                                        return true;
208✔
1822
                                case 340:
1823
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
402✔
1824
                                        return true;
402✔
1825
                                case 342:
1826
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
402✔
1827
                                        return true;
402✔
1828
                                default:
1829
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,432✔
1830
                        }
1831
                }
18,444✔
1832

1833
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1834
                {
2,316✔
1835
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
2,316✔
1836

1837
                        switch (this._reader.Code)
2,316✔
1838
                        {
1839
                                default:
1840
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
2,316✔
1841
                        }
1842
                }
2,316✔
1843

1844
                private bool readBlockElement(CadTemplate template, DxfMap map)
1845
                {
2,702✔
1846
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
2,702✔
1847

1848
                        switch (this._reader.Code)
2,702✔
1849
                        {
1850
                                default:
1851
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
2,702✔
1852
                                        {
2,316✔
1853
                                                return this.readEvaluationExpression(template, map);
2,316✔
1854
                                        }
1855
                                        return true;
386✔
1856
                        }
1857
                }
2,702✔
1858

1859
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1860
                {
3,281✔
1861
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,281✔
1862

1863
                        switch (this._reader.Code)
3,281✔
1864
                        {
1865
                                default:
1866
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,281✔
1867
                                        {
2,702✔
1868
                                                return this.readBlockElement(template, map);
2,702✔
1869
                                        }
1870
                                        return true;
579✔
1871
                        }
1872
                }
3,281✔
1873

1874
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1875
                {
4,246✔
1876
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1877

1878
                        switch (this._reader.Code)
4,246✔
1879
                        {
1880
                                default:
1881
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
1882
                                        {
3,281✔
1883
                                                return this.readBlockParameter(template, map);
3,281✔
1884
                                        }
1885
                                        return true;
965✔
1886
                        }
1887
                }
4,246✔
1888

1889
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
1890
                {
5,404✔
1891
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
1892

1893
                        switch (this._reader.Code)
5,404✔
1894
                        {
1895
                                case 92:
1896
                                        var stateCount = this._reader.ValueAsInt;
193✔
1897
                                        for (int i = 0; i < stateCount; i++)
1,930✔
1898
                                        {
772✔
1899
                                                this._reader.ReadNext();
772✔
1900
                                                tmp.StateTemplates.Add(this.readState());
772✔
1901
                                        }
772✔
1902
                                        return true;
193✔
1903
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
1904
                                        var entityCount = this._reader.ValueAsInt;
193✔
1905
                                        for (int i = 0; i < entityCount; i++)
778✔
1906
                                        {
196✔
1907
                                                this._reader.ReadNext();
196✔
1908
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
196✔
1909
                                        }
196✔
1910
                                        return true;
193✔
1911
                                default:
1912
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
1913
                                        {
4,246✔
1914
                                                return this.readBlock1PtParameter(template, map);
4,246✔
1915
                                        }
1916
                                        return true;
772✔
1917
                        }
1918
                }
5,404✔
1919

1920
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
1921
                {
772✔
1922
                        var state = new BlockVisibilityParameter.State();
772✔
1923
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
1924

1925
                        List<int> expectedCodes = new List<int>();
772✔
1926
                        expectedCodes.Add(303);
772✔
1927
                        expectedCodes.Add(94);
772✔
1928
                        expectedCodes.Add(95);
772✔
1929

1930
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
1931
                        {
2,316✔
1932
                                expectedCodes.Remove(this._reader.Code);
2,316✔
1933

1934
                                switch (this._reader.Code)
2,316!
1935
                                {
1936
                                        case 303:
1937
                                                state.Name = this._reader.ValueAsString;
772✔
1938
                                                break;
772✔
1939
                                        case 94:
1940
                                                var count = this._reader.ValueAsInt;
772✔
1941
                                                for (int i = 0; i < count; i++)
2,712✔
1942
                                                {
584✔
1943
                                                        this._reader.ReadNext();
584✔
1944
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
584✔
1945
                                                }
584✔
1946
                                                break;
772✔
1947
                                        case 95:
1948
                                                count = this._reader.ValueAsInt;
772✔
1949
                                                for (int i = 0; i < count; i++)
6,152✔
1950
                                                {
2,304✔
1951
                                                        this._reader.ReadNext();
2,304✔
1952
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
1953
                                                }
2,304✔
1954
                                                break;
772✔
1955
                                        default:
NEW
1956
                                                return template;
×
1957
                                }
1958

1959
                                if (!expectedCodes.Any())
2,316✔
1960
                                {
772✔
1961
                                        break;
772✔
1962
                                }
1963

1964
                                this._reader.ReadNext();
1,544✔
1965
                        }
1,544✔
1966

1967
                        return template;
772✔
1968
                }
772✔
1969

1970
                private bool readXRecord(CadTemplate template, DxfMap map)
1971
                {
113,152✔
1972
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,152✔
1973

1974
                        switch (this._reader.Code)
113,152✔
1975
                        {
1976
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,896✔
1977
                                        this.readXRecordEntries(tmp);
28,896✔
1978
                                        return true;
28,896✔
1979
                                default:
1980
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,256✔
1981
                        }
1982
                }
113,152✔
1983

1984
                private void readXRecordEntries(CadXRecordTemplate template)
1985
                {
28,896✔
1986
                        this._reader.ReadNext();
28,896✔
1987

1988
                        while (this._reader.DxfCode != DxfCode.Start)
2,408,845✔
1989
                        {
2,379,949✔
1990
                                switch (this._reader.GroupCodeValue)
2,379,949✔
1991
                                {
1992
                                        case GroupCodeValueType.Point3D:
1993
                                                var code = this._reader.Code;
2,884✔
1994
                                                var x = this._reader.ValueAsDouble;
2,884✔
1995
                                                this._reader.ReadNext();
2,884✔
1996
                                                var y = this._reader.ValueAsDouble;
2,884✔
1997
                                                this._reader.ReadNext();
2,884✔
1998
                                                var z = this._reader.ValueAsDouble;
2,884✔
1999
                                                XYZ pt = new XYZ(x, y, z);
2,884✔
2000
                                                template.CadObject.CreateEntry(code, pt);
2,884✔
2001
                                                break;
2,884✔
2002
                                        case GroupCodeValueType.Handle:
2003
                                        case GroupCodeValueType.ObjectId:
2004
                                        case GroupCodeValueType.ExtendedDataHandle:
2005
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,039✔
2006
                                                break;
12,039✔
2007
                                        default:
2008
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,026✔
2009
                                                break;
2,365,026✔
2010
                                }
2011

2012
                                this._reader.ReadNext();
2,379,949✔
2013
                        }
2,379,949✔
2014
                }
28,896✔
2015

2016
                private bool readBookColor(CadTemplate template, DxfMap map)
2017
                {
1,376✔
2018
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2019
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2020

2021
                        switch (this._reader.Code)
1,376✔
2022
                        {
2023
                                case 430:
2024
                                        color.Name = this._reader.ValueAsString;
160✔
2025
                                        return true;
160✔
2026
                                default:
2027
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2028
                        }
2029
                }
1,376✔
2030

2031
                private bool readDictionary(CadTemplate template, DxfMap map)
2032
                {
223,286✔
2033
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
223,286✔
2034
                        CadDictionary cadDictionary = tmp.CadObject;
223,286✔
2035

2036
                        switch (this._reader.Code)
223,286✔
2037
                        {
2038
                                case 280:
2039
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,018✔
2040
                                        return true;
15,018✔
2041
                                case 281:
2042
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,439✔
2043
                                        return true;
21,439✔
2044
                                case 3:
2045
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,127✔
2046
                                        return true;
57,127✔
2047
                                case 350: // Soft-owner ID/handle to entry object 
2048
                                case 360: // Hard-owner ID/handle to entry object
2049
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,127✔
2050
                                        return true;
57,127✔
2051
                                default:
2052
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,575✔
2053
                        }
2054
                }
223,286✔
2055

2056
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2057
                {
1,755✔
2058
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,755✔
2059

2060
                        switch (this._reader.Code)
1,755✔
2061
                        {
2062
                                case 340:
2063
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
195✔
2064
                                        return true;
195✔
2065
                                default:
2066
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,560!
2067
                                        {
1,560✔
2068
                                                return this.readDictionary(template, map);
1,560✔
2069
                                        }
2070
                                        return true;
×
2071
                        }
2072
                }
1,755✔
2073

2074
                private CadTemplate readSortentsTable()
2075
                {
576✔
2076
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2077
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2078

2079
                        //Jump the 0 marker
2080
                        this._reader.ReadNext();
576✔
2081

2082
                        this.readCommonObjectData(template);
576✔
2083

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

2086
                        //Jump the 100 marker
2087
                        this._reader.ReadNext();
576✔
2088

2089
                        (ulong?, ulong?) pair = (null, null);
576✔
2090

2091
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2092
                        {
3,648✔
2093
                                switch (this._reader.Code)
3,648!
2094
                                {
2095
                                        case 5:
2096
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2097
                                                break;
1,536✔
2098
                                        case 330:
2099
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2100
                                                break;
576✔
2101
                                        case 331:
2102
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2103
                                                break;
1,536✔
2104
                                        default:
2105
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2106
                                                break;
×
2107
                                }
2108

2109
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2110
                                {
1,536✔
2111
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2112
                                        pair = (null, null);
1,536✔
2113
                                }
1,536✔
2114

2115
                                this._reader.ReadNext();
3,648✔
2116
                        }
3,648✔
2117

2118
                        return template;
576✔
2119
                }
576✔
2120
        }
2121
}
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