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

DomCR / ACadSharp / 22305305154

23 Feb 2026 12:03PM UTC coverage: 77.082% (-0.2%) from 77.315%
22305305154

Pull #982

github

web-flow
Merge 342325222 into e5434eb50
Pull Request #982: Refactor Field, FieldList, and CadValue handling

8177 of 11488 branches covered (71.18%)

Branch coverage included in aggregate %.

3037 of 3710 new or added lines in 11 files covered. (81.86%)

47 existing lines in 3 files now uncovered.

29586 of 37503 relevant lines covered (78.89%)

150261.28 hits per line

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

82.22
/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:
65
                                        return this.readObjectCodes<BlockReferenceObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new BlockReferenceObjectContextData()), this.readAnnotScaleObjectContextData);
×
66
                                case DxfFileToken.MTextAttributeObjectContextData:
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:
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:
133
                                        return this.readObjectCodes<Field>(new CadFieldTemplate(new Field()), this.readField);
×
134
                                case DxfFileToken.ObjectFieldList:
NEW
135
                                        return this.readObjectCodes<FieldList>(new CadFieldListTemplate(new FieldList()), 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)
200
                {
×
NEW
201
                        var tmp = template as CadFieldListTemplate;
×
202

UNCOV
203
                        switch (this._reader.Code)
×
204
                        {
NEW
205
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.IdSet:
×
NEW
206
                                        this.currentSubclass = this._reader.ValueAsString;
×
NEW
207
                                        return true;
×
NEW
208
                                case 90 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
NEW
209
                                        return true;
×
NEW
210
                                case 330 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
NEW
211
                                        tmp.OwnedObjectsHandlers.Add(this._reader.ValueAsHandle);
×
NEW
212
                                        return true;
×
213
                                default:
214
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.FieldList]);
×
215
                        }
216
                }
×
217

218
                private bool readField(CadTemplate template, DxfMap map)
219
                {
×
220
                        var tmp = template as CadFieldTemplate;
×
221

222
                        switch (this._reader.Code)
×
223
                        {
224
                                case 3:
NEW
225
                                        tmp.CadObject.FieldCode += this._reader.ValueAsString;
×
NEW
226
                                        return true;
×
227
                                //98 Length of format string
228
                                case 98:
229
                                        return true;
×
230
                                case 6:
NEW
231
                                        string key = this._reader.ValueAsString;
×
NEW
232
                                        var t = this.readCadValue(this._reader.ValueAsString);
×
NEW
233
                                        tmp.CadObject.Values.Add(key, t.CadValue);
×
NEW
234
                                        tmp.CadValueTemplates.Add(t);
×
NEW
235
                                        return true;
×
236
                                case 7:
NEW
237
                                        t = this.readCadValue(this._reader.ValueAsString);
×
NEW
238
                                        tmp.CadObject.Value = t.CadValue;
×
NEW
239
                                        tmp.CadValueTemplates.Add(t);
×
UNCOV
240
                                        return true;
×
241
                                case 331:
242
                                        tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
243
                                        return true;
×
244
                                case 360:
245
                                        tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
246
                                        return true;
×
247
                                default:
248
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
249
                        }
250
                }
×
251

252
                private CadValueTemplate readCadValue(string name)
253
                {
×
254
                        this._reader.ReadNext();
×
255

256
                        CadValue value = new();
×
NEW
257
                        CadValueTemplate template = new(value);
×
NEW
258
                        var map = DxfClassMap.Create(value.GetType(), name);
×
259

260
                        while (this._reader.Code != 304)
×
261
                        {
×
262
                                switch (this._reader.Code)
×
263
                                {
264
                                        case 330:
NEW
265
                                                template.ValueHandle = this._reader.ValueAsHandle;
×
UNCOV
266
                                                break;
×
267
                                        default:
268
                                                if (!this.tryAssignCurrentValue(value, map))
×
269
                                                {
×
270
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCadValue)} method.", NotificationType.None);
×
271
                                                }
×
272
                                                break;
×
273
                                }
274

275
                                this._reader.ReadNext();
×
276
                        }
×
277

NEW
278
                        return template;
×
UNCOV
279
                }
×
280

281
                private bool readProxyObject(CadTemplate template, DxfMap map)
282
                {
×
283
                        CadProxyObjectTemplate tmp = template as CadProxyObjectTemplate;
×
284
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
285

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

335
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
336
                {
23,355✔
337
                        switch (this._reader.Code)
23,355✔
338
                        {
339
                                default:
340
                                        if (string.IsNullOrEmpty(this.currentSubclass))
23,355✔
341
                                        {
14,655✔
342
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
14,655✔
343
                                        }
344
                                        else
345
                                        {
8,700✔
346
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
8,700✔
347
                                        }
348
                        }
349
                }
23,355✔
350

351
                private bool readAnnotScaleObjectContextData(CadTemplate template, DxfMap map)
352
                {
×
353
                        var tmp = template as CadAnnotScaleObjectContextDataTemplate;
×
354
                        switch (this._reader.Code)
×
355
                        {
356
                                case 340:
357
                                        tmp.ScaleHandle = this._reader.ValueAsHandle;
×
358
                                        return true;
×
359
                                default:
360
                                        if (string.IsNullOrEmpty(this.currentSubclass))
×
361
                                        {
×
362
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
363
                                        }
364
                                        else
365
                                        {
×
366
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
367
                                        }
368
                        }
369
                }
×
370

371
                private bool readPlotSettings(CadTemplate template, DxfMap map)
372
                {
25,534✔
373
                        switch (this._reader.Code)
25,534✔
374
                        {
375
                                default:
376
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,534✔
377
                        }
378
                }
25,534✔
379

380
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
381
                {
3,096✔
382
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,096✔
383
                        EvaluationGraph evGraph = tmp.CadObject;
3,096✔
384

385
                        switch (this._reader.Code)
3,096✔
386
                        {
387
                                case 91:
388
                                        while (this._reader.Code == 91)
3,025✔
389
                                        {
2,574✔
390
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,574✔
391
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,574✔
392

393
                                                node.Index = this._reader.ValueAsInt;
2,574✔
394

395
                                                this._reader.ExpectedCode(93);
2,574✔
396
                                                node.Flags = this._reader.ValueAsInt;
2,574✔
397

398
                                                this._reader.ExpectedCode(95);
2,574✔
399
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,574✔
400

401
                                                this._reader.ExpectedCode(360);
2,574✔
402
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,574✔
403

404
                                                this._reader.ExpectedCode(92);
2,574✔
405
                                                node.Data1 = this._reader.ValueAsInt;
2,574✔
406
                                                this._reader.ExpectedCode(92);
2,574✔
407
                                                node.Data2 = this._reader.ValueAsInt;
2,574✔
408
                                                this._reader.ExpectedCode(92);
2,574✔
409
                                                node.Data3 = this._reader.ValueAsInt;
2,574✔
410
                                                this._reader.ExpectedCode(92);
2,574✔
411
                                                node.Data4 = this._reader.ValueAsInt;
2,574✔
412

413
                                                this._reader.ReadNext();
2,574✔
414

415
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
416
                                        }
2,574✔
417

418
                                        this.lockPointer = true;
451✔
419
                                        return true;
451✔
420
                                case 92:
421
                                        //Edges
422
                                        while (this._reader.Code == 92)
2,126✔
423
                                        {
1,931✔
424
                                                this._reader.ExpectedCode(93);
1,931✔
425
                                                this._reader.ExpectedCode(94);
1,931✔
426
                                                this._reader.ExpectedCode(91);
1,931✔
427
                                                this._reader.ExpectedCode(91);
1,931✔
428
                                                this._reader.ExpectedCode(92);
1,931✔
429
                                                this._reader.ExpectedCode(92);
1,931✔
430
                                                this._reader.ExpectedCode(92);
1,931✔
431
                                                this._reader.ExpectedCode(92);
1,931✔
432
                                                this._reader.ExpectedCode(92);
1,931✔
433

434
                                                this._reader.ReadNext();
1,931✔
435
                                        }
1,931✔
436

437
                                        this.lockPointer = true;
195✔
438
                                        return true;
195✔
439
                                default:
440
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,450✔
441
                        }
442
                }
3,096✔
443

444
                private bool readLayout(CadTemplate template, DxfMap map)
445
                {
51,979✔
446
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,979✔
447

448
                        switch (this._reader.Code)
51,979✔
449
                        {
450
                                case 330:
451
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,614✔
452
                                        return true;
1,614✔
453
                                case 331:
454
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
773✔
455
                                        return true;
773✔
456
                                default:
457
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,592✔
458
                                        {
25,534✔
459
                                                return this.readPlotSettings(template, map);
25,534✔
460
                                        }
461
                                        return true;
24,058✔
462
                        }
463
                }
51,979✔
464

465
                private bool readGroup(CadTemplate template, DxfMap map)
466
                {
4,992✔
467
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
468

469
                        switch (this._reader.Code)
4,992✔
470
                        {
471
                                case 70:
472
                                        return true;
384✔
473
                                case 340:
474
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
475
                                        return true;
2,304✔
476
                                default:
477
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
478
                        }
479
                }
4,992✔
480

481
                private bool readGeoData(CadTemplate template, DxfMap map)
482
                {
102✔
483
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
484

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

525
                                                this._reader.ReadNext();
24✔
526
                                                double destX = this._reader.ValueAsDouble;
24✔
527
                                                this._reader.ReadNext();
24✔
528
                                                double destY = this._reader.ValueAsDouble;
24✔
529

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

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

589
                private bool readMaterial(CadTemplate template, DxfMap map)
590
                {
42,114✔
591
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,114✔
592
                        List<double> arr = null;
42,114✔
593

594
                        switch (this._reader.Code)
42,114!
595
                        {
596
                                case 43:
597
                                        arr = new();
1,349✔
598
                                        for (int i = 0; i < 16; i++)
45,866✔
599
                                        {
21,584✔
600
                                                Debug.Assert(this._reader.Code == 43);
21,584✔
601

602
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
603

604
                                                this._reader.ReadNext();
21,584✔
605
                                        }
21,584✔
606

607
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,349✔
608
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,349✔
609
                                case 47:
610
                                        arr = new();
×
611
                                        for (int i = 0; i < 16; i++)
×
612
                                        {
×
613
                                                Debug.Assert(this._reader.Code == 47);
×
614

615
                                                arr.Add(this._reader.ValueAsDouble);
×
616

617
                                                this._reader.ReadNext();
×
618
                                        }
×
619

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

628
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
629

630
                                                this._reader.ReadNext();
3,152✔
631
                                        }
3,152✔
632

633
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
634
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
635
                                case 142:
636
                                        arr = new();
197✔
637
                                        for (int i = 0; i < 16; i++)
6,698✔
638
                                        {
3,152✔
639
                                                Debug.Assert(this._reader.Code == 142);
3,152✔
640

641
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
642

643
                                                this._reader.ReadNext();
3,152✔
644
                                        }
3,152✔
645

646
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
647
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
648
                                case 144:
649
                                        arr = new();
1,157✔
650
                                        for (int i = 0; i < 16; i++)
39,338✔
651
                                        {
18,512✔
652
                                                Debug.Assert(this._reader.Code == 144);
18,512✔
653

654
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
655

656
                                                this._reader.ReadNext();
18,512✔
657
                                        }
18,512✔
658

659
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,157✔
660
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,157✔
661
                                case 147:
662
                                        arr = new();
×
663
                                        for (int i = 0; i < 16; i++)
×
664
                                        {
×
665
                                                Debug.Assert(this._reader.Code == 147);
×
666

667
                                                arr.Add(this._reader.ValueAsDouble);
×
668

669
                                                this._reader.ReadNext();
×
670
                                        }
×
671

672
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
673
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
674
                                default:
675
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,214✔
676
                        }
677
                }
42,114✔
678

679
                private bool readScale(CadTemplate template, DxfMap map)
680
                {
60,141✔
681
                        switch (this._reader.Code)
60,141✔
682
                        {
683
                                // Undocumented codes
684
                                case 70:
685
                                        //Always 0
686
                                        return true;
6,705✔
687
                                default:
688
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
53,436✔
689
                        }
690
                }
60,141✔
691

692
                private void readLinkedData(CadTemplate template, DxfMap map)
693
                {
320✔
694
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
695
                        LinkedData linkedData = tmp.CadObject;
320✔
696

697
                        this._reader.ReadNext();
320✔
698

699
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
700
                        {
640✔
701
                                switch (this._reader.Code)
640✔
702
                                {
703
                                        default:
704
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
705
                                                {
×
706
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
707
                                                }
×
708
                                                break;
640✔
709
                                }
710

711
                                this._reader.ReadNext();
640✔
712
                        }
640✔
713
                }
320✔
714

715
                private bool readTableContent(CadTemplate template, DxfMap map)
716
                {
2,368✔
717
                        switch (this._reader.Code)
2,368✔
718
                        {
719
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
720
                                        this.readTableContentSubclass(template, map);
256✔
721
                                        this.lockPointer = true;
256✔
722
                                        return true;
256✔
723
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
724
                                        this.readFormattedTableDataSubclass(template, map);
256✔
725
                                        this.lockPointer = true;
256✔
726
                                        return true;
256✔
727
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
728
                                        this.readLinkedTableDataSubclass(template, map);
320✔
729
                                        this.lockPointer = true;
320✔
730
                                        return true;
320✔
731
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
732
                                        this.readLinkedData(template, map);
320✔
733
                                        this.lockPointer = true;
320✔
734
                                        return true;
320✔
735
                                default:
736
                                        return false;
1,216✔
737
                        }
738
                }
2,368✔
739

740
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
741
                {
256✔
742
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
743
                        TableContent tableContent = tmp.CadObject;
256✔
744

745
                        this._reader.ReadNext();
256✔
746

747
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
748
                        {
256✔
749
                                switch (this._reader.Code)
256!
750
                                {
751
                                        case 340:
752
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
753
                                                break;
256✔
754
                                        default:
755
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
756
                                                {
×
757
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
758
                                                }
×
759
                                                break;
×
760
                                }
761

762
                                this._reader.ReadNext();
256✔
763
                        }
256✔
764
                }
256✔
765

766
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
767
                {
256✔
768
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
769
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
770

771
                        this._reader.ReadNext();
256✔
772

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

824
                                this._reader.ReadNext();
2,048✔
825
                        }
2,048✔
826
                }
256✔
827

828
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
829
                {
320✔
830
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
831
                        TableContent tableContent = tmp.CadObject;
320✔
832

833
                        this._reader.ReadNext();
320✔
834

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

864
                                this._reader.ReadNext();
3,904✔
865
                        }
3,904✔
866
                }
320✔
867

868

869
                private TableEntity.Column readTableColumn()
870
                {
1,216✔
871
                        this._reader.ReadNext();
1,216✔
872

873
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
874

875
                        bool end = false;
1,216✔
876
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
877
                        {
3,648✔
878
                                switch (this._reader.Code)
3,648!
879
                                {
880
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
881
                                                this.readLinkedTableColumn(column);
1,216✔
882
                                                break;
1,216✔
883
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
884
                                                this.readFormattedTableColumn(column);
1,216✔
885
                                                break;
1,216✔
886
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
887
                                                this.readTableColumn(column);
1,216✔
888
                                                end = true;
1,216✔
889
                                                break;
1,216✔
890
                                        default:
891
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
892
                                                break;
×
893
                                }
894

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

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

903
                        return column;
×
904
                }
1,216✔
905

906
                private TableEntity.Row readTableRow()
907
                {
1,472✔
908
                        this._reader.ReadNext();
1,472✔
909

910
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
911

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

932
                                if (end)
11,840✔
933
                                {
1,408✔
934
                                        return row;
1,408✔
935
                                }
936

937
                                this._reader.ReadNext();
10,432✔
938
                        }
10,432✔
939

940
                        return row;
64✔
941
                }
1,472✔
942

943
                private void readTableRow(TableEntity.Row row)
944
                {
1,408✔
945
                        this._reader.ReadNext();
1,408✔
946

947
                        bool end = false;
1,408✔
948
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
949
                        {
4,224✔
950
                                switch (this._reader.Code)
4,224!
951
                                {
952
                                        case 40:
953
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
954
                                                break;
1,408✔
955
                                        case 90:
956
                                                //styleID
957
                                                break;
1,408✔
958
                                        case 309:
959
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
960
                                                break;
1,408✔
961
                                        default:
962
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
963
                                                break;
×
964
                                }
965

966
                                if (end)
4,224✔
967
                                {
1,408✔
968
                                        break;
1,408✔
969
                                }
970

971
                                this._reader.ReadNext();
2,816✔
972
                        }
2,816✔
973
                }
1,408✔
974

975
                private void readFormattedTableRow(TableEntity.Row row)
976
                {
1,408✔
977
                        this._reader.ReadNext();
1,408✔
978

979
                        bool end = false;
1,408✔
980
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
981
                        {
4,224✔
982
                                switch (this._reader.Code)
4,224!
983
                                {
984
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
985
                                                break;
1,408✔
986
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
987
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
988
                                                break;
1,408✔
989
                                        case 309:
990
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
991
                                                break;
1,408✔
992
                                        default:
993
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
994
                                                break;
×
995
                                }
996

997
                                if (end)
4,224✔
998
                                {
1,408✔
999
                                        break;
1,408✔
1000
                                }
1001

1002
                                this._reader.ReadNext();
2,816✔
1003
                        }
2,816✔
1004
                }
1,408✔
1005

1006
                private void readTableColumn(TableEntity.Column column)
1007
                {
1,216✔
1008
                        this._reader.ReadNext();
1,216✔
1009

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

1034
                                if (end)
3,648✔
1035
                                {
1,216✔
1036
                                        break;
1,216✔
1037
                                }
1038

1039
                                this._reader.ReadNext();
2,432✔
1040
                        }
2,432✔
1041
                }
1,216✔
1042

1043
                private void readLinkedTableColumn(TableEntity.Column column)
1044
                {
1,216✔
1045
                        this._reader.ReadNext();
1,216✔
1046

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

1074
                                if (end)
4,864✔
1075
                                {
1,216✔
1076
                                        break;
1,216✔
1077
                                }
1078

1079
                                this._reader.ReadNext();
3,648✔
1080
                        }
3,648✔
1081
                }
1,216✔
1082

1083
                private void readLinkedTableRow(TableEntity.Row row)
1084
                {
1,536✔
1085
                        this._reader.ReadNext();
1,536✔
1086

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

1113
                                if (end)
12,480✔
1114
                                {
1,408✔
1115
                                        break;
1,408✔
1116
                                }
1117

1118
                                this._reader.ReadNext();
11,072✔
1119
                        }
11,072✔
1120
                }
1,536✔
1121

1122
                private TableEntity.Cell readCell()
1123
                {
5,376✔
1124
                        this._reader.ReadNext();
5,376✔
1125

1126
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
1127
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
1128

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

1149
                                if (end)
16,832✔
1150
                                {
5,248✔
1151
                                        return cell;
5,248✔
1152
                                }
1153

1154
                                this._reader.ReadNext();
11,584✔
1155
                        }
11,584✔
1156

1157
                        return cell;
128✔
1158
                }
5,376✔
1159

1160
                private void readTableCell(TableEntity.Cell cell)
1161
                {
5,248✔
1162
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1163

1164
                        this._reader.ReadNext();
5,248✔
1165

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

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

1194
                                this._reader.ReadNext();
11,136✔
1195
                        }
11,136✔
1196
                }
5,248✔
1197

1198
                private void readFormattedTableCell(TableEntity.Cell cell)
1199
                {
5,248✔
1200
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1201

1202
                        this._reader.ReadNext();
5,248✔
1203

1204
                        bool end = false;
5,248✔
1205
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1206
                        {
10,496✔
1207
                                switch (this._reader.Code)
10,496!
1208
                                {
1209
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1210
                                                this.readCellTableFormat(cell);
5,248✔
1211
                                                continue;
5,248✔
1212
                                        case 309:
1213
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1214
                                                break;
5,248✔
1215
                                        default:
1216
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1217
                                                {
×
1218
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1219
                                                }
×
1220
                                                break;
×
1221
                                }
1222

1223
                                if (end)
5,248!
1224
                                {
5,248✔
1225
                                        break;
5,248✔
1226
                                }
1227

1228
                                this._reader.ReadNext();
×
1229
                        }
×
1230
                }
5,248✔
1231

1232
                private void readCellTableFormat(TableEntity.Cell cell)
1233
                {
5,248✔
1234
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1235

1236
                        this._reader.ReadNext();
5,248✔
1237

1238
                        bool end = false;
5,248✔
1239
                        while (this._reader.Code == 1)
10,496✔
1240
                        {
5,248✔
1241
                                switch (this._reader.Code)
5,248!
1242
                                {
1243
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1244
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1245
                                                break;
5,248✔
1246
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1247
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1248
                                                break;
×
1249
                                        default:
1250
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1251
                                                {
×
1252
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1253
                                                }
×
1254
                                                break;
×
1255
                                }
1256

1257
                                if (end)
5,248!
1258
                                {
×
1259
                                        break;
×
1260
                                }
1261

1262
                                this._reader.ReadNext();
5,248✔
1263
                        }
5,248✔
1264
                }
5,248✔
1265

1266
                private void readCellStyle(CadCellStyleTemplate template)
1267
                {
×
1268
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1269

1270
                        this._reader.ReadNext();
×
1271

1272
                        bool end = false;
×
1273
                        while (this._reader.Code != 1)
×
1274
                        {
×
1275
                                switch (this._reader.Code)
×
1276
                                {
1277
                                        case 309:
1278
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1279
                                                break;
×
1280
                                        default:
1281
                                                //if (!this.tryAssignCurrentValue(cell, map))
1282
                                                {
×
1283
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1284
                                                }
×
1285
                                                break;
×
1286
                                }
1287

1288
                                if (end)
×
1289
                                {
×
1290
                                        break;
×
1291
                                }
1292

1293
                                this._reader.ReadNext();
×
1294
                        }
×
1295
                }
×
1296

1297
                private void readLinkedTableCell(TableEntity.Cell cell)
1298
                {
5,376✔
1299
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1300

1301
                        this._reader.ReadNext();
5,376✔
1302

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

1328
                                if (end)
53,760✔
1329
                                {
5,248✔
1330
                                        break;
5,248✔
1331
                                }
1332

1333
                                this._reader.ReadNext();
48,512✔
1334
                        }
48,512✔
1335
                }
5,376✔
1336

1337
                private CadTableCellContentTemplate readLinkedTableCellContent()
1338
                {
4,096✔
1339
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1340
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1341
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1342

1343
                        this._reader.ReadNext();
4,096✔
1344

1345
                        bool end = false;
4,096✔
1346
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1347
                        {
8,192✔
1348
                                switch (this._reader.Code)
8,192!
1349
                                {
1350
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1351
                                                readFormattedCellContent();
4,096✔
1352
                                                end = true;
4,096✔
1353
                                                break;
4,096✔
1354
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1355
                                                readCellContent(template);
4,096✔
1356
                                                break;
4,096✔
1357
                                        default:
1358
                                                if (!this.tryAssignCurrentValue(content, map))
×
1359
                                                {
×
1360
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1361
                                                }
×
1362
                                                break;
×
1363
                                }
1364

1365
                                if (end)
8,192✔
1366
                                {
4,096✔
1367
                                        break;
4,096✔
1368
                                }
1369

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

1373
                        return template;
4,096✔
1374
                }
4,096✔
1375

1376
                private void readCellContent(CadTableCellContentTemplate template)
1377
                {
4,096✔
1378
                        TableEntity.CellContent content = template.Content;
4,096✔
1379
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1380

1381
                        this._reader.ReadNext();
4,096✔
1382

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

1407
                                if (end)
16,384✔
1408
                                {
4,096✔
1409
                                        break;
4,096✔
1410
                                }
1411

1412
                                this._reader.ReadNext();
12,288✔
1413
                        }
12,288✔
1414
                }
4,096✔
1415

1416
                private void readFormattedCellContent()
1417
                {
4,096✔
1418
                        TableEntity.ContentFormat format = new();
4,096✔
1419
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1420
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1421

1422
                        this._reader.ReadNext();
4,096✔
1423

1424
                        bool end = false;
4,096✔
1425
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1426
                        {
12,288✔
1427
                                switch (this._reader.Code)
12,288✔
1428
                                {
1429
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1430
                                                readContentFormat(template);
4,096✔
1431
                                                break;
4,096✔
1432
                                        case 309:
1433
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1434
                                                break;
4,096✔
1435
                                        default:
1436
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1437
                                                {
×
1438
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1439
                                                }
×
1440
                                                break;
4,096✔
1441
                                }
1442

1443
                                if (end)
12,288✔
1444
                                {
4,096✔
1445
                                        break;
4,096✔
1446
                                }
1447

1448
                                this._reader.ReadNext();
8,192✔
1449
                        }
8,192✔
1450
                }
4,096✔
1451

1452
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1453
                {
9,600✔
1454
                        var format = template.Format;
9,600✔
1455
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1456

1457
                        this._reader.ReadNext();
9,600✔
1458

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

1480
                                if (end)
124,800✔
1481
                                {
9,600✔
1482
                                        break;
9,600✔
1483
                                }
1484

1485
                                this._reader.ReadNext();
115,200✔
1486
                        }
115,200✔
1487
                }
9,600✔
1488

1489
                private void readFormattedTableColumn(TableEntity.Column column)
1490
                {
1,216✔
1491
                        this._reader.ReadNext();
1,216✔
1492

1493
                        bool end = false;
1,216✔
1494
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1495
                        {
3,648✔
1496
                                switch (this._reader.Code)
3,648!
1497
                                {
1498
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1499
                                                break;
1,216✔
1500
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1501
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1502
                                                break;
1,216✔
1503
                                        case 309:
1504
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1505
                                                break;
1,216✔
1506
                                        default:
1507
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1508
                                                break;
×
1509
                                }
1510

1511
                                if (end)
3,648✔
1512
                                {
1,216✔
1513
                                        break;
1,216✔
1514
                                }
1515

1516
                                this._reader.ReadNext();
2,432✔
1517
                        }
2,432✔
1518
                }
1,216✔
1519

1520
                private void readStyleOverride(CadCellStyleTemplate template)
1521
                {
8,128✔
1522
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1523
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1524
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1525

1526
                        this._reader.ReadNext();
8,128✔
1527

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

1560
                                if (end)
89,536✔
1561
                                {
8,128✔
1562
                                        break;
8,128✔
1563
                                }
1564

1565
                                this._reader.ReadNext();
81,408✔
1566
                        }
81,408✔
1567
                }
8,128✔
1568

1569
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1570
                {
11,776✔
1571
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1572

1573
                        this._reader.ReadNext();
11,776✔
1574

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

1605
                                if (end)
105,984✔
1606
                                {
11,776✔
1607
                                        break;
11,776✔
1608
                                }
1609

1610
                                this._reader.ReadNext();
94,208✔
1611
                        }
94,208✔
1612
                }
11,776✔
1613

1614
                private void readCellMargin(CadCellStyleTemplate template)
1615
                {
2,816✔
1616
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1617

1618
                        this._reader.ReadNext();
2,816✔
1619

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

1651
                                                i++;
16,896✔
1652
                                                break;
16,896✔
1653
                                        case 309:
1654
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1655
                                                break;
2,816✔
1656
                                        default:
1657
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1658
                                                break;
×
1659
                                }
1660

1661
                                if (end)
22,528✔
1662
                                {
2,816✔
1663
                                        break;
2,816✔
1664
                                }
1665

1666
                                this._reader.ReadNext();
19,712✔
1667
                        }
19,712✔
1668
                }
2,816✔
1669

1670
                private void readCustomData()
1671
                {
8,000✔
1672
                        this._reader.ReadNext();
8,000✔
1673

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

1699
                                if (end)
74,304✔
1700
                                {
7,872✔
1701
                                        break;
7,872✔
1702
                                }
1703

1704
                                this._reader.ReadNext();
66,432✔
1705
                        }
66,432✔
1706
                }
8,000✔
1707

1708
                private void readDataMapValue()
1709
                {
8,960✔
1710
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1711
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1712

1713
                        this._reader.ReadNext();
8,960✔
1714

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

1746
                                if (end)
330,112✔
1747
                                {
8,832✔
1748
                                        break;
8,832✔
1749
                                }
1750

1751
                                this._reader.ReadNext();
321,280✔
1752
                        }
321,280✔
1753
                }
8,960✔
1754

1755
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1756
                {
379,506✔
1757
                        switch (this._reader.Code)
379,506✔
1758
                        {
1759
                                // Undocumented codes
1760
                                case 176:
1761
                                case 177:
1762
                                case 420:
1763
                                        return true;
123,592✔
1764
                                default:
1765
                                        //Avoid noise while is not implemented
1766
                                        return true;
255,914✔
1767
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1768
                        }
1769
                }
379,506✔
1770

1771
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1772
                {
4,032✔
1773
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1774
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1775

1776
                        switch (this._reader.Code)
4,032✔
1777
                        {
1778
                                case 10:
1779
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1780
                                        return true;
384✔
1781
                                case 20:
1782
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1783
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1784
                                        return true;
384✔
1785
                                case 40:
1786
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1787
                                        {
×
1788
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1789
                                                tmp.HasFrontPlane = true;
×
1790
                                        }
×
1791

1792
                                        double[] array = new double[16]
384✔
1793
                                        {
384✔
1794
                                                0.0, 0.0, 0.0, 0.0,
384✔
1795
                                                0.0, 0.0, 0.0, 0.0,
384✔
1796
                                                0.0, 0.0, 0.0, 0.0,
384✔
1797
                                                0.0, 0.0, 0.0, 1.0
384✔
1798
                                        };
384✔
1799

1800
                                        for (int i = 0; i < 12; i++)
9,984✔
1801
                                        {
4,608✔
1802
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1803

1804
                                                if (i < 11)
4,608✔
1805
                                                {
4,224✔
1806
                                                        this._reader.ReadNext();
4,224✔
1807
                                                }
4,224✔
1808
                                        }
4,608✔
1809

1810
                                        if (tmp.InsertTransformRead)
384!
1811
                                        {
×
1812
                                                filter.InsertTransform = new Matrix4(array);
×
1813
                                                tmp.InsertTransformRead = true;
×
1814
                                        }
×
1815
                                        else
1816
                                        {
384✔
1817
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1818
                                        }
384✔
1819

1820
                                        return true;
384✔
1821
                                case 73:
1822
                                default:
1823
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1824
                        }
1825
                }
4,032✔
1826

1827
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1828
                {
3,529✔
1829
                        var tmp = template as CadMLineStyleTemplate;
3,529✔
1830
                        var mLineStyle = template.CadObject as MLineStyle;
3,529✔
1831

1832
                        switch (this._reader.Code)
3,529✔
1833
                        {
1834
                                case 6:
1835
                                        var t = tmp.ElementTemplates.LastOrDefault();
418✔
1836
                                        if (t == null)
418!
1837
                                        {
×
1838
                                                return true;
×
1839
                                        }
1840
                                        t.LineTypeName = this._reader.ValueAsString;
418✔
1841
                                        return true;
418✔
1842
                                case 49:
1843
                                        MLineStyle.Element element = new MLineStyle.Element();
418✔
1844
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
418✔
1845
                                        element.Offset = this._reader.ValueAsDouble;
418✔
1846

1847
                                        tmp.ElementTemplates.Add(elementTemplate);
418✔
1848
                                        mLineStyle.AddElement(element);
418✔
1849
                                        return true;
418✔
1850
                                default:
1851
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,693✔
1852
                        }
1853
                }
3,529✔
1854

1855
                private bool readTableStyle(CadTemplate template, DxfMap map)
1856
                {
17,845✔
1857
                        var tmp = template as CadTableStyleTemplate;
17,845✔
1858
                        var style = tmp.CadObject;
17,845✔
1859
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,845✔
1860

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

1953
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1954
                {
18,636✔
1955
                        var tmp = template as CadMLeaderStyleTemplate;
18,636✔
1956

1957
                        switch (this._reader.Code)
18,636✔
1958
                        {
1959
                                case 179:
1960
                                        return true;
212✔
1961
                                case 340:
1962
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
406✔
1963
                                        return true;
406✔
1964
                                case 342:
1965
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
406✔
1966
                                        return true;
406✔
1967
                                default:
1968
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,612✔
1969
                        }
1970
                }
18,636✔
1971

1972
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1973
                {
13,737✔
1974
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,737✔
1975

1976
                        switch (this._reader.Code)
13,737✔
1977
                        {
1978
                                case 1:
1979
                                        this._reader.ExpectedCode(70);
1,158✔
1980
                                        this._reader.ExpectedCode(140);
1,158✔
1981
                                        return true;
1,158✔
1982
                                default:
1983
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,579✔
1984
                        }
1985
                }
13,737✔
1986

1987
                private bool readBlockElement(CadTemplate template, DxfMap map)
1988
                {
5,249✔
1989
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,249✔
1990

1991
                        switch (this._reader.Code)
5,249✔
1992
                        {
1993
                                default:
1994
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,249✔
1995
                                        {
4,473✔
1996
                                                return this.readEvaluationExpression(template, map);
4,473✔
1997
                                        }
1998
                                        return true;
776✔
1999
                        }
2000
                }
5,249✔
2001

2002
                private bool readBlockAction(CadTemplate template, DxfMap map)
2003
                {
20✔
2004
                        CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
20✔
2005

2006
                        switch (this._reader.Code)
20✔
2007
                        {
2008
                                default:
2009
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
20✔
2010
                                        {
15✔
2011
                                                return this.readBlockElement(template, map);
15✔
2012
                                        }
2013
                                        return true;
5✔
2014
                        }
2015
                }
20✔
2016

2017
                private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
2018
                {
31✔
2019
                        CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
31✔
2020

2021
                        switch (this._reader.Code)
31✔
2022
                        {
2023
                                default:
2024
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
31✔
2025
                                        {
20✔
2026
                                                return this.readBlockAction(template, map);
20✔
2027
                                        }
2028
                                        return true;
11✔
2029
                        }
2030
                }
31✔
2031

2032
                private bool readBlockRotationAction(CadTemplate template, DxfMap map)
2033
                {
33✔
2034
                        CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
33✔
2035

2036
                        switch (this._reader.Code)
33✔
2037
                        {
2038
                                default:
2039
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
33✔
2040
                                        {
31✔
2041
                                                return this.readBlockActionBasePt(template, map);
31✔
2042
                                        }
2043
                                        return true;
2✔
2044
                        }
2045
                }
33✔
2046

2047
                private bool readBlockParameter(CadTemplate template, DxfMap map)
2048
                {
3,291✔
2049
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,291✔
2050

2051
                        switch (this._reader.Code)
3,291✔
2052
                        {
2053
                                default:
2054
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,291✔
2055
                                        {
2,712✔
2056
                                                return this.readBlockElement(template, map);
2,712✔
2057
                                        }
2058
                                        return true;
579✔
2059
                        }
2060
                }
3,291✔
2061

2062
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
2063
                {
4,246✔
2064
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
2065

2066
                        switch (this._reader.Code)
4,246✔
2067
                        {
2068
                                default:
2069
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
2070
                                        {
3,281✔
2071
                                                return this.readBlockParameter(template, map);
3,281✔
2072
                                        }
2073
                                        return true;
965✔
2074
                        }
2075
                }
4,246✔
2076

2077
                private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
2078
                {
14✔
2079
                        var tmp = template as CadBlock2PtParameterTemplate;
14✔
2080

2081
                        switch (this._reader.Code)
14✔
2082
                        {
2083
                                //Stores always 4 entries using this code
2084
                                case 91:
2085
                                        return true;
4✔
2086
                                default:
2087
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
10!
2088
                                        {
10✔
2089
                                                return this.readBlockParameter(template, map);
10✔
2090
                                        }
2091
                                        return true;
×
2092
                        }
2093
                }
14✔
2094

2095
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
2096
                {
5,404✔
2097
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
2098

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

2126
                private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2127
                {
49✔
2128
                        var tmp = template as CadBlockRotationParameterTemplate;
49✔
2129

2130
                        switch (this._reader.Code)
49✔
2131
                        {
2132
                                default:
2133
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
49✔
2134
                                        {
14✔
2135
                                                return this.readBlock2PtParameter(template, map);
14✔
2136
                                        }
2137
                                        return true;
35✔
2138
                        }
2139
                }
49✔
2140

2141
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2142
                {
772✔
2143
                        var state = new BlockVisibilityParameter.State();
772✔
2144
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
2145

2146
                        List<int> expectedCodes = new List<int>();
772✔
2147
                        expectedCodes.Add(303);
772✔
2148
                        expectedCodes.Add(94);
772✔
2149
                        expectedCodes.Add(95);
772✔
2150

2151
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
2152
                        {
2,316✔
2153
                                expectedCodes.Remove(this._reader.Code);
2,316✔
2154

2155
                                switch (this._reader.Code)
2,316!
2156
                                {
2157
                                        case 303:
2158
                                                state.Name = this._reader.ValueAsString;
772✔
2159
                                                break;
772✔
2160
                                        case 94:
2161
                                                var count = this._reader.ValueAsInt;
772✔
2162
                                                for (int i = 0; i < count; i++)
2,720✔
2163
                                                {
588✔
2164
                                                        this._reader.ReadNext();
588✔
2165
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
2166
                                                }
588✔
2167
                                                break;
772✔
2168
                                        case 95:
2169
                                                count = this._reader.ValueAsInt;
772✔
2170
                                                for (int i = 0; i < count; i++)
6,152✔
2171
                                                {
2,304✔
2172
                                                        this._reader.ReadNext();
2,304✔
2173
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2174
                                                }
2,304✔
2175
                                                break;
772✔
2176
                                        default:
2177
                                                return template;
×
2178
                                }
2179

2180
                                if (!expectedCodes.Any())
2,316✔
2181
                                {
772✔
2182
                                        break;
772✔
2183
                                }
2184

2185
                                this._reader.ReadNext();
1,544✔
2186
                        }
1,544✔
2187

2188
                        return template;
772✔
2189
                }
772✔
2190

2191
                private bool readBlockGrip(CadTemplate template, DxfMap map)
2192
                {
3,880✔
2193
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,880✔
2194

2195
                        switch (this._reader.Code)
3,880✔
2196
                        {
2197
                                default:
2198
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,880✔
2199
                                        {
2,522✔
2200
                                                return this.readBlockElement(template, map);
2,522✔
2201
                                        }
2202
                                        return true;
1,358✔
2203
                        }
2204
                }
3,880✔
2205

2206
                private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
2207
                {
20✔
2208
                        CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
20✔
2209

2210
                        switch (this._reader.Code)
20✔
2211
                        {
2212
                                default:
2213
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
20!
2214
                                        {
20✔
2215
                                                return this.readBlockGrip(template, map);
20✔
2216
                                        }
2217
                                        return true;
×
2218
                        }
2219
                }
20✔
2220

2221
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
2222
                {
3,860✔
2223
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2224

2225
                        switch (this._reader.Code)
3,860✔
2226
                        {
2227
                                default:
2228
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2229
                                        {
3,860✔
2230
                                                return this.readBlockGrip(template, map);
3,860✔
2231
                                        }
2232
                                        return true;
×
2233
                        }
2234
                }
3,860✔
2235

2236
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2237
                {
1,590✔
2238
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,590✔
2239

2240
                        switch (this._reader.Code)
1,590✔
2241
                        {
2242
                                case 340:
2243
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
265✔
2244
                                        return true;
265✔
2245
                                default:
2246
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,325✔
2247
                        }
2248
                }
1,590✔
2249

2250
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2251
                {
11,580✔
2252
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,580✔
2253

2254
                        switch (this._reader.Code)
11,580✔
2255
                        {
2256
                                default:
2257
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,580✔
2258
                                        {
9,264✔
2259
                                                return this.readEvaluationExpression(template, map);
9,264✔
2260
                                        }
2261
                                        return true;
2,316✔
2262
                        }
2263
                }
11,580✔
2264

2265
                private bool readXRecord(CadTemplate template, DxfMap map)
2266
                {
113,272✔
2267
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,272✔
2268

2269
                        switch (this._reader.Code)
113,272✔
2270
                        {
2271
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,926✔
2272
                                        this.readXRecordEntries(tmp);
28,926✔
2273
                                        return true;
28,926✔
2274
                                default:
2275
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,346✔
2276
                        }
2277
                }
113,272✔
2278

2279
                private void readXRecordEntries(CadXRecordTemplate template)
2280
                {
28,926✔
2281
                        this._reader.ReadNext();
28,926✔
2282

2283
                        while (this._reader.DxfCode != DxfCode.Start)
2,409,286✔
2284
                        {
2,380,360✔
2285
                                switch (this._reader.GroupCodeValue)
2,380,360✔
2286
                                {
2287
                                        case GroupCodeValueType.Point3D:
2288
                                                var code = this._reader.Code;
2,901✔
2289
                                                var x = this._reader.ValueAsDouble;
2,901✔
2290
                                                this._reader.ReadNext();
2,901✔
2291
                                                var y = this._reader.ValueAsDouble;
2,901✔
2292
                                                this._reader.ReadNext();
2,901✔
2293
                                                var z = this._reader.ValueAsDouble;
2,901✔
2294
                                                XYZ pt = new XYZ(x, y, z);
2,901✔
2295
                                                template.CadObject.CreateEntry(code, pt);
2,901✔
2296
                                                break;
2,901✔
2297
                                        case GroupCodeValueType.Handle:
2298
                                        case GroupCodeValueType.ObjectId:
2299
                                        case GroupCodeValueType.ExtendedDataHandle:
2300
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,041✔
2301
                                                break;
12,041✔
2302
                                        default:
2303
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,418✔
2304
                                                break;
2,365,418✔
2305
                                }
2306

2307
                                this._reader.ReadNext();
2,380,360✔
2308
                        }
2,380,360✔
2309
                }
28,926✔
2310

2311
                private bool readBookColor(CadTemplate template, DxfMap map)
2312
                {
1,376✔
2313
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2314
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2315

2316
                        switch (this._reader.Code)
1,376✔
2317
                        {
2318
                                case 430:
2319
                                        color.Name = this._reader.ValueAsString;
160✔
2320
                                        return true;
160✔
2321
                                default:
2322
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2323
                        }
2324
                }
1,376✔
2325

2326
                private bool readDictionary(CadTemplate template, DxfMap map)
2327
                {
224,204✔
2328
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
224,204✔
2329
                        CadDictionary cadDictionary = tmp.CadObject;
224,204✔
2330

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

2351
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2352
                {
1,773✔
2353
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,773✔
2354

2355
                        switch (this._reader.Code)
1,773✔
2356
                        {
2357
                                case 340:
2358
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
197✔
2359
                                        return true;
197✔
2360
                                default:
2361
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,576!
2362
                                        {
1,576✔
2363
                                                return this.readDictionary(template, map);
1,576✔
2364
                                        }
2365
                                        return true;
×
2366
                        }
2367
                }
1,773✔
2368

2369
                private CadTemplate readSortentsTable()
2370
                {
576✔
2371
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2372
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2373

2374
                        //Jump the 0 marker
2375
                        this._reader.ReadNext();
576✔
2376

2377
                        this.readCommonObjectData(template);
576✔
2378

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

2381
                        //Jump the 100 marker
2382
                        this._reader.ReadNext();
576✔
2383

2384
                        (ulong?, ulong?) pair = (null, null);
576✔
2385

2386
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2387
                        {
3,648✔
2388
                                switch (this._reader.Code)
3,648!
2389
                                {
2390
                                        case 5:
2391
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2392
                                                break;
1,536✔
2393
                                        case 330:
2394
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2395
                                                break;
576✔
2396
                                        case 331:
2397
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2398
                                                break;
1,536✔
2399
                                        default:
2400
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2401
                                                break;
×
2402
                                }
2403

2404
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2405
                                {
1,536✔
2406
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2407
                                        pair = (null, null);
1,536✔
2408
                                }
1,536✔
2409

2410
                                this._reader.ReadNext();
3,648✔
2411
                        }
3,648✔
2412

2413
                        return template;
576✔
2414
                }
576✔
2415
        }
2416
}
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