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

DomCR / ACadSharp / 22056180537

16 Feb 2026 08:56AM UTC coverage: 77.283% (-0.3%) from 77.593%
22056180537

Pull #978

github

web-flow
Merge a338464f1 into ae77202b7
Pull Request #978: issue-976 context data

8169 of 11454 branches covered (71.32%)

Branch coverage included in aggregate %.

87 of 256 new or added lines in 16 files covered. (33.98%)

13 existing lines in 5 files now uncovered.

29543 of 37343 relevant lines covered (79.11%)

150779.69 hits per line

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

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

149
                                        this._reader.ReadNext();
4,055✔
150

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

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

164
                                        return unknownEntityTemplate;
4,055✔
165
                        }
166
                }
77,390✔
167

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

173
                        DxfMap map = DxfMap.Create<T>();
72,759✔
174

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

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

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

196
                        return template;
72,759✔
197
                }
72,759✔
198

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

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

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

232
                private void readCadValue()
NEW
233
                {
×
NEW
234
                        this._reader.ReadNext();
×
235

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

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

NEW
268
                                this._reader.ReadNext();
×
NEW
269
                        }
×
NEW
270
                }
×
271

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

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

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

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

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

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

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

384
                                                node.Index = this._reader.ValueAsInt;
2,574✔
385

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

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

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

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

404
                                                this._reader.ReadNext();
2,574✔
405

406
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
407
                                        }
2,574✔
408

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

425
                                                this._reader.ReadNext();
1,931✔
426
                                        }
1,931✔
427

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

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

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

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

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

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

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

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

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

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

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

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

593
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
594

595
                                                this._reader.ReadNext();
21,584✔
596
                                        }
21,584✔
597

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

606
                                                arr.Add(this._reader.ValueAsDouble);
×
607

608
                                                this._reader.ReadNext();
×
609
                                        }
×
610

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

619
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
620

621
                                                this._reader.ReadNext();
3,152✔
622
                                        }
3,152✔
623

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

632
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
633

634
                                                this._reader.ReadNext();
3,152✔
635
                                        }
3,152✔
636

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

645
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
646

647
                                                this._reader.ReadNext();
18,512✔
648
                                        }
18,512✔
649

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

658
                                                arr.Add(this._reader.ValueAsDouble);
×
659

660
                                                this._reader.ReadNext();
×
661
                                        }
×
662

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

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

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

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

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

702
                                this._reader.ReadNext();
640✔
703
                        }
640✔
704
                }
320✔
705

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

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

736
                        this._reader.ReadNext();
256✔
737

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

753
                                this._reader.ReadNext();
256✔
754
                        }
256✔
755
                }
256✔
756

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

762
                        this._reader.ReadNext();
256✔
763

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

815
                                this._reader.ReadNext();
2,048✔
816
                        }
2,048✔
817
                }
256✔
818

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

824
                        this._reader.ReadNext();
320✔
825

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

855
                                this._reader.ReadNext();
3,904✔
856
                        }
3,904✔
857
                }
320✔
858

859

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

864
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
865

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

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

891
                                this._reader.ReadNext();
2,432✔
892
                        }
2,432✔
893

894
                        return column;
×
895
                }
1,216✔
896

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

901
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
902

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

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

928
                                this._reader.ReadNext();
10,432✔
929
                        }
10,432✔
930

931
                        return row;
64✔
932
                }
1,472✔
933

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1145
                                this._reader.ReadNext();
11,584✔
1146
                        }
11,584✔
1147

1148
                        return cell;
128✔
1149
                }
5,376✔
1150

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

1155
                        this._reader.ReadNext();
5,248✔
1156

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

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

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

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

1193
                        this._reader.ReadNext();
5,248✔
1194

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

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

1219
                                this._reader.ReadNext();
×
1220
                        }
×
1221
                }
5,248✔
1222

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

1227
                        this._reader.ReadNext();
5,248✔
1228

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

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

1253
                                this._reader.ReadNext();
5,248✔
1254
                        }
5,248✔
1255
                }
5,248✔
1256

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

1261
                        this._reader.ReadNext();
×
1262

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

1279
                                if (end)
×
1280
                                {
×
1281
                                        break;
×
1282
                                }
1283

1284
                                this._reader.ReadNext();
×
1285
                        }
×
1286
                }
×
1287

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

1292
                        this._reader.ReadNext();
5,376✔
1293

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

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

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

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

1334
                        this._reader.ReadNext();
4,096✔
1335

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

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

1361
                                this._reader.ReadNext();
4,096✔
1362
                        }
4,096✔
1363

1364
                        return template;
4,096✔
1365
                }
4,096✔
1366

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

1372
                        this._reader.ReadNext();
4,096✔
1373

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

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

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

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

1413
                        this._reader.ReadNext();
4,096✔
1414

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

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

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

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

1448
                        this._reader.ReadNext();
9,600✔
1449

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

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

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

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

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

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

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

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

1517
                        this._reader.ReadNext();
8,128✔
1518

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

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

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

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

1564
                        this._reader.ReadNext();
11,776✔
1565

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

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

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

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

1609
                        this._reader.ReadNext();
2,816✔
1610

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

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

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

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

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

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

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

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

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

1704
                        this._reader.ReadNext();
8,960✔
1705

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2176
                                this._reader.ReadNext();
1,544✔
2177
                        }
1,544✔
2178

2179
                        return template;
772✔
2180
                }
772✔
2181

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2365
                        //Jump the 0 marker
2366
                        this._reader.ReadNext();
576✔
2367

2368
                        this.readCommonObjectData(template);
576✔
2369

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

2372
                        //Jump the 100 marker
2373
                        this._reader.ReadNext();
576✔
2374

2375
                        (ulong?, ulong?) pair = (null, null);
576✔
2376

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

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

2401
                                this._reader.ReadNext();
3,648✔
2402
                        }
3,648✔
2403

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