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

DomCR / ACadSharp / 22042725382

15 Feb 2026 08:42PM UTC coverage: 77.217% (-0.2%) from 77.463%
22042725382

Pull #978

github

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

8154 of 11444 branches covered (71.25%)

Branch coverage included in aggregate %.

81 of 217 new or added lines in 13 files covered. (37.33%)

9 existing lines in 6 files now uncovered.

29510 of 37333 relevant lines covered (79.05%)

150816.78 hits per line

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

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

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

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

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

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

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

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

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

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

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

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

147
                                        this._reader.ReadNext();
4,055✔
148

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

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

162
                                        return unknownEntityTemplate;
4,055✔
163
                        }
164
                }
77,390✔
165

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

171
                        DxfMap map = DxfMap.Create<T>();
72,759✔
172

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

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

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

194
                        return template;
72,759✔
195
                }
72,759✔
196

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

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

NEW
210
                        switch (this._reader.Code)
×
211
                        {
212
                                //98 Length of format string
213
                                case 98:
NEW
214
                                        return true;
×
215
                                case 6:
216
                                case 7:
NEW
217
                                        this.readCadValue();
×
NEW
218
                                        return true;
×
219
                                case 331:
NEW
220
                                        tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
NEW
221
                                        return true;
×
222
                                case 360:
NEW
223
                                        tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
NEW
224
                                        return true;
×
225
                                default:
NEW
226
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
227
                        }
NEW
228
                }
×
229

230
                private void readCadValue()
NEW
231
                {
×
NEW
232
                        this._reader.ReadNext();
×
233

NEW
234
                        CadValue value = new();
×
NEW
235
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
×
236

NEW
237
                        while (this._reader.Code != 304)
×
NEW
238
                        {
×
NEW
239
                                switch (this._reader.Code)
×
240
                                {
241
                                        case 11:
242
                                        case 21:
243
                                        case 31:
244
                                                //Value as point
NEW
245
                                                break;
×
246
                                        case 91:
247
                                        case 92:
248
                                                //Value as int
NEW
249
                                                break;
×
250
                                        case 140:
251
                                                //Value as double
NEW
252
                                                break;
×
253
                                        case 310:
254
                                                //Value as byte array
NEW
255
                                                break;
×
256
                                        case 330:
NEW
257
                                                break;
×
258
                                        default:
NEW
259
                                                if (!this.tryAssignCurrentValue(value, map))
×
NEW
260
                                                {
×
NEW
261
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCadValue)} method.", NotificationType.None);
×
NEW
262
                                                }
×
NEW
263
                                                break;
×
264
                                }
265

NEW
266
                                this._reader.ReadNext();
×
NEW
267
                        }
×
NEW
268
                }
×
269

270
                private bool readProxyObject(CadTemplate template, DxfMap map)
271
                {
×
NEW
272
                        CadProxyObjectTemplate tmp = template as CadProxyObjectTemplate;
×
UNCOV
273
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
274

275
                        switch (this._reader.Code)
×
276
                        {
277
                                case 90:
278
                                case 94:
279
                                //Undocumented
280
                                case 97:
281
                                case 71:
282
                                        return true;
×
283
                                case 95:
284
                                        int format = this._reader.ValueAsInt;
×
285
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
286
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
287
                                        return true;
×
288
                                case 91:
289
                                        var classId = this._reader.ValueAsShort;
×
290
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
291
                                        {
×
292
                                                proxy.DxfClass = dxfClass;
×
293
                                        }
×
294
                                        return true;
×
295
                                case 161:
296
                                        return true;
×
297
                                case 162:
298
                                        return true;
×
299
                                case 310:
300
                                        if (proxy.BinaryData == null)
×
301
                                        {
×
302
                                                proxy.BinaryData = new MemoryStream();
×
303
                                        }
×
304
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
305
                                        return true;
×
306
                                case 311:
307
                                        if (proxy.Data == null)
×
308
                                        {
×
309
                                                proxy.Data = new MemoryStream();
×
310
                                        }
×
311
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
312
                                        return true;
×
313
                                case 330:
314
                                case 340:
315
                                case 350:
316
                                case 360:
NEW
317
                                        tmp.Entries.Add(this._reader.ValueAsHandle);
×
NEW
318
                                        return true;
×
319
                                default:
320
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
321
                        }
322
                }
×
323

324
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
325
                {
23,355✔
326
                        switch (this._reader.Code)
23,355✔
327
                        {
328
                                default:
329
                                        if (string.IsNullOrEmpty(this.currentSubclass))
23,355✔
330
                                        {
14,655✔
331
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
14,655✔
332
                                        }
333
                                        else
334
                                        {
8,700✔
335
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
8,700✔
336
                                        }
337
                        }
338
                }
23,355✔
339

340
                private bool readAnnotScaleObjectContextData(CadTemplate template, DxfMap map)
NEW
341
                {
×
NEW
342
                        var tmp = template as CadAnnotScaleObjectContextDataTemplate;
×
NEW
343
                        switch (this._reader.Code)
×
344
                        {
345
                                case 340:
NEW
346
                                        tmp.ScaleHandle = this._reader.ValueAsHandle;
×
NEW
347
                                        return true;
×
348
                                default:
NEW
349
                                        if (string.IsNullOrEmpty(this.currentSubclass))
×
NEW
350
                                        {
×
NEW
351
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
352
                                        }
353
                                        else
NEW
354
                                        {
×
NEW
355
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
356
                                        }
357
                        }
UNCOV
358
                }
×
359

360
                private bool readPlotSettings(CadTemplate template, DxfMap map)
361
                {
25,534✔
362
                        switch (this._reader.Code)
25,534✔
363
                        {
364
                                default:
365
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,534✔
366
                        }
367
                }
25,534✔
368

369
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
370
                {
3,096✔
371
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,096✔
372
                        EvaluationGraph evGraph = tmp.CadObject;
3,096✔
373

374
                        switch (this._reader.Code)
3,096✔
375
                        {
376
                                case 91:
377
                                        while (this._reader.Code == 91)
3,025✔
378
                                        {
2,574✔
379
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,574✔
380
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,574✔
381

382
                                                node.Index = this._reader.ValueAsInt;
2,574✔
383

384
                                                this._reader.ExpectedCode(93);
2,574✔
385
                                                node.Flags = this._reader.ValueAsInt;
2,574✔
386

387
                                                this._reader.ExpectedCode(95);
2,574✔
388
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,574✔
389

390
                                                this._reader.ExpectedCode(360);
2,574✔
391
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,574✔
392

393
                                                this._reader.ExpectedCode(92);
2,574✔
394
                                                node.Data1 = this._reader.ValueAsInt;
2,574✔
395
                                                this._reader.ExpectedCode(92);
2,574✔
396
                                                node.Data2 = this._reader.ValueAsInt;
2,574✔
397
                                                this._reader.ExpectedCode(92);
2,574✔
398
                                                node.Data3 = this._reader.ValueAsInt;
2,574✔
399
                                                this._reader.ExpectedCode(92);
2,574✔
400
                                                node.Data4 = this._reader.ValueAsInt;
2,574✔
401

402
                                                this._reader.ReadNext();
2,574✔
403

404
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
405
                                        }
2,574✔
406

407
                                        this.lockPointer = true;
451✔
408
                                        return true;
451✔
409
                                case 92:
410
                                        //Edges
411
                                        while (this._reader.Code == 92)
2,126✔
412
                                        {
1,931✔
413
                                                this._reader.ExpectedCode(93);
1,931✔
414
                                                this._reader.ExpectedCode(94);
1,931✔
415
                                                this._reader.ExpectedCode(91);
1,931✔
416
                                                this._reader.ExpectedCode(91);
1,931✔
417
                                                this._reader.ExpectedCode(92);
1,931✔
418
                                                this._reader.ExpectedCode(92);
1,931✔
419
                                                this._reader.ExpectedCode(92);
1,931✔
420
                                                this._reader.ExpectedCode(92);
1,931✔
421
                                                this._reader.ExpectedCode(92);
1,931✔
422

423
                                                this._reader.ReadNext();
1,931✔
424
                                        }
1,931✔
425

426
                                        this.lockPointer = true;
195✔
427
                                        return true;
195✔
428
                                default:
429
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,450✔
430
                        }
431
                }
3,096✔
432

433
                private bool readLayout(CadTemplate template, DxfMap map)
434
                {
51,979✔
435
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,979✔
436

437
                        switch (this._reader.Code)
51,979✔
438
                        {
439
                                case 330:
440
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,614✔
441
                                        return true;
1,614✔
442
                                case 331:
443
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
773✔
444
                                        return true;
773✔
445
                                default:
446
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,592✔
447
                                        {
25,534✔
448
                                                return this.readPlotSettings(template, map);
25,534✔
449
                                        }
450
                                        return true;
24,058✔
451
                        }
452
                }
51,979✔
453

454
                private bool readGroup(CadTemplate template, DxfMap map)
455
                {
4,992✔
456
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
457

458
                        switch (this._reader.Code)
4,992✔
459
                        {
460
                                case 70:
461
                                        return true;
384✔
462
                                case 340:
463
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
464
                                        return true;
2,304✔
465
                                default:
466
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
467
                        }
468
                }
4,992✔
469

470
                private bool readGeoData(CadTemplate template, DxfMap map)
471
                {
102✔
472
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
473

474
                        switch (this._reader.Code)
102✔
475
                        {
476
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
477
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
478
                                                tmp.CadObject.ReferencePoint.X,
1✔
479
                                                this._reader.ValueAsDouble,
1✔
480
                                                tmp.CadObject.ReferencePoint.Z
1✔
481
                                                );
1✔
482
                                        return true;
1✔
483
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
484
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
485
                                                this._reader.ValueAsDouble,
1✔
486
                                                tmp.CadObject.ReferencePoint.Y,
1✔
487
                                                tmp.CadObject.ReferencePoint.Z
1✔
488
                                                );
1✔
489
                                        return true;
1✔
490
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
491
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
492
                                                tmp.CadObject.ReferencePoint.X,
1✔
493
                                                tmp.CadObject.ReferencePoint.Y,
1✔
494
                                                this._reader.ValueAsDouble
1✔
495
                                                );
1✔
496
                                        return true;
1✔
497
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
498
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
499
                                        return true;
1✔
500
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
501
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
502
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
503
                                        return true;
1✔
504
                                // Number of Geo-Mesh points
505
                                case 93:
506
                                        var npts = this._reader.ValueAsInt;
3✔
507
                                        for (int i = 0; i < npts; i++)
54✔
508
                                        {
24✔
509
                                                this._reader.ReadNext();
24✔
510
                                                double sourceX = this._reader.ValueAsDouble;
24✔
511
                                                this._reader.ReadNext();
24✔
512
                                                double sourceY = this._reader.ValueAsDouble;
24✔
513

514
                                                this._reader.ReadNext();
24✔
515
                                                double destX = this._reader.ValueAsDouble;
24✔
516
                                                this._reader.ReadNext();
24✔
517
                                                double destY = this._reader.ValueAsDouble;
24✔
518

519
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
520
                                                {
24✔
521
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
522
                                                        Destination = new CSMath.XY(destX, destY)
24✔
523
                                                });
24✔
524
                                        }
24✔
525
                                        return true;
3✔
526
                                // Number of Geo-Mesh points
527
                                case 96:
528
                                        var nfaces = this._reader.ValueAsInt;
2✔
529
                                        for (int i = 0; i < nfaces; i++)
4!
530
                                        {
×
531
                                                this._reader.ReadNext();
×
532
                                                Debug.Assert(this._reader.Code == 97);
×
533
                                                int index1 = this._reader.ValueAsInt;
×
534
                                                this._reader.ReadNext();
×
535
                                                Debug.Assert(this._reader.Code == 98);
×
536
                                                int index2 = this._reader.ValueAsInt;
×
537
                                                this._reader.ReadNext();
×
538
                                                Debug.Assert(this._reader.Code == 99);
×
539
                                                int index3 = this._reader.ValueAsInt;
×
540

541
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
542
                                                {
×
543
                                                        Index1 = index1,
×
544
                                                        Index2 = index2,
×
545
                                                        Index3 = index3
×
546
                                                });
×
547
                                        }
×
548
                                        return true;
2✔
549
                                case 303:
550
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
551
                                        return true;
13✔
552
                                //Obsolete codes for version GeoDataVersion.R2009
553
                                case 3:
554
                                case 4:
555
                                case 14:
556
                                case 24:
557
                                case 15:
558
                                case 25:
559
                                case 43:
560
                                case 44:
561
                                case 45:
562
                                case 94:
563
                                case 293:
564
                                case 16:
565
                                case 26:
566
                                case 17:
567
                                case 27:
568
                                case 54:
569
                                case 140:
570
                                case 304:
571
                                case 292:
572
                                        return true;
19✔
573
                                default:
574
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
575
                        }
576
                }
102✔
577

578
                private bool readMaterial(CadTemplate template, DxfMap map)
579
                {
42,114✔
580
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,114✔
581
                        List<double> arr = null;
42,114✔
582

583
                        switch (this._reader.Code)
42,114!
584
                        {
585
                                case 43:
586
                                        arr = new();
1,349✔
587
                                        for (int i = 0; i < 16; i++)
45,866✔
588
                                        {
21,584✔
589
                                                Debug.Assert(this._reader.Code == 43);
21,584✔
590

591
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
592

593
                                                this._reader.ReadNext();
21,584✔
594
                                        }
21,584✔
595

596
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,349✔
597
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,349✔
598
                                case 47:
599
                                        arr = new();
×
600
                                        for (int i = 0; i < 16; i++)
×
601
                                        {
×
602
                                                Debug.Assert(this._reader.Code == 47);
×
603

604
                                                arr.Add(this._reader.ValueAsDouble);
×
605

606
                                                this._reader.ReadNext();
×
607
                                        }
×
608

609
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
610
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
611
                                case 49:
612
                                        arr = new();
197✔
613
                                        for (int i = 0; i < 16; i++)
6,698✔
614
                                        {
3,152✔
615
                                                Debug.Assert(this._reader.Code == 49);
3,152✔
616

617
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
618

619
                                                this._reader.ReadNext();
3,152✔
620
                                        }
3,152✔
621

622
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
623
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
624
                                case 142:
625
                                        arr = new();
197✔
626
                                        for (int i = 0; i < 16; i++)
6,698✔
627
                                        {
3,152✔
628
                                                Debug.Assert(this._reader.Code == 142);
3,152✔
629

630
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
631

632
                                                this._reader.ReadNext();
3,152✔
633
                                        }
3,152✔
634

635
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
636
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
637
                                case 144:
638
                                        arr = new();
1,157✔
639
                                        for (int i = 0; i < 16; i++)
39,338✔
640
                                        {
18,512✔
641
                                                Debug.Assert(this._reader.Code == 144);
18,512✔
642

643
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
644

645
                                                this._reader.ReadNext();
18,512✔
646
                                        }
18,512✔
647

648
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,157✔
649
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,157✔
650
                                case 147:
651
                                        arr = new();
×
652
                                        for (int i = 0; i < 16; i++)
×
653
                                        {
×
654
                                                Debug.Assert(this._reader.Code == 147);
×
655

656
                                                arr.Add(this._reader.ValueAsDouble);
×
657

658
                                                this._reader.ReadNext();
×
659
                                        }
×
660

661
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
662
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
663
                                default:
664
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,214✔
665
                        }
666
                }
42,114✔
667

668
                private bool readScale(CadTemplate template, DxfMap map)
669
                {
60,141✔
670
                        switch (this._reader.Code)
60,141✔
671
                        {
672
                                // Undocumented codes
673
                                case 70:
674
                                        //Always 0
675
                                        return true;
6,705✔
676
                                default:
677
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
53,436✔
678
                        }
679
                }
60,141✔
680

681
                private void readLinkedData(CadTemplate template, DxfMap map)
682
                {
320✔
683
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
684
                        LinkedData linkedData = tmp.CadObject;
320✔
685

686
                        this._reader.ReadNext();
320✔
687

688
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
689
                        {
640✔
690
                                switch (this._reader.Code)
640✔
691
                                {
692
                                        default:
693
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
694
                                                {
×
695
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
696
                                                }
×
697
                                                break;
640✔
698
                                }
699

700
                                this._reader.ReadNext();
640✔
701
                        }
640✔
702
                }
320✔
703

704
                private bool readTableContent(CadTemplate template, DxfMap map)
705
                {
2,368✔
706
                        switch (this._reader.Code)
2,368✔
707
                        {
708
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
709
                                        this.readTableContentSubclass(template, map);
256✔
710
                                        this.lockPointer = true;
256✔
711
                                        return true;
256✔
712
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
713
                                        this.readFormattedTableDataSubclass(template, map);
256✔
714
                                        this.lockPointer = true;
256✔
715
                                        return true;
256✔
716
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
717
                                        this.readLinkedTableDataSubclass(template, map);
320✔
718
                                        this.lockPointer = true;
320✔
719
                                        return true;
320✔
720
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
721
                                        this.readLinkedData(template, map);
320✔
722
                                        this.lockPointer = true;
320✔
723
                                        return true;
320✔
724
                                default:
725
                                        return false;
1,216✔
726
                        }
727
                }
2,368✔
728

729
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
730
                {
256✔
731
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
732
                        TableContent tableContent = tmp.CadObject;
256✔
733

734
                        this._reader.ReadNext();
256✔
735

736
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
737
                        {
256✔
738
                                switch (this._reader.Code)
256!
739
                                {
740
                                        case 340:
741
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
742
                                                break;
256✔
743
                                        default:
744
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
745
                                                {
×
746
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
747
                                                }
×
748
                                                break;
×
749
                                }
750

751
                                this._reader.ReadNext();
256✔
752
                        }
256✔
753
                }
256✔
754

755
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
756
                {
256✔
757
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
758
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
759

760
                        this._reader.ReadNext();
256✔
761

762
                        TableEntity.CellRange cellRange = null;
256✔
763
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
764
                        {
2,048✔
765
                                switch (this._reader.Code)
2,048!
766
                                {
767
                                        case 90:
768
                                                break;
256✔
769
                                        case 91:
770
                                                if (cellRange == null)
384✔
771
                                                {
384✔
772
                                                        cellRange = new();
384✔
773
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
774
                                                }
384✔
775
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
776
                                                break;
384✔
777
                                        case 92:
778
                                                if (cellRange == null)
384!
779
                                                {
×
780
                                                        cellRange = new();
×
781
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
782
                                                }
×
783
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
784
                                                break;
384✔
785
                                        case 93:
786
                                                if (cellRange == null)
384!
787
                                                {
×
788
                                                        cellRange = new();
×
789
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
790
                                                }
×
791
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
792
                                                break;
384✔
793
                                        case 94:
794
                                                if (cellRange == null)
384!
795
                                                {
×
796
                                                        cellRange = new();
×
797
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
798
                                                }
×
799
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
800
                                                cellRange = null;
384✔
801
                                                break;
384✔
802
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
803
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
804
                                                break;
256✔
805
                                        default:
806
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
807
                                                {
×
808
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
809
                                                }
×
810
                                                break;
×
811
                                }
812

813
                                this._reader.ReadNext();
2,048✔
814
                        }
2,048✔
815
                }
256✔
816

817
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
818
                {
320✔
819
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
820
                        TableContent tableContent = tmp.CadObject;
320✔
821

822
                        this._reader.ReadNext();
320✔
823

824
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
825
                        {
3,904✔
826
                                switch (this._reader.Code)
3,904✔
827
                                {
828
                                        case 90:
829
                                                //Column count
830
                                                break;
320✔
831
                                        case 91:
832
                                                //Row count
833
                                                break;
320✔
834
                                        //Unknown
835
                                        case 92:
836
                                                break;
256✔
837
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
838
                                                //Read Column
839
                                                this.readTableColumn();
1,216✔
840
                                                break;
1,216✔
841
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
842
                                                //Read Row
843
                                                this.readTableRow();
1,472✔
844
                                                break;
1,472✔
845
                                        default:
846
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
847
                                                {
320✔
848
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
849
                                                }
320✔
850
                                                break;
320✔
851
                                }
852

853
                                this._reader.ReadNext();
3,904✔
854
                        }
3,904✔
855
                }
320✔
856

857

858
                private TableEntity.Column readTableColumn()
859
                {
1,216✔
860
                        this._reader.ReadNext();
1,216✔
861

862
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
863

864
                        bool end = false;
1,216✔
865
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
866
                        {
3,648✔
867
                                switch (this._reader.Code)
3,648!
868
                                {
869
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
870
                                                this.readLinkedTableColumn(column);
1,216✔
871
                                                break;
1,216✔
872
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
873
                                                this.readFormattedTableColumn(column);
1,216✔
874
                                                break;
1,216✔
875
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
876
                                                this.readTableColumn(column);
1,216✔
877
                                                end = true;
1,216✔
878
                                                break;
1,216✔
879
                                        default:
880
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
881
                                                break;
×
882
                                }
883

884
                                if (end)
3,648✔
885
                                {
1,216✔
886
                                        return column;
1,216✔
887
                                }
888

889
                                this._reader.ReadNext();
2,432✔
890
                        }
2,432✔
891

892
                        return column;
×
893
                }
1,216✔
894

895
                private TableEntity.Row readTableRow()
896
                {
1,472✔
897
                        this._reader.ReadNext();
1,472✔
898

899
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
900

901
                        bool end = false;
1,472✔
902
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
903
                        {
11,840✔
904
                                switch (this._reader.Code)
11,840✔
905
                                {
906
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
907
                                                this.readLinkedTableRow(row);
1,536✔
908
                                                break;
1,536✔
909
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
910
                                                this.readFormattedTableRow(row);
1,408✔
911
                                                break;
1,408✔
912
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
913
                                                this.readTableRow(row);
1,408✔
914
                                                end = true;
1,408✔
915
                                                break;
1,408✔
916
                                        default:
917
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
918
                                                break;
7,488✔
919
                                }
920

921
                                if (end)
11,840✔
922
                                {
1,408✔
923
                                        return row;
1,408✔
924
                                }
925

926
                                this._reader.ReadNext();
10,432✔
927
                        }
10,432✔
928

929
                        return row;
64✔
930
                }
1,472✔
931

932
                private void readTableRow(TableEntity.Row row)
933
                {
1,408✔
934
                        this._reader.ReadNext();
1,408✔
935

936
                        bool end = false;
1,408✔
937
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
938
                        {
4,224✔
939
                                switch (this._reader.Code)
4,224!
940
                                {
941
                                        case 40:
942
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
943
                                                break;
1,408✔
944
                                        case 90:
945
                                                //styleID
946
                                                break;
1,408✔
947
                                        case 309:
948
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
949
                                                break;
1,408✔
950
                                        default:
951
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
952
                                                break;
×
953
                                }
954

955
                                if (end)
4,224✔
956
                                {
1,408✔
957
                                        break;
1,408✔
958
                                }
959

960
                                this._reader.ReadNext();
2,816✔
961
                        }
2,816✔
962
                }
1,408✔
963

964
                private void readFormattedTableRow(TableEntity.Row row)
965
                {
1,408✔
966
                        this._reader.ReadNext();
1,408✔
967

968
                        bool end = false;
1,408✔
969
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
970
                        {
4,224✔
971
                                switch (this._reader.Code)
4,224!
972
                                {
973
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
974
                                                break;
1,408✔
975
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
976
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
977
                                                break;
1,408✔
978
                                        case 309:
979
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
980
                                                break;
1,408✔
981
                                        default:
982
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
983
                                                break;
×
984
                                }
985

986
                                if (end)
4,224✔
987
                                {
1,408✔
988
                                        break;
1,408✔
989
                                }
990

991
                                this._reader.ReadNext();
2,816✔
992
                        }
2,816✔
993
                }
1,408✔
994

995
                private void readTableColumn(TableEntity.Column column)
996
                {
1,216✔
997
                        this._reader.ReadNext();
1,216✔
998

999
                        bool end = false;
1,216✔
1000
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1001
                        {
3,648✔
1002
                                switch (this._reader.Code)
3,648!
1003
                                {
1004
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1005
                                                break;
×
1006
                                        case 1:
1007
                                                end = true;
×
1008
                                                break;
×
1009
                                        case 40:
1010
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
1011
                                                break;
1,216✔
1012
                                        case 90:
1013
                                                //StyleId
1014
                                                break;
1,216✔
1015
                                        case 309:
1016
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
1017
                                                break;
1,216✔
1018
                                        default:
1019
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
1020
                                                break;
×
1021
                                }
1022

1023
                                if (end)
3,648✔
1024
                                {
1,216✔
1025
                                        break;
1,216✔
1026
                                }
1027

1028
                                this._reader.ReadNext();
2,432✔
1029
                        }
2,432✔
1030
                }
1,216✔
1031

1032
                private void readLinkedTableColumn(TableEntity.Column column)
1033
                {
1,216✔
1034
                        this._reader.ReadNext();
1,216✔
1035

1036
                        bool end = false;
1,216✔
1037
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
1038
                        {
4,864✔
1039
                                switch (this._reader.Code)
4,864!
1040
                                {
1041
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
1042
                                                break;
×
1043
                                        case 1:
1044
                                                end = true;
×
1045
                                                break;
×
1046
                                        case 91:
1047
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
1048
                                                break;
1,216✔
1049
                                        case 300:
1050
                                                column.Name = this._reader.ValueAsString;
1,216✔
1051
                                                break;
1,216✔
1052
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
1053
                                                this.readCustomData();
1,216✔
1054
                                                break;
1,216✔
1055
                                        case 309:
1056
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1057
                                                break;
1,216✔
1058
                                        default:
1059
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
1060
                                                break;
×
1061
                                }
1062

1063
                                if (end)
4,864✔
1064
                                {
1,216✔
1065
                                        break;
1,216✔
1066
                                }
1067

1068
                                this._reader.ReadNext();
3,648✔
1069
                        }
3,648✔
1070
                }
1,216✔
1071

1072
                private void readLinkedTableRow(TableEntity.Row row)
1073
                {
1,536✔
1074
                        this._reader.ReadNext();
1,536✔
1075

1076
                        bool end = false;
1,536✔
1077
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
1078
                        {
12,480✔
1079
                                switch (this._reader.Code)
12,480!
1080
                                {
1081
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
1082
                                                break;
×
1083
                                        case 90:
1084
                                                break;
1,536✔
1085
                                        case 91:
1086
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
1087
                                                break;
1,408✔
1088
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1089
                                                this.readCell();
5,376✔
1090
                                                break;
5,376✔
1091
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
1092
                                                this.readCustomData();
1,408✔
1093
                                                break;
1,408✔
1094
                                        case 309:
1095
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
1096
                                                break;
1,408✔
1097
                                        default:
1098
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
1099
                                                break;
1,344✔
1100
                                }
1101

1102
                                if (end)
12,480✔
1103
                                {
1,408✔
1104
                                        break;
1,408✔
1105
                                }
1106

1107
                                this._reader.ReadNext();
11,072✔
1108
                        }
11,072✔
1109
                }
1,536✔
1110

1111
                private TableEntity.Cell readCell()
1112
                {
5,376✔
1113
                        this._reader.ReadNext();
5,376✔
1114

1115
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
1116
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
1117

1118
                        bool end = false;
5,376✔
1119
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
1120
                        {
16,832✔
1121
                                switch (this._reader.Code)
16,832✔
1122
                                {
1123
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
1124
                                                this.readLinkedTableCell(cell);
5,376✔
1125
                                                break;
5,376✔
1126
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
1127
                                                this.readFormattedTableCell(cell);
5,248✔
1128
                                                break;
5,248✔
1129
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1130
                                                this.readTableCell(cell);
5,248✔
1131
                                                end = true;
5,248✔
1132
                                                break;
5,248✔
1133
                                        default:
1134
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1135
                                                break;
960✔
1136
                                }
1137

1138
                                if (end)
16,832✔
1139
                                {
5,248✔
1140
                                        return cell;
5,248✔
1141
                                }
1142

1143
                                this._reader.ReadNext();
11,584✔
1144
                        }
11,584✔
1145

1146
                        return cell;
128✔
1147
                }
5,376✔
1148

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

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

1155
                        bool end = false;
5,248✔
1156
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1157
                        {
16,384✔
1158
                                switch (this._reader.Code)
16,384✔
1159
                                {
1160
                                        //Unknown
1161
                                        case 40:
1162
                                        case 41:
1163
                                                break;
256✔
1164
                                        case 309:
1165
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1166
                                                break;
5,248✔
1167
                                        case 330:
1168
                                                //Unknown handle
1169
                                                break;
128✔
1170
                                        default:
1171
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1172
                                                {
×
1173
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1174
                                                }
×
1175
                                                break;
10,752✔
1176
                                }
1177

1178
                                if (end)
16,384✔
1179
                                {
5,248✔
1180
                                        break;
5,248✔
1181
                                }
1182

1183
                                this._reader.ReadNext();
11,136✔
1184
                        }
11,136✔
1185
                }
5,248✔
1186

1187
                private void readFormattedTableCell(TableEntity.Cell cell)
1188
                {
5,248✔
1189
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1190

1191
                        this._reader.ReadNext();
5,248✔
1192

1193
                        bool end = false;
5,248✔
1194
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1195
                        {
10,496✔
1196
                                switch (this._reader.Code)
10,496!
1197
                                {
1198
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1199
                                                this.readCellTableFormat(cell);
5,248✔
1200
                                                continue;
5,248✔
1201
                                        case 309:
1202
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1203
                                                break;
5,248✔
1204
                                        default:
1205
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1206
                                                {
×
1207
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1208
                                                }
×
1209
                                                break;
×
1210
                                }
1211

1212
                                if (end)
5,248!
1213
                                {
5,248✔
1214
                                        break;
5,248✔
1215
                                }
1216

1217
                                this._reader.ReadNext();
×
1218
                        }
×
1219
                }
5,248✔
1220

1221
                private void readCellTableFormat(TableEntity.Cell cell)
1222
                {
5,248✔
1223
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1224

1225
                        this._reader.ReadNext();
5,248✔
1226

1227
                        bool end = false;
5,248✔
1228
                        while (this._reader.Code == 1)
10,496✔
1229
                        {
5,248✔
1230
                                switch (this._reader.Code)
5,248!
1231
                                {
1232
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1233
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1234
                                                break;
5,248✔
1235
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1236
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1237
                                                break;
×
1238
                                        default:
1239
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1240
                                                {
×
1241
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1242
                                                }
×
1243
                                                break;
×
1244
                                }
1245

1246
                                if (end)
5,248!
1247
                                {
×
1248
                                        break;
×
1249
                                }
1250

1251
                                this._reader.ReadNext();
5,248✔
1252
                        }
5,248✔
1253
                }
5,248✔
1254

1255
                private void readCellStyle(CadCellStyleTemplate template)
1256
                {
×
1257
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1258

1259
                        this._reader.ReadNext();
×
1260

1261
                        bool end = false;
×
1262
                        while (this._reader.Code != 1)
×
1263
                        {
×
1264
                                switch (this._reader.Code)
×
1265
                                {
1266
                                        case 309:
1267
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1268
                                                break;
×
1269
                                        default:
1270
                                                //if (!this.tryAssignCurrentValue(cell, map))
1271
                                                {
×
1272
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1273
                                                }
×
1274
                                                break;
×
1275
                                }
1276

1277
                                if (end)
×
1278
                                {
×
1279
                                        break;
×
1280
                                }
1281

1282
                                this._reader.ReadNext();
×
1283
                        }
×
1284
                }
×
1285

1286
                private void readLinkedTableCell(TableEntity.Cell cell)
1287
                {
5,376✔
1288
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1289

1290
                        this._reader.ReadNext();
5,376✔
1291

1292
                        bool end = false;
5,376✔
1293
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1294
                        {
53,760✔
1295
                                switch (this._reader.Code)
53,760✔
1296
                                {
1297
                                        case 95:
1298
                                                //BL 95 Number of cell contents
1299
                                                break;
5,248✔
1300
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1301
                                                this.readCustomData();
5,376✔
1302
                                                break;
5,376✔
1303
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1304
                                                var c = this.readLinkedTableCellContent();
4,096✔
1305
                                                break;
4,096✔
1306
                                        case 309:
1307
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1308
                                                break;
5,248✔
1309
                                        default:
1310
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1311
                                                {
11,648✔
1312
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1313
                                                }
11,648✔
1314
                                                break;
33,792✔
1315
                                }
1316

1317
                                if (end)
53,760✔
1318
                                {
5,248✔
1319
                                        break;
5,248✔
1320
                                }
1321

1322
                                this._reader.ReadNext();
48,512✔
1323
                        }
48,512✔
1324
                }
5,376✔
1325

1326
                private CadTableCellContentTemplate readLinkedTableCellContent()
1327
                {
4,096✔
1328
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1329
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1330
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1331

1332
                        this._reader.ReadNext();
4,096✔
1333

1334
                        bool end = false;
4,096✔
1335
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1336
                        {
8,192✔
1337
                                switch (this._reader.Code)
8,192!
1338
                                {
1339
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1340
                                                readFormattedCellContent();
4,096✔
1341
                                                end = true;
4,096✔
1342
                                                break;
4,096✔
1343
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1344
                                                readCellContent(template);
4,096✔
1345
                                                break;
4,096✔
1346
                                        default:
1347
                                                if (!this.tryAssignCurrentValue(content, map))
×
1348
                                                {
×
1349
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1350
                                                }
×
1351
                                                break;
×
1352
                                }
1353

1354
                                if (end)
8,192✔
1355
                                {
4,096✔
1356
                                        break;
4,096✔
1357
                                }
1358

1359
                                this._reader.ReadNext();
4,096✔
1360
                        }
4,096✔
1361

1362
                        return template;
4,096✔
1363
                }
4,096✔
1364

1365
                private void readCellContent(CadTableCellContentTemplate template)
1366
                {
4,096✔
1367
                        TableEntity.CellContent content = template.Content;
4,096✔
1368
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1369

1370
                        this._reader.ReadNext();
4,096✔
1371

1372
                        bool end = false;
4,096✔
1373
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1374
                        {
16,384✔
1375
                                switch (this._reader.Code)
16,384✔
1376
                                {
1377
                                        case 91:
1378
                                                break;
4,096✔
1379
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1380
                                                this.readDataMapValue();
3,712✔
1381
                                                break;
3,712✔
1382
                                        case 309:
1383
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1384
                                                break;
4,096✔
1385
                                        case 340:
1386
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1387
                                                break;
384✔
1388
                                        default:
1389
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1390
                                                {
×
1391
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1392
                                                }
×
1393
                                                break;
4,096✔
1394
                                }
1395

1396
                                if (end)
16,384✔
1397
                                {
4,096✔
1398
                                        break;
4,096✔
1399
                                }
1400

1401
                                this._reader.ReadNext();
12,288✔
1402
                        }
12,288✔
1403
                }
4,096✔
1404

1405
                private void readFormattedCellContent()
1406
                {
4,096✔
1407
                        TableEntity.ContentFormat format = new();
4,096✔
1408
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1409
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1410

1411
                        this._reader.ReadNext();
4,096✔
1412

1413
                        bool end = false;
4,096✔
1414
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1415
                        {
12,288✔
1416
                                switch (this._reader.Code)
12,288✔
1417
                                {
1418
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1419
                                                readContentFormat(template);
4,096✔
1420
                                                break;
4,096✔
1421
                                        case 309:
1422
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1423
                                                break;
4,096✔
1424
                                        default:
1425
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1426
                                                {
×
1427
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1428
                                                }
×
1429
                                                break;
4,096✔
1430
                                }
1431

1432
                                if (end)
12,288✔
1433
                                {
4,096✔
1434
                                        break;
4,096✔
1435
                                }
1436

1437
                                this._reader.ReadNext();
8,192✔
1438
                        }
8,192✔
1439
                }
4,096✔
1440

1441
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1442
                {
9,600✔
1443
                        var format = template.Format;
9,600✔
1444
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1445

1446
                        this._reader.ReadNext();
9,600✔
1447

1448
                        bool end = false;
9,600✔
1449
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1450
                        {
124,800✔
1451
                                switch (this._reader.Code)
124,800✔
1452
                                {
1453
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1454
                                                break;
9,600✔
1455
                                        case 309:
1456
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1457
                                                break;
9,600✔
1458
                                        case 340:
1459
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1460
                                                break;
9,600✔
1461
                                        default:
1462
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1463
                                                {
×
1464
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1465
                                                }
×
1466
                                                break;
96,000✔
1467
                                }
1468

1469
                                if (end)
124,800✔
1470
                                {
9,600✔
1471
                                        break;
9,600✔
1472
                                }
1473

1474
                                this._reader.ReadNext();
115,200✔
1475
                        }
115,200✔
1476
                }
9,600✔
1477

1478
                private void readFormattedTableColumn(TableEntity.Column column)
1479
                {
1,216✔
1480
                        this._reader.ReadNext();
1,216✔
1481

1482
                        bool end = false;
1,216✔
1483
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1484
                        {
3,648✔
1485
                                switch (this._reader.Code)
3,648!
1486
                                {
1487
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1488
                                                break;
1,216✔
1489
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1490
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1491
                                                break;
1,216✔
1492
                                        case 309:
1493
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1494
                                                break;
1,216✔
1495
                                        default:
1496
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1497
                                                break;
×
1498
                                }
1499

1500
                                if (end)
3,648✔
1501
                                {
1,216✔
1502
                                        break;
1,216✔
1503
                                }
1504

1505
                                this._reader.ReadNext();
2,432✔
1506
                        }
2,432✔
1507
                }
1,216✔
1508

1509
                private void readStyleOverride(CadCellStyleTemplate template)
1510
                {
8,128✔
1511
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1512
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1513
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1514

1515
                        this._reader.ReadNext();
8,128✔
1516

1517
                        bool end = false;
8,128✔
1518
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1519
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1520
                        {
89,536✔
1521
                                switch (this._reader.Code)
89,536✔
1522
                                {
1523
                                        case 95:
1524
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1525
                                                break;
11,776✔
1526
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1527
                                                break;
256✔
1528
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1529
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1530
                                                break;
5,504✔
1531
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1532
                                                this.readCellMargin(template);
2,816✔
1533
                                                break;
2,816✔
1534
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1535
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1536
                                                this.readGridFormat(template, border);
11,776✔
1537
                                                break;
11,776✔
1538
                                        case 309:
1539
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1540
                                                break;
8,128✔
1541
                                        default:
1542
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
1543
                                                {
×
1544
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1545
                                                }
×
1546
                                                break;
49,280✔
1547
                                }
1548

1549
                                if (end)
89,536✔
1550
                                {
8,128✔
1551
                                        break;
8,128✔
1552
                                }
1553

1554
                                this._reader.ReadNext();
81,408✔
1555
                        }
81,408✔
1556
                }
8,128✔
1557

1558
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1559
                {
11,776✔
1560
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1561

1562
                        this._reader.ReadNext();
11,776✔
1563

1564
                        bool end = false;
11,776✔
1565
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1566
                        {
105,984✔
1567
                                switch (this._reader.Code)
105,984✔
1568
                                {
1569
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1570
                                                break;
11,776✔
1571
                                        case 62:
1572
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1573
                                                break;
11,776✔
1574
                                        case 92:
1575
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1576
                                                break;
11,776✔
1577
                                        case 93:
1578
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1579
                                                break;
11,776✔
1580
                                        case 340:
1581
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1582
                                                break;
11,776✔
1583
                                        case 309:
1584
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1585
                                                break;
11,776✔
1586
                                        default:
1587
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
1588
                                                {
×
1589
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1590
                                                }
×
1591
                                                break;
35,328✔
1592
                                }
1593

1594
                                if (end)
105,984✔
1595
                                {
11,776✔
1596
                                        break;
11,776✔
1597
                                }
1598

1599
                                this._reader.ReadNext();
94,208✔
1600
                        }
94,208✔
1601
                }
11,776✔
1602

1603
                private void readCellMargin(CadCellStyleTemplate template)
1604
                {
2,816✔
1605
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1606

1607
                        this._reader.ReadNext();
2,816✔
1608

1609
                        bool end = false;
2,816✔
1610
                        int i = 0;
2,816✔
1611
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1612
                        {
22,528✔
1613
                                switch (this._reader.Code)
22,528!
1614
                                {
1615
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1616
                                                break;
2,816✔
1617
                                        case 40:
1618
                                                switch (i)
16,896✔
1619
                                                {
1620
                                                        case 0:
1621
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1622
                                                                break;
2,816✔
1623
                                                        case 1:
1624
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1625
                                                                break;
2,816✔
1626
                                                        case 2:
1627
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1628
                                                                break;
2,816✔
1629
                                                        case 3:
1630
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1631
                                                                break;
2,816✔
1632
                                                        case 4:
1633
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1634
                                                                break;
2,816✔
1635
                                                        case 5:
1636
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1637
                                                                break;
2,816✔
1638
                                                }
1639

1640
                                                i++;
16,896✔
1641
                                                break;
16,896✔
1642
                                        case 309:
1643
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1644
                                                break;
2,816✔
1645
                                        default:
1646
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1647
                                                break;
×
1648
                                }
1649

1650
                                if (end)
22,528✔
1651
                                {
2,816✔
1652
                                        break;
2,816✔
1653
                                }
1654

1655
                                this._reader.ReadNext();
19,712✔
1656
                        }
19,712✔
1657
                }
2,816✔
1658

1659
                private void readCustomData()
1660
                {
8,000✔
1661
                        this._reader.ReadNext();
8,000✔
1662

1663
                        int ndata = 0;
8,000✔
1664
                        bool end = false;
8,000✔
1665
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1666
                        {
74,304✔
1667
                                switch (this._reader.Code)
74,304✔
1668
                                {
1669
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1670
                                                break;
8,000✔
1671
                                        case 90:
1672
                                                ndata = this._reader.ValueAsInt;
8,128✔
1673
                                                break;
8,128✔
1674
                                        case 300:
1675
                                                //Name
1676
                                                break;
5,248✔
1677
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1678
                                                this.readDataMapValue();
5,248✔
1679
                                                break;
5,248✔
1680
                                        case 309:
1681
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1682
                                                break;
7,872✔
1683
                                        default:
1684
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1685
                                                break;
39,808✔
1686
                                }
1687

1688
                                if (end)
74,304✔
1689
                                {
7,872✔
1690
                                        break;
7,872✔
1691
                                }
1692

1693
                                this._reader.ReadNext();
66,432✔
1694
                        }
66,432✔
1695
                }
8,000✔
1696

1697
                private void readDataMapValue()
1698
                {
8,960✔
1699
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1700
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1701

1702
                        this._reader.ReadNext();
8,960✔
1703

1704
                        bool end = false;
8,960✔
1705
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1706
                        {
330,112✔
1707
                                switch (this._reader.Code)
330,112✔
1708
                                {
1709
                                        case 11:
1710
                                        case 21:
1711
                                        case 31:
1712
                                                //Value as point
1713
                                                break;
768✔
1714
                                        case 91:
1715
                                        case 92:
1716
                                                //Value as int
1717
                                                break;
38,912✔
1718
                                        case 140:
1719
                                                //Value as double
1720
                                                break;
13,248✔
1721
                                        case 310:
1722
                                                //Value as byte array
1723
                                                break;
256✔
1724
                                        case 304:
1725
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1726
                                                break;
8,832✔
1727
                                        default:
1728
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1729
                                                {
106,880✔
1730
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1731
                                                }
106,880✔
1732
                                                break;
268,096✔
1733
                                }
1734

1735
                                if (end)
330,112✔
1736
                                {
8,832✔
1737
                                        break;
8,832✔
1738
                                }
1739

1740
                                this._reader.ReadNext();
321,280✔
1741
                        }
321,280✔
1742
                }
8,960✔
1743

1744
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1745
                {
379,506✔
1746
                        switch (this._reader.Code)
379,506✔
1747
                        {
1748
                                // Undocumented codes
1749
                                case 176:
1750
                                case 177:
1751
                                case 420:
1752
                                        return true;
123,592✔
1753
                                default:
1754
                                        //Avoid noise while is not implemented
1755
                                        return true;
255,914✔
1756
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1757
                        }
1758
                }
379,506✔
1759

1760
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1761
                {
4,032✔
1762
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1763
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1764

1765
                        switch (this._reader.Code)
4,032✔
1766
                        {
1767
                                case 10:
1768
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1769
                                        return true;
384✔
1770
                                case 20:
1771
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1772
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1773
                                        return true;
384✔
1774
                                case 40:
1775
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1776
                                        {
×
1777
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1778
                                                tmp.HasFrontPlane = true;
×
1779
                                        }
×
1780

1781
                                        double[] array = new double[16]
384✔
1782
                                        {
384✔
1783
                                                0.0, 0.0, 0.0, 0.0,
384✔
1784
                                                0.0, 0.0, 0.0, 0.0,
384✔
1785
                                                0.0, 0.0, 0.0, 0.0,
384✔
1786
                                                0.0, 0.0, 0.0, 1.0
384✔
1787
                                        };
384✔
1788

1789
                                        for (int i = 0; i < 12; i++)
9,984✔
1790
                                        {
4,608✔
1791
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1792

1793
                                                if (i < 11)
4,608✔
1794
                                                {
4,224✔
1795
                                                        this._reader.ReadNext();
4,224✔
1796
                                                }
4,224✔
1797
                                        }
4,608✔
1798

1799
                                        if (tmp.InsertTransformRead)
384!
1800
                                        {
×
1801
                                                filter.InsertTransform = new Matrix4(array);
×
1802
                                                tmp.InsertTransformRead = true;
×
1803
                                        }
×
1804
                                        else
1805
                                        {
384✔
1806
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1807
                                        }
384✔
1808

1809
                                        return true;
384✔
1810
                                case 73:
1811
                                default:
1812
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1813
                        }
1814
                }
4,032✔
1815

1816
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1817
                {
3,529✔
1818
                        var tmp = template as CadMLineStyleTemplate;
3,529✔
1819
                        var mLineStyle = template.CadObject as MLineStyle;
3,529✔
1820

1821
                        switch (this._reader.Code)
3,529✔
1822
                        {
1823
                                case 6:
1824
                                        var t = tmp.ElementTemplates.LastOrDefault();
418✔
1825
                                        if (t == null)
418!
1826
                                        {
×
1827
                                                return true;
×
1828
                                        }
1829
                                        t.LineTypeName = this._reader.ValueAsString;
418✔
1830
                                        return true;
418✔
1831
                                case 49:
1832
                                        MLineStyle.Element element = new MLineStyle.Element();
418✔
1833
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
418✔
1834
                                        element.Offset = this._reader.ValueAsDouble;
418✔
1835

1836
                                        tmp.ElementTemplates.Add(elementTemplate);
418✔
1837
                                        mLineStyle.AddElement(element);
418✔
1838
                                        return true;
418✔
1839
                                default:
1840
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,693✔
1841
                        }
1842
                }
3,529✔
1843

1844
                private bool readTableStyle(CadTemplate template, DxfMap map)
1845
                {
17,845✔
1846
                        var tmp = template as CadTableStyleTemplate;
17,845✔
1847
                        var style = tmp.CadObject;
17,845✔
1848
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,845✔
1849

1850
                        switch (this._reader.Code)
17,845!
1851
                        {
1852
                                case 7:
1853
                                        tmp.CreateCurrentCellStyleTemplate();
591✔
1854
                                        tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
591✔
1855
                                        return true;
591✔
1856
                                case 94:
1857
                                        cellStyle.Alignment = this._reader.ValueAsInt;
×
1858
                                        return true;
×
1859
                                case 62:
1860
                                        cellStyle.Color = new Color(this._reader.ValueAsShort);
591✔
1861
                                        return true;
591✔
1862
                                case 63:
1863
                                        cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
591✔
1864
                                        return true;
591✔
1865
                                case 140:
1866
                                        cellStyle.TextHeight = this._reader.ValueAsDouble;
591✔
1867
                                        return true;
591✔
1868
                                case 170:
1869
                                        cellStyle.CellAlignment = (TableEntity.Cell.CellAlignmentType)this._reader.ValueAsShort;
591✔
1870
                                        return true;
591✔
1871
                                case 283:
1872
                                        cellStyle.IsFillColorOn = this._reader.ValueAsBool;
591✔
1873
                                        return true;
591✔
1874
                                case 90:
1875
                                        cellStyle.Type = (TableEntity.CellStyleType)this._reader.ValueAsShort;
399✔
1876
                                        return true;
399✔
1877
                                case 91:
1878
                                        cellStyle.StyleClass = (TableEntity.CellStyleClass)this._reader.ValueAsShort;
399✔
1879
                                        return true;
399✔
1880
                                case 1:
1881
                                        //Undocumented
1882
                                        return true;
399✔
1883
                                case 274:
1884
                                        cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1885
                                        return true;
591✔
1886
                                case 275:
1887
                                        cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1888
                                        return true;
591✔
1889
                                case 276:
1890
                                        cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1891
                                        return true;
591✔
1892
                                case 277:
1893
                                        cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1894
                                        return true;
591✔
1895
                                case 278:
1896
                                        cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1897
                                        return true;
591✔
1898
                                case 279:
1899
                                        cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1900
                                        return true;
591✔
1901
                                case 284:
1902
                                        cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1903
                                        return true;
591✔
1904
                                case 285:
1905
                                        cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1906
                                        return true;
591✔
1907
                                case 286:
1908
                                        cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1909
                                        return true;
591✔
1910
                                case 287:
1911
                                        cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1912
                                        return true;
591✔
1913
                                case 288:
1914
                                        cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1915
                                        return true;
591✔
1916
                                case 289:
1917
                                        cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1918
                                        return true;
591✔
1919
                                case 64:
1920
                                        cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1921
                                        return true;
591✔
1922
                                case 65:
1923
                                        cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1924
                                        return true;
591✔
1925
                                case 66:
1926
                                        cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1927
                                        return true;
591✔
1928
                                case 67:
1929
                                        cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1930
                                        return true;
591✔
1931
                                case 68:
1932
                                        cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1933
                                        return true;
591✔
1934
                                case 69:
1935
                                        cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1936
                                        return true;
591✔
1937
                                default:
1938
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,464✔
1939
                        }
1940
                }
17,845✔
1941

1942
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1943
                {
18,636✔
1944
                        var tmp = template as CadMLeaderStyleTemplate;
18,636✔
1945

1946
                        switch (this._reader.Code)
18,636✔
1947
                        {
1948
                                case 179:
1949
                                        return true;
212✔
1950
                                case 340:
1951
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
406✔
1952
                                        return true;
406✔
1953
                                case 342:
1954
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
406✔
1955
                                        return true;
406✔
1956
                                default:
1957
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,612✔
1958
                        }
1959
                }
18,636✔
1960

1961
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1962
                {
13,737✔
1963
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,737✔
1964

1965
                        switch (this._reader.Code)
13,737✔
1966
                        {
1967
                                case 1:
1968
                                        this._reader.ExpectedCode(70);
1,158✔
1969
                                        this._reader.ExpectedCode(140);
1,158✔
1970
                                        return true;
1,158✔
1971
                                default:
1972
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,579✔
1973
                        }
1974
                }
13,737✔
1975

1976
                private bool readBlockElement(CadTemplate template, DxfMap map)
1977
                {
5,249✔
1978
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,249✔
1979

1980
                        switch (this._reader.Code)
5,249✔
1981
                        {
1982
                                default:
1983
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,249✔
1984
                                        {
4,473✔
1985
                                                return this.readEvaluationExpression(template, map);
4,473✔
1986
                                        }
1987
                                        return true;
776✔
1988
                        }
1989
                }
5,249✔
1990

1991
                private bool readBlockAction(CadTemplate template, DxfMap map)
1992
                {
20✔
1993
                        CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
20✔
1994

1995
                        switch (this._reader.Code)
20✔
1996
                        {
1997
                                default:
1998
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
20✔
1999
                                        {
15✔
2000
                                                return this.readBlockElement(template, map);
15✔
2001
                                        }
2002
                                        return true;
5✔
2003
                        }
2004
                }
20✔
2005

2006
                private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
2007
                {
31✔
2008
                        CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
31✔
2009

2010
                        switch (this._reader.Code)
31✔
2011
                        {
2012
                                default:
2013
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
31✔
2014
                                        {
20✔
2015
                                                return this.readBlockAction(template, map);
20✔
2016
                                        }
2017
                                        return true;
11✔
2018
                        }
2019
                }
31✔
2020

2021
                private bool readBlockRotationAction(CadTemplate template, DxfMap map)
2022
                {
33✔
2023
                        CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
33✔
2024

2025
                        switch (this._reader.Code)
33✔
2026
                        {
2027
                                default:
2028
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
33✔
2029
                                        {
31✔
2030
                                                return this.readBlockActionBasePt(template, map);
31✔
2031
                                        }
2032
                                        return true;
2✔
2033
                        }
2034
                }
33✔
2035

2036
                private bool readBlockParameter(CadTemplate template, DxfMap map)
2037
                {
3,291✔
2038
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,291✔
2039

2040
                        switch (this._reader.Code)
3,291✔
2041
                        {
2042
                                default:
2043
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,291✔
2044
                                        {
2,712✔
2045
                                                return this.readBlockElement(template, map);
2,712✔
2046
                                        }
2047
                                        return true;
579✔
2048
                        }
2049
                }
3,291✔
2050

2051
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
2052
                {
4,246✔
2053
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
2054

2055
                        switch (this._reader.Code)
4,246✔
2056
                        {
2057
                                default:
2058
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
2059
                                        {
3,281✔
2060
                                                return this.readBlockParameter(template, map);
3,281✔
2061
                                        }
2062
                                        return true;
965✔
2063
                        }
2064
                }
4,246✔
2065

2066
                private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
2067
                {
14✔
2068
                        var tmp = template as CadBlock2PtParameterTemplate;
14✔
2069

2070
                        switch (this._reader.Code)
14✔
2071
                        {
2072
                                //Stores always 4 entries using this code
2073
                                case 91:
2074
                                        return true;
4✔
2075
                                default:
2076
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
10!
2077
                                        {
10✔
2078
                                                return this.readBlockParameter(template, map);
10✔
2079
                                        }
2080
                                        return true;
×
2081
                        }
2082
                }
14✔
2083

2084
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
2085
                {
5,404✔
2086
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
2087

2088
                        switch (this._reader.Code)
5,404✔
2089
                        {
2090
                                case 92:
2091
                                        var stateCount = this._reader.ValueAsInt;
193✔
2092
                                        for (int i = 0; i < stateCount; i++)
1,930✔
2093
                                        {
772✔
2094
                                                this._reader.ReadNext();
772✔
2095
                                                tmp.StateTemplates.Add(this.readState());
772✔
2096
                                        }
772✔
2097
                                        return true;
193✔
2098
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
2099
                                        var entityCount = this._reader.ValueAsInt;
193✔
2100
                                        for (int i = 0; i < entityCount; i++)
780✔
2101
                                        {
197✔
2102
                                                this._reader.ReadNext();
197✔
2103
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
197✔
2104
                                        }
197✔
2105
                                        return true;
193✔
2106
                                default:
2107
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
2108
                                        {
4,246✔
2109
                                                return this.readBlock1PtParameter(template, map);
4,246✔
2110
                                        }
2111
                                        return true;
772✔
2112
                        }
2113
                }
5,404✔
2114

2115
                private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2116
                {
49✔
2117
                        var tmp = template as CadBlockRotationParameterTemplate;
49✔
2118

2119
                        switch (this._reader.Code)
49✔
2120
                        {
2121
                                default:
2122
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
49✔
2123
                                        {
14✔
2124
                                                return this.readBlock2PtParameter(template, map);
14✔
2125
                                        }
2126
                                        return true;
35✔
2127
                        }
2128
                }
49✔
2129

2130
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2131
                {
772✔
2132
                        var state = new BlockVisibilityParameter.State();
772✔
2133
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
2134

2135
                        List<int> expectedCodes = new List<int>();
772✔
2136
                        expectedCodes.Add(303);
772✔
2137
                        expectedCodes.Add(94);
772✔
2138
                        expectedCodes.Add(95);
772✔
2139

2140
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
2141
                        {
2,316✔
2142
                                expectedCodes.Remove(this._reader.Code);
2,316✔
2143

2144
                                switch (this._reader.Code)
2,316!
2145
                                {
2146
                                        case 303:
2147
                                                state.Name = this._reader.ValueAsString;
772✔
2148
                                                break;
772✔
2149
                                        case 94:
2150
                                                var count = this._reader.ValueAsInt;
772✔
2151
                                                for (int i = 0; i < count; i++)
2,720✔
2152
                                                {
588✔
2153
                                                        this._reader.ReadNext();
588✔
2154
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
2155
                                                }
588✔
2156
                                                break;
772✔
2157
                                        case 95:
2158
                                                count = this._reader.ValueAsInt;
772✔
2159
                                                for (int i = 0; i < count; i++)
6,152✔
2160
                                                {
2,304✔
2161
                                                        this._reader.ReadNext();
2,304✔
2162
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2163
                                                }
2,304✔
2164
                                                break;
772✔
2165
                                        default:
2166
                                                return template;
×
2167
                                }
2168

2169
                                if (!expectedCodes.Any())
2,316✔
2170
                                {
772✔
2171
                                        break;
772✔
2172
                                }
2173

2174
                                this._reader.ReadNext();
1,544✔
2175
                        }
1,544✔
2176

2177
                        return template;
772✔
2178
                }
772✔
2179

2180
                private bool readBlockGrip(CadTemplate template, DxfMap map)
2181
                {
3,880✔
2182
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,880✔
2183

2184
                        switch (this._reader.Code)
3,880✔
2185
                        {
2186
                                default:
2187
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,880✔
2188
                                        {
2,522✔
2189
                                                return this.readBlockElement(template, map);
2,522✔
2190
                                        }
2191
                                        return true;
1,358✔
2192
                        }
2193
                }
3,880✔
2194

2195
                private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
2196
                {
20✔
2197
                        CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
20✔
2198

2199
                        switch (this._reader.Code)
20✔
2200
                        {
2201
                                default:
2202
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
20!
2203
                                        {
20✔
2204
                                                return this.readBlockGrip(template, map);
20✔
2205
                                        }
2206
                                        return true;
×
2207
                        }
2208
                }
20✔
2209

2210
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
2211
                {
3,860✔
2212
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2213

2214
                        switch (this._reader.Code)
3,860✔
2215
                        {
2216
                                default:
2217
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2218
                                        {
3,860✔
2219
                                                return this.readBlockGrip(template, map);
3,860✔
2220
                                        }
2221
                                        return true;
×
2222
                        }
2223
                }
3,860✔
2224

2225
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2226
                {
1,590✔
2227
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,590✔
2228

2229
                        switch (this._reader.Code)
1,590✔
2230
                        {
2231
                                case 340:
2232
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
265✔
2233
                                        return true;
265✔
2234
                                default:
2235
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,325✔
2236
                        }
2237
                }
1,590✔
2238

2239
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2240
                {
11,580✔
2241
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,580✔
2242

2243
                        switch (this._reader.Code)
11,580✔
2244
                        {
2245
                                default:
2246
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,580✔
2247
                                        {
9,264✔
2248
                                                return this.readEvaluationExpression(template, map);
9,264✔
2249
                                        }
2250
                                        return true;
2,316✔
2251
                        }
2252
                }
11,580✔
2253

2254
                private bool readXRecord(CadTemplate template, DxfMap map)
2255
                {
113,272✔
2256
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,272✔
2257

2258
                        switch (this._reader.Code)
113,272✔
2259
                        {
2260
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,926✔
2261
                                        this.readXRecordEntries(tmp);
28,926✔
2262
                                        return true;
28,926✔
2263
                                default:
2264
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,346✔
2265
                        }
2266
                }
113,272✔
2267

2268
                private void readXRecordEntries(CadXRecordTemplate template)
2269
                {
28,926✔
2270
                        this._reader.ReadNext();
28,926✔
2271

2272
                        while (this._reader.DxfCode != DxfCode.Start)
2,409,286✔
2273
                        {
2,380,360✔
2274
                                switch (this._reader.GroupCodeValue)
2,380,360✔
2275
                                {
2276
                                        case GroupCodeValueType.Point3D:
2277
                                                var code = this._reader.Code;
2,901✔
2278
                                                var x = this._reader.ValueAsDouble;
2,901✔
2279
                                                this._reader.ReadNext();
2,901✔
2280
                                                var y = this._reader.ValueAsDouble;
2,901✔
2281
                                                this._reader.ReadNext();
2,901✔
2282
                                                var z = this._reader.ValueAsDouble;
2,901✔
2283
                                                XYZ pt = new XYZ(x, y, z);
2,901✔
2284
                                                template.CadObject.CreateEntry(code, pt);
2,901✔
2285
                                                break;
2,901✔
2286
                                        case GroupCodeValueType.Handle:
2287
                                        case GroupCodeValueType.ObjectId:
2288
                                        case GroupCodeValueType.ExtendedDataHandle:
2289
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,041✔
2290
                                                break;
12,041✔
2291
                                        default:
2292
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,418✔
2293
                                                break;
2,365,418✔
2294
                                }
2295

2296
                                this._reader.ReadNext();
2,380,360✔
2297
                        }
2,380,360✔
2298
                }
28,926✔
2299

2300
                private bool readBookColor(CadTemplate template, DxfMap map)
2301
                {
1,376✔
2302
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2303
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2304

2305
                        switch (this._reader.Code)
1,376✔
2306
                        {
2307
                                case 430:
2308
                                        color.Name = this._reader.ValueAsString;
160✔
2309
                                        return true;
160✔
2310
                                default:
2311
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2312
                        }
2313
                }
1,376✔
2314

2315
                private bool readDictionary(CadTemplate template, DxfMap map)
2316
                {
224,204✔
2317
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
224,204✔
2318
                        CadDictionary cadDictionary = tmp.CadObject;
224,204✔
2319

2320
                        switch (this._reader.Code)
224,204✔
2321
                        {
2322
                                case 280:
2323
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,069✔
2324
                                        return true;
15,069✔
2325
                                case 281:
2326
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,522✔
2327
                                        return true;
21,522✔
2328
                                case 3:
2329
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,371✔
2330
                                        return true;
57,371✔
2331
                                case 350: // Soft-owner ID/handle to entry object 
2332
                                case 360: // Hard-owner ID/handle to entry object
2333
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,371✔
2334
                                        return true;
57,371✔
2335
                                default:
2336
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,871✔
2337
                        }
2338
                }
224,204✔
2339

2340
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2341
                {
1,773✔
2342
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,773✔
2343

2344
                        switch (this._reader.Code)
1,773✔
2345
                        {
2346
                                case 340:
2347
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
197✔
2348
                                        return true;
197✔
2349
                                default:
2350
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,576!
2351
                                        {
1,576✔
2352
                                                return this.readDictionary(template, map);
1,576✔
2353
                                        }
2354
                                        return true;
×
2355
                        }
2356
                }
1,773✔
2357

2358
                private CadTemplate readSortentsTable()
2359
                {
576✔
2360
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2361
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2362

2363
                        //Jump the 0 marker
2364
                        this._reader.ReadNext();
576✔
2365

2366
                        this.readCommonObjectData(template);
576✔
2367

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

2370
                        //Jump the 100 marker
2371
                        this._reader.ReadNext();
576✔
2372

2373
                        (ulong?, ulong?) pair = (null, null);
576✔
2374

2375
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2376
                        {
3,648✔
2377
                                switch (this._reader.Code)
3,648!
2378
                                {
2379
                                        case 5:
2380
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2381
                                                break;
1,536✔
2382
                                        case 330:
2383
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2384
                                                break;
576✔
2385
                                        case 331:
2386
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2387
                                                break;
1,536✔
2388
                                        default:
2389
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2390
                                                break;
×
2391
                                }
2392

2393
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2394
                                {
1,536✔
2395
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2396
                                        pair = (null, null);
1,536✔
2397
                                }
1,536✔
2398

2399
                                this._reader.ReadNext();
3,648✔
2400
                        }
3,648✔
2401

2402
                        return template;
576✔
2403
                }
576✔
2404
        }
2405
}
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