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

DomCR / ACadSharp / 22021855126

14 Feb 2026 06:01PM UTC coverage: 77.277% (-0.2%) from 77.463%
22021855126

Pull #978

github

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

8149 of 11428 branches covered (71.31%)

Branch coverage included in aggregate %.

29 of 120 new or added lines in 8 files covered. (24.17%)

2 existing lines in 2 files now uncovered.

29491 of 37280 relevant lines covered (79.11%)

151024.68 hits per line

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

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

145
                                        this._reader.ReadNext();
4,055✔
146

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

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

160
                                        return unknownEntityTemplate;
4,055✔
161
                        }
162
                }
77,390✔
163

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

169
                        DxfMap map = DxfMap.Create<T>();
72,759✔
170

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

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

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

192
                        return template;
72,759✔
193
                }
72,759✔
194

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

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

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

228
                private void readCadValue()
NEW
229
                {
×
NEW
230
                        this._reader.ReadNext();
×
231

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

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

NEW
264
                                this._reader.ReadNext();
×
NEW
265
                        }
×
NEW
266
                }
×
267

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

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

322
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
323
                {
23,355✔
324
                        switch (this._reader.Code)
23,355✔
325
                        {
326
                                default:
327
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,355✔
328
                        }
329
                }
23,355✔
330

331
                private bool readPlotSettings(CadTemplate template, DxfMap map)
332
                {
25,534✔
333
                        switch (this._reader.Code)
25,534✔
334
                        {
335
                                default:
336
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,534✔
337
                        }
338
                }
25,534✔
339

340
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
341
                {
3,096✔
342
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,096✔
343
                        EvaluationGraph evGraph = tmp.CadObject;
3,096✔
344

345
                        switch (this._reader.Code)
3,096✔
346
                        {
347
                                case 91:
348
                                        while (this._reader.Code == 91)
3,025✔
349
                                        {
2,574✔
350
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,574✔
351
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,574✔
352

353
                                                node.Index = this._reader.ValueAsInt;
2,574✔
354

355
                                                this._reader.ExpectedCode(93);
2,574✔
356
                                                node.Flags = this._reader.ValueAsInt;
2,574✔
357

358
                                                this._reader.ExpectedCode(95);
2,574✔
359
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,574✔
360

361
                                                this._reader.ExpectedCode(360);
2,574✔
362
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,574✔
363

364
                                                this._reader.ExpectedCode(92);
2,574✔
365
                                                node.Data1 = this._reader.ValueAsInt;
2,574✔
366
                                                this._reader.ExpectedCode(92);
2,574✔
367
                                                node.Data2 = this._reader.ValueAsInt;
2,574✔
368
                                                this._reader.ExpectedCode(92);
2,574✔
369
                                                node.Data3 = this._reader.ValueAsInt;
2,574✔
370
                                                this._reader.ExpectedCode(92);
2,574✔
371
                                                node.Data4 = this._reader.ValueAsInt;
2,574✔
372

373
                                                this._reader.ReadNext();
2,574✔
374

375
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
376
                                        }
2,574✔
377

378
                                        this.lockPointer = true;
451✔
379
                                        return true;
451✔
380
                                case 92:
381
                                        //Edges
382
                                        while (this._reader.Code == 92)
2,126✔
383
                                        {
1,931✔
384
                                                this._reader.ExpectedCode(93);
1,931✔
385
                                                this._reader.ExpectedCode(94);
1,931✔
386
                                                this._reader.ExpectedCode(91);
1,931✔
387
                                                this._reader.ExpectedCode(91);
1,931✔
388
                                                this._reader.ExpectedCode(92);
1,931✔
389
                                                this._reader.ExpectedCode(92);
1,931✔
390
                                                this._reader.ExpectedCode(92);
1,931✔
391
                                                this._reader.ExpectedCode(92);
1,931✔
392
                                                this._reader.ExpectedCode(92);
1,931✔
393

394
                                                this._reader.ReadNext();
1,931✔
395
                                        }
1,931✔
396

397
                                        this.lockPointer = true;
195✔
398
                                        return true;
195✔
399
                                default:
400
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,450✔
401
                        }
402
                }
3,096✔
403

404
                private bool readLayout(CadTemplate template, DxfMap map)
405
                {
51,979✔
406
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,979✔
407

408
                        switch (this._reader.Code)
51,979✔
409
                        {
410
                                case 330:
411
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,614✔
412
                                        return true;
1,614✔
413
                                case 331:
414
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
773✔
415
                                        return true;
773✔
416
                                default:
417
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,592✔
418
                                        {
25,534✔
419
                                                return this.readPlotSettings(template, map);
25,534✔
420
                                        }
421
                                        return true;
24,058✔
422
                        }
423
                }
51,979✔
424

425
                private bool readGroup(CadTemplate template, DxfMap map)
426
                {
4,992✔
427
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
428

429
                        switch (this._reader.Code)
4,992✔
430
                        {
431
                                case 70:
432
                                        return true;
384✔
433
                                case 340:
434
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
435
                                        return true;
2,304✔
436
                                default:
437
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
438
                        }
439
                }
4,992✔
440

441
                private bool readGeoData(CadTemplate template, DxfMap map)
442
                {
102✔
443
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
444

445
                        switch (this._reader.Code)
102✔
446
                        {
447
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
448
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
449
                                                tmp.CadObject.ReferencePoint.X,
1✔
450
                                                this._reader.ValueAsDouble,
1✔
451
                                                tmp.CadObject.ReferencePoint.Z
1✔
452
                                                );
1✔
453
                                        return true;
1✔
454
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
455
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
456
                                                this._reader.ValueAsDouble,
1✔
457
                                                tmp.CadObject.ReferencePoint.Y,
1✔
458
                                                tmp.CadObject.ReferencePoint.Z
1✔
459
                                                );
1✔
460
                                        return true;
1✔
461
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
462
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
463
                                                tmp.CadObject.ReferencePoint.X,
1✔
464
                                                tmp.CadObject.ReferencePoint.Y,
1✔
465
                                                this._reader.ValueAsDouble
1✔
466
                                                );
1✔
467
                                        return true;
1✔
468
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
469
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
470
                                        return true;
1✔
471
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
472
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
473
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
474
                                        return true;
1✔
475
                                // Number of Geo-Mesh points
476
                                case 93:
477
                                        var npts = this._reader.ValueAsInt;
3✔
478
                                        for (int i = 0; i < npts; i++)
54✔
479
                                        {
24✔
480
                                                this._reader.ReadNext();
24✔
481
                                                double sourceX = this._reader.ValueAsDouble;
24✔
482
                                                this._reader.ReadNext();
24✔
483
                                                double sourceY = this._reader.ValueAsDouble;
24✔
484

485
                                                this._reader.ReadNext();
24✔
486
                                                double destX = this._reader.ValueAsDouble;
24✔
487
                                                this._reader.ReadNext();
24✔
488
                                                double destY = this._reader.ValueAsDouble;
24✔
489

490
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
491
                                                {
24✔
492
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
493
                                                        Destination = new CSMath.XY(destX, destY)
24✔
494
                                                });
24✔
495
                                        }
24✔
496
                                        return true;
3✔
497
                                // Number of Geo-Mesh points
498
                                case 96:
499
                                        var nfaces = this._reader.ValueAsInt;
2✔
500
                                        for (int i = 0; i < nfaces; i++)
4!
501
                                        {
×
502
                                                this._reader.ReadNext();
×
503
                                                Debug.Assert(this._reader.Code == 97);
×
504
                                                int index1 = this._reader.ValueAsInt;
×
505
                                                this._reader.ReadNext();
×
506
                                                Debug.Assert(this._reader.Code == 98);
×
507
                                                int index2 = this._reader.ValueAsInt;
×
508
                                                this._reader.ReadNext();
×
509
                                                Debug.Assert(this._reader.Code == 99);
×
510
                                                int index3 = this._reader.ValueAsInt;
×
511

512
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
513
                                                {
×
514
                                                        Index1 = index1,
×
515
                                                        Index2 = index2,
×
516
                                                        Index3 = index3
×
517
                                                });
×
518
                                        }
×
519
                                        return true;
2✔
520
                                case 303:
521
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
522
                                        return true;
13✔
523
                                //Obsolete codes for version GeoDataVersion.R2009
524
                                case 3:
525
                                case 4:
526
                                case 14:
527
                                case 24:
528
                                case 15:
529
                                case 25:
530
                                case 43:
531
                                case 44:
532
                                case 45:
533
                                case 94:
534
                                case 293:
535
                                case 16:
536
                                case 26:
537
                                case 17:
538
                                case 27:
539
                                case 54:
540
                                case 140:
541
                                case 304:
542
                                case 292:
543
                                        return true;
19✔
544
                                default:
545
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
546
                        }
547
                }
102✔
548

549
                private bool readMaterial(CadTemplate template, DxfMap map)
550
                {
42,114✔
551
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,114✔
552
                        List<double> arr = null;
42,114✔
553

554
                        switch (this._reader.Code)
42,114!
555
                        {
556
                                case 43:
557
                                        arr = new();
1,349✔
558
                                        for (int i = 0; i < 16; i++)
45,866✔
559
                                        {
21,584✔
560
                                                Debug.Assert(this._reader.Code == 43);
21,584✔
561

562
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
563

564
                                                this._reader.ReadNext();
21,584✔
565
                                        }
21,584✔
566

567
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,349✔
568
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,349✔
569
                                case 47:
570
                                        arr = new();
×
571
                                        for (int i = 0; i < 16; i++)
×
572
                                        {
×
573
                                                Debug.Assert(this._reader.Code == 47);
×
574

575
                                                arr.Add(this._reader.ValueAsDouble);
×
576

577
                                                this._reader.ReadNext();
×
578
                                        }
×
579

580
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
581
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
582
                                case 49:
583
                                        arr = new();
197✔
584
                                        for (int i = 0; i < 16; i++)
6,698✔
585
                                        {
3,152✔
586
                                                Debug.Assert(this._reader.Code == 49);
3,152✔
587

588
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
589

590
                                                this._reader.ReadNext();
3,152✔
591
                                        }
3,152✔
592

593
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
594
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
595
                                case 142:
596
                                        arr = new();
197✔
597
                                        for (int i = 0; i < 16; i++)
6,698✔
598
                                        {
3,152✔
599
                                                Debug.Assert(this._reader.Code == 142);
3,152✔
600

601
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
602

603
                                                this._reader.ReadNext();
3,152✔
604
                                        }
3,152✔
605

606
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
607
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
608
                                case 144:
609
                                        arr = new();
1,157✔
610
                                        for (int i = 0; i < 16; i++)
39,338✔
611
                                        {
18,512✔
612
                                                Debug.Assert(this._reader.Code == 144);
18,512✔
613

614
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
615

616
                                                this._reader.ReadNext();
18,512✔
617
                                        }
18,512✔
618

619
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,157✔
620
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,157✔
621
                                case 147:
622
                                        arr = new();
×
623
                                        for (int i = 0; i < 16; i++)
×
624
                                        {
×
625
                                                Debug.Assert(this._reader.Code == 147);
×
626

627
                                                arr.Add(this._reader.ValueAsDouble);
×
628

629
                                                this._reader.ReadNext();
×
630
                                        }
×
631

632
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
633
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
634
                                default:
635
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,214✔
636
                        }
637
                }
42,114✔
638

639
                private bool readScale(CadTemplate template, DxfMap map)
640
                {
60,141✔
641
                        switch (this._reader.Code)
60,141✔
642
                        {
643
                                // Undocumented codes
644
                                case 70:
645
                                        //Always 0
646
                                        return true;
6,705✔
647
                                default:
648
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
53,436✔
649
                        }
650
                }
60,141✔
651

652
                private void readLinkedData(CadTemplate template, DxfMap map)
653
                {
320✔
654
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
655
                        LinkedData linkedData = tmp.CadObject;
320✔
656

657
                        this._reader.ReadNext();
320✔
658

659
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
660
                        {
640✔
661
                                switch (this._reader.Code)
640✔
662
                                {
663
                                        default:
664
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
665
                                                {
×
666
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
667
                                                }
×
668
                                                break;
640✔
669
                                }
670

671
                                this._reader.ReadNext();
640✔
672
                        }
640✔
673
                }
320✔
674

675
                private bool readTableContent(CadTemplate template, DxfMap map)
676
                {
2,368✔
677
                        switch (this._reader.Code)
2,368✔
678
                        {
679
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
680
                                        this.readTableContentSubclass(template, map);
256✔
681
                                        this.lockPointer = true;
256✔
682
                                        return true;
256✔
683
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
684
                                        this.readFormattedTableDataSubclass(template, map);
256✔
685
                                        this.lockPointer = true;
256✔
686
                                        return true;
256✔
687
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
688
                                        this.readLinkedTableDataSubclass(template, map);
320✔
689
                                        this.lockPointer = true;
320✔
690
                                        return true;
320✔
691
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
692
                                        this.readLinkedData(template, map);
320✔
693
                                        this.lockPointer = true;
320✔
694
                                        return true;
320✔
695
                                default:
696
                                        return false;
1,216✔
697
                        }
698
                }
2,368✔
699

700
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
701
                {
256✔
702
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
703
                        TableContent tableContent = tmp.CadObject;
256✔
704

705
                        this._reader.ReadNext();
256✔
706

707
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
708
                        {
256✔
709
                                switch (this._reader.Code)
256!
710
                                {
711
                                        case 340:
712
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
713
                                                break;
256✔
714
                                        default:
715
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
716
                                                {
×
717
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
718
                                                }
×
719
                                                break;
×
720
                                }
721

722
                                this._reader.ReadNext();
256✔
723
                        }
256✔
724
                }
256✔
725

726
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
727
                {
256✔
728
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
729
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
730

731
                        this._reader.ReadNext();
256✔
732

733
                        TableEntity.CellRange cellRange = null;
256✔
734
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
735
                        {
2,048✔
736
                                switch (this._reader.Code)
2,048!
737
                                {
738
                                        case 90:
739
                                                break;
256✔
740
                                        case 91:
741
                                                if (cellRange == null)
384✔
742
                                                {
384✔
743
                                                        cellRange = new();
384✔
744
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
745
                                                }
384✔
746
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
747
                                                break;
384✔
748
                                        case 92:
749
                                                if (cellRange == null)
384!
750
                                                {
×
751
                                                        cellRange = new();
×
752
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
753
                                                }
×
754
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
755
                                                break;
384✔
756
                                        case 93:
757
                                                if (cellRange == null)
384!
758
                                                {
×
759
                                                        cellRange = new();
×
760
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
761
                                                }
×
762
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
763
                                                break;
384✔
764
                                        case 94:
765
                                                if (cellRange == null)
384!
766
                                                {
×
767
                                                        cellRange = new();
×
768
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
769
                                                }
×
770
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
771
                                                cellRange = null;
384✔
772
                                                break;
384✔
773
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
774
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
775
                                                break;
256✔
776
                                        default:
777
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
778
                                                {
×
779
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
780
                                                }
×
781
                                                break;
×
782
                                }
783

784
                                this._reader.ReadNext();
2,048✔
785
                        }
2,048✔
786
                }
256✔
787

788
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
789
                {
320✔
790
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
791
                        TableContent tableContent = tmp.CadObject;
320✔
792

793
                        this._reader.ReadNext();
320✔
794

795
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
796
                        {
3,904✔
797
                                switch (this._reader.Code)
3,904✔
798
                                {
799
                                        case 90:
800
                                                //Column count
801
                                                break;
320✔
802
                                        case 91:
803
                                                //Row count
804
                                                break;
320✔
805
                                        //Unknown
806
                                        case 92:
807
                                                break;
256✔
808
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
809
                                                //Read Column
810
                                                this.readTableColumn();
1,216✔
811
                                                break;
1,216✔
812
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
813
                                                //Read Row
814
                                                this.readTableRow();
1,472✔
815
                                                break;
1,472✔
816
                                        default:
817
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
818
                                                {
320✔
819
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
820
                                                }
320✔
821
                                                break;
320✔
822
                                }
823

824
                                this._reader.ReadNext();
3,904✔
825
                        }
3,904✔
826
                }
320✔
827

828

829
                private TableEntity.Column readTableColumn()
830
                {
1,216✔
831
                        this._reader.ReadNext();
1,216✔
832

833
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
834

835
                        bool end = false;
1,216✔
836
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
837
                        {
3,648✔
838
                                switch (this._reader.Code)
3,648!
839
                                {
840
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
841
                                                this.readLinkedTableColumn(column);
1,216✔
842
                                                break;
1,216✔
843
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
844
                                                this.readFormattedTableColumn(column);
1,216✔
845
                                                break;
1,216✔
846
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
847
                                                this.readTableColumn(column);
1,216✔
848
                                                end = true;
1,216✔
849
                                                break;
1,216✔
850
                                        default:
851
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
852
                                                break;
×
853
                                }
854

855
                                if (end)
3,648✔
856
                                {
1,216✔
857
                                        return column;
1,216✔
858
                                }
859

860
                                this._reader.ReadNext();
2,432✔
861
                        }
2,432✔
862

863
                        return column;
×
864
                }
1,216✔
865

866
                private TableEntity.Row readTableRow()
867
                {
1,472✔
868
                        this._reader.ReadNext();
1,472✔
869

870
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
871

872
                        bool end = false;
1,472✔
873
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
874
                        {
11,840✔
875
                                switch (this._reader.Code)
11,840✔
876
                                {
877
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
878
                                                this.readLinkedTableRow(row);
1,536✔
879
                                                break;
1,536✔
880
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
881
                                                this.readFormattedTableRow(row);
1,408✔
882
                                                break;
1,408✔
883
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
884
                                                this.readTableRow(row);
1,408✔
885
                                                end = true;
1,408✔
886
                                                break;
1,408✔
887
                                        default:
888
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
889
                                                break;
7,488✔
890
                                }
891

892
                                if (end)
11,840✔
893
                                {
1,408✔
894
                                        return row;
1,408✔
895
                                }
896

897
                                this._reader.ReadNext();
10,432✔
898
                        }
10,432✔
899

900
                        return row;
64✔
901
                }
1,472✔
902

903
                private void readTableRow(TableEntity.Row row)
904
                {
1,408✔
905
                        this._reader.ReadNext();
1,408✔
906

907
                        bool end = false;
1,408✔
908
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
909
                        {
4,224✔
910
                                switch (this._reader.Code)
4,224!
911
                                {
912
                                        case 40:
913
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
914
                                                break;
1,408✔
915
                                        case 90:
916
                                                //styleID
917
                                                break;
1,408✔
918
                                        case 309:
919
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
920
                                                break;
1,408✔
921
                                        default:
922
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
923
                                                break;
×
924
                                }
925

926
                                if (end)
4,224✔
927
                                {
1,408✔
928
                                        break;
1,408✔
929
                                }
930

931
                                this._reader.ReadNext();
2,816✔
932
                        }
2,816✔
933
                }
1,408✔
934

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

939
                        bool end = false;
1,408✔
940
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
941
                        {
4,224✔
942
                                switch (this._reader.Code)
4,224!
943
                                {
944
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
945
                                                break;
1,408✔
946
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
947
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
948
                                                break;
1,408✔
949
                                        case 309:
950
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
951
                                                break;
1,408✔
952
                                        default:
953
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
954
                                                break;
×
955
                                }
956

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

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

966
                private void readTableColumn(TableEntity.Column column)
967
                {
1,216✔
968
                        this._reader.ReadNext();
1,216✔
969

970
                        bool end = false;
1,216✔
971
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
972
                        {
3,648✔
973
                                switch (this._reader.Code)
3,648!
974
                                {
975
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
976
                                                break;
×
977
                                        case 1:
978
                                                end = true;
×
979
                                                break;
×
980
                                        case 40:
981
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
982
                                                break;
1,216✔
983
                                        case 90:
984
                                                //StyleId
985
                                                break;
1,216✔
986
                                        case 309:
987
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
988
                                                break;
1,216✔
989
                                        default:
990
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
991
                                                break;
×
992
                                }
993

994
                                if (end)
3,648✔
995
                                {
1,216✔
996
                                        break;
1,216✔
997
                                }
998

999
                                this._reader.ReadNext();
2,432✔
1000
                        }
2,432✔
1001
                }
1,216✔
1002

1003
                private void readLinkedTableColumn(TableEntity.Column column)
1004
                {
1,216✔
1005
                        this._reader.ReadNext();
1,216✔
1006

1007
                        bool end = false;
1,216✔
1008
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
1009
                        {
4,864✔
1010
                                switch (this._reader.Code)
4,864!
1011
                                {
1012
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
1013
                                                break;
×
1014
                                        case 1:
1015
                                                end = true;
×
1016
                                                break;
×
1017
                                        case 91:
1018
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
1019
                                                break;
1,216✔
1020
                                        case 300:
1021
                                                column.Name = this._reader.ValueAsString;
1,216✔
1022
                                                break;
1,216✔
1023
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
1024
                                                this.readCustomData();
1,216✔
1025
                                                break;
1,216✔
1026
                                        case 309:
1027
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_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(readLinkedTableColumn)} method.", NotificationType.None);
×
1031
                                                break;
×
1032
                                }
1033

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

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

1043
                private void readLinkedTableRow(TableEntity.Row row)
1044
                {
1,536✔
1045
                        this._reader.ReadNext();
1,536✔
1046

1047
                        bool end = false;
1,536✔
1048
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
1049
                        {
12,480✔
1050
                                switch (this._reader.Code)
12,480!
1051
                                {
1052
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
1053
                                                break;
×
1054
                                        case 90:
1055
                                                break;
1,536✔
1056
                                        case 91:
1057
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
1058
                                                break;
1,408✔
1059
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1060
                                                this.readCell();
5,376✔
1061
                                                break;
5,376✔
1062
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
1063
                                                this.readCustomData();
1,408✔
1064
                                                break;
1,408✔
1065
                                        case 309:
1066
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
1067
                                                break;
1,408✔
1068
                                        default:
1069
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
1070
                                                break;
1,344✔
1071
                                }
1072

1073
                                if (end)
12,480✔
1074
                                {
1,408✔
1075
                                        break;
1,408✔
1076
                                }
1077

1078
                                this._reader.ReadNext();
11,072✔
1079
                        }
11,072✔
1080
                }
1,536✔
1081

1082
                private TableEntity.Cell readCell()
1083
                {
5,376✔
1084
                        this._reader.ReadNext();
5,376✔
1085

1086
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
1087
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
1088

1089
                        bool end = false;
5,376✔
1090
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
1091
                        {
16,832✔
1092
                                switch (this._reader.Code)
16,832✔
1093
                                {
1094
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
1095
                                                this.readLinkedTableCell(cell);
5,376✔
1096
                                                break;
5,376✔
1097
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
1098
                                                this.readFormattedTableCell(cell);
5,248✔
1099
                                                break;
5,248✔
1100
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1101
                                                this.readTableCell(cell);
5,248✔
1102
                                                end = true;
5,248✔
1103
                                                break;
5,248✔
1104
                                        default:
1105
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1106
                                                break;
960✔
1107
                                }
1108

1109
                                if (end)
16,832✔
1110
                                {
5,248✔
1111
                                        return cell;
5,248✔
1112
                                }
1113

1114
                                this._reader.ReadNext();
11,584✔
1115
                        }
11,584✔
1116

1117
                        return cell;
128✔
1118
                }
5,376✔
1119

1120
                private void readTableCell(TableEntity.Cell cell)
1121
                {
5,248✔
1122
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1123

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

1126
                        bool end = false;
5,248✔
1127
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1128
                        {
16,384✔
1129
                                switch (this._reader.Code)
16,384✔
1130
                                {
1131
                                        //Unknown
1132
                                        case 40:
1133
                                        case 41:
1134
                                                break;
256✔
1135
                                        case 309:
1136
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1137
                                                break;
5,248✔
1138
                                        case 330:
1139
                                                //Unknown handle
1140
                                                break;
128✔
1141
                                        default:
1142
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1143
                                                {
×
1144
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1145
                                                }
×
1146
                                                break;
10,752✔
1147
                                }
1148

1149
                                if (end)
16,384✔
1150
                                {
5,248✔
1151
                                        break;
5,248✔
1152
                                }
1153

1154
                                this._reader.ReadNext();
11,136✔
1155
                        }
11,136✔
1156
                }
5,248✔
1157

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

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

1164
                        bool end = false;
5,248✔
1165
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1166
                        {
10,496✔
1167
                                switch (this._reader.Code)
10,496!
1168
                                {
1169
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1170
                                                this.readCellTableFormat(cell);
5,248✔
1171
                                                continue;
5,248✔
1172
                                        case 309:
1173
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1174
                                                break;
5,248✔
1175
                                        default:
1176
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1177
                                                {
×
1178
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1179
                                                }
×
1180
                                                break;
×
1181
                                }
1182

1183
                                if (end)
5,248!
1184
                                {
5,248✔
1185
                                        break;
5,248✔
1186
                                }
1187

1188
                                this._reader.ReadNext();
×
1189
                        }
×
1190
                }
5,248✔
1191

1192
                private void readCellTableFormat(TableEntity.Cell cell)
1193
                {
5,248✔
1194
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1195

1196
                        this._reader.ReadNext();
5,248✔
1197

1198
                        bool end = false;
5,248✔
1199
                        while (this._reader.Code == 1)
10,496✔
1200
                        {
5,248✔
1201
                                switch (this._reader.Code)
5,248!
1202
                                {
1203
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1204
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1205
                                                break;
5,248✔
1206
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1207
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1208
                                                break;
×
1209
                                        default:
1210
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1211
                                                {
×
1212
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1213
                                                }
×
1214
                                                break;
×
1215
                                }
1216

1217
                                if (end)
5,248!
1218
                                {
×
1219
                                        break;
×
1220
                                }
1221

1222
                                this._reader.ReadNext();
5,248✔
1223
                        }
5,248✔
1224
                }
5,248✔
1225

1226
                private void readCellStyle(CadCellStyleTemplate template)
1227
                {
×
1228
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1229

1230
                        this._reader.ReadNext();
×
1231

1232
                        bool end = false;
×
1233
                        while (this._reader.Code != 1)
×
1234
                        {
×
1235
                                switch (this._reader.Code)
×
1236
                                {
1237
                                        case 309:
1238
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1239
                                                break;
×
1240
                                        default:
1241
                                                //if (!this.tryAssignCurrentValue(cell, map))
1242
                                                {
×
1243
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1244
                                                }
×
1245
                                                break;
×
1246
                                }
1247

1248
                                if (end)
×
1249
                                {
×
1250
                                        break;
×
1251
                                }
1252

1253
                                this._reader.ReadNext();
×
1254
                        }
×
1255
                }
×
1256

1257
                private void readLinkedTableCell(TableEntity.Cell cell)
1258
                {
5,376✔
1259
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1260

1261
                        this._reader.ReadNext();
5,376✔
1262

1263
                        bool end = false;
5,376✔
1264
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1265
                        {
53,760✔
1266
                                switch (this._reader.Code)
53,760✔
1267
                                {
1268
                                        case 95:
1269
                                                //BL 95 Number of cell contents
1270
                                                break;
5,248✔
1271
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1272
                                                this.readCustomData();
5,376✔
1273
                                                break;
5,376✔
1274
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1275
                                                var c = this.readLinkedTableCellContent();
4,096✔
1276
                                                break;
4,096✔
1277
                                        case 309:
1278
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1279
                                                break;
5,248✔
1280
                                        default:
1281
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1282
                                                {
11,648✔
1283
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1284
                                                }
11,648✔
1285
                                                break;
33,792✔
1286
                                }
1287

1288
                                if (end)
53,760✔
1289
                                {
5,248✔
1290
                                        break;
5,248✔
1291
                                }
1292

1293
                                this._reader.ReadNext();
48,512✔
1294
                        }
48,512✔
1295
                }
5,376✔
1296

1297
                private CadTableCellContentTemplate readLinkedTableCellContent()
1298
                {
4,096✔
1299
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1300
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1301
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1302

1303
                        this._reader.ReadNext();
4,096✔
1304

1305
                        bool end = false;
4,096✔
1306
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1307
                        {
8,192✔
1308
                                switch (this._reader.Code)
8,192!
1309
                                {
1310
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1311
                                                readFormattedCellContent();
4,096✔
1312
                                                end = true;
4,096✔
1313
                                                break;
4,096✔
1314
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1315
                                                readCellContent(template);
4,096✔
1316
                                                break;
4,096✔
1317
                                        default:
1318
                                                if (!this.tryAssignCurrentValue(content, map))
×
1319
                                                {
×
1320
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1321
                                                }
×
1322
                                                break;
×
1323
                                }
1324

1325
                                if (end)
8,192✔
1326
                                {
4,096✔
1327
                                        break;
4,096✔
1328
                                }
1329

1330
                                this._reader.ReadNext();
4,096✔
1331
                        }
4,096✔
1332

1333
                        return template;
4,096✔
1334
                }
4,096✔
1335

1336
                private void readCellContent(CadTableCellContentTemplate template)
1337
                {
4,096✔
1338
                        TableEntity.CellContent content = template.Content;
4,096✔
1339
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1340

1341
                        this._reader.ReadNext();
4,096✔
1342

1343
                        bool end = false;
4,096✔
1344
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1345
                        {
16,384✔
1346
                                switch (this._reader.Code)
16,384✔
1347
                                {
1348
                                        case 91:
1349
                                                break;
4,096✔
1350
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1351
                                                this.readDataMapValue();
3,712✔
1352
                                                break;
3,712✔
1353
                                        case 309:
1354
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1355
                                                break;
4,096✔
1356
                                        case 340:
1357
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1358
                                                break;
384✔
1359
                                        default:
1360
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1361
                                                {
×
1362
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1363
                                                }
×
1364
                                                break;
4,096✔
1365
                                }
1366

1367
                                if (end)
16,384✔
1368
                                {
4,096✔
1369
                                        break;
4,096✔
1370
                                }
1371

1372
                                this._reader.ReadNext();
12,288✔
1373
                        }
12,288✔
1374
                }
4,096✔
1375

1376
                private void readFormattedCellContent()
1377
                {
4,096✔
1378
                        TableEntity.ContentFormat format = new();
4,096✔
1379
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1380
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1381

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

1384
                        bool end = false;
4,096✔
1385
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1386
                        {
12,288✔
1387
                                switch (this._reader.Code)
12,288✔
1388
                                {
1389
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1390
                                                readContentFormat(template);
4,096✔
1391
                                                break;
4,096✔
1392
                                        case 309:
1393
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1394
                                                break;
4,096✔
1395
                                        default:
1396
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1397
                                                {
×
1398
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1399
                                                }
×
1400
                                                break;
4,096✔
1401
                                }
1402

1403
                                if (end)
12,288✔
1404
                                {
4,096✔
1405
                                        break;
4,096✔
1406
                                }
1407

1408
                                this._reader.ReadNext();
8,192✔
1409
                        }
8,192✔
1410
                }
4,096✔
1411

1412
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1413
                {
9,600✔
1414
                        var format = template.Format;
9,600✔
1415
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1416

1417
                        this._reader.ReadNext();
9,600✔
1418

1419
                        bool end = false;
9,600✔
1420
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1421
                        {
124,800✔
1422
                                switch (this._reader.Code)
124,800✔
1423
                                {
1424
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1425
                                                break;
9,600✔
1426
                                        case 309:
1427
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1428
                                                break;
9,600✔
1429
                                        case 340:
1430
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1431
                                                break;
9,600✔
1432
                                        default:
1433
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1434
                                                {
×
1435
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1436
                                                }
×
1437
                                                break;
96,000✔
1438
                                }
1439

1440
                                if (end)
124,800✔
1441
                                {
9,600✔
1442
                                        break;
9,600✔
1443
                                }
1444

1445
                                this._reader.ReadNext();
115,200✔
1446
                        }
115,200✔
1447
                }
9,600✔
1448

1449
                private void readFormattedTableColumn(TableEntity.Column column)
1450
                {
1,216✔
1451
                        this._reader.ReadNext();
1,216✔
1452

1453
                        bool end = false;
1,216✔
1454
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1455
                        {
3,648✔
1456
                                switch (this._reader.Code)
3,648!
1457
                                {
1458
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1459
                                                break;
1,216✔
1460
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1461
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1462
                                                break;
1,216✔
1463
                                        case 309:
1464
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1465
                                                break;
1,216✔
1466
                                        default:
1467
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1468
                                                break;
×
1469
                                }
1470

1471
                                if (end)
3,648✔
1472
                                {
1,216✔
1473
                                        break;
1,216✔
1474
                                }
1475

1476
                                this._reader.ReadNext();
2,432✔
1477
                        }
2,432✔
1478
                }
1,216✔
1479

1480
                private void readStyleOverride(CadCellStyleTemplate template)
1481
                {
8,128✔
1482
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1483
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1484
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1485

1486
                        this._reader.ReadNext();
8,128✔
1487

1488
                        bool end = false;
8,128✔
1489
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1490
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1491
                        {
89,536✔
1492
                                switch (this._reader.Code)
89,536✔
1493
                                {
1494
                                        case 95:
1495
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1496
                                                break;
11,776✔
1497
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1498
                                                break;
256✔
1499
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1500
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1501
                                                break;
5,504✔
1502
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1503
                                                this.readCellMargin(template);
2,816✔
1504
                                                break;
2,816✔
1505
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1506
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1507
                                                this.readGridFormat(template, border);
11,776✔
1508
                                                break;
11,776✔
1509
                                        case 309:
1510
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1511
                                                break;
8,128✔
1512
                                        default:
1513
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
1514
                                                {
×
1515
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1516
                                                }
×
1517
                                                break;
49,280✔
1518
                                }
1519

1520
                                if (end)
89,536✔
1521
                                {
8,128✔
1522
                                        break;
8,128✔
1523
                                }
1524

1525
                                this._reader.ReadNext();
81,408✔
1526
                        }
81,408✔
1527
                }
8,128✔
1528

1529
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1530
                {
11,776✔
1531
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1532

1533
                        this._reader.ReadNext();
11,776✔
1534

1535
                        bool end = false;
11,776✔
1536
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1537
                        {
105,984✔
1538
                                switch (this._reader.Code)
105,984✔
1539
                                {
1540
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1541
                                                break;
11,776✔
1542
                                        case 62:
1543
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1544
                                                break;
11,776✔
1545
                                        case 92:
1546
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1547
                                                break;
11,776✔
1548
                                        case 93:
1549
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1550
                                                break;
11,776✔
1551
                                        case 340:
1552
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1553
                                                break;
11,776✔
1554
                                        case 309:
1555
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1556
                                                break;
11,776✔
1557
                                        default:
1558
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
1559
                                                {
×
1560
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1561
                                                }
×
1562
                                                break;
35,328✔
1563
                                }
1564

1565
                                if (end)
105,984✔
1566
                                {
11,776✔
1567
                                        break;
11,776✔
1568
                                }
1569

1570
                                this._reader.ReadNext();
94,208✔
1571
                        }
94,208✔
1572
                }
11,776✔
1573

1574
                private void readCellMargin(CadCellStyleTemplate template)
1575
                {
2,816✔
1576
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1577

1578
                        this._reader.ReadNext();
2,816✔
1579

1580
                        bool end = false;
2,816✔
1581
                        int i = 0;
2,816✔
1582
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1583
                        {
22,528✔
1584
                                switch (this._reader.Code)
22,528!
1585
                                {
1586
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1587
                                                break;
2,816✔
1588
                                        case 40:
1589
                                                switch (i)
16,896✔
1590
                                                {
1591
                                                        case 0:
1592
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1593
                                                                break;
2,816✔
1594
                                                        case 1:
1595
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1596
                                                                break;
2,816✔
1597
                                                        case 2:
1598
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1599
                                                                break;
2,816✔
1600
                                                        case 3:
1601
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1602
                                                                break;
2,816✔
1603
                                                        case 4:
1604
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1605
                                                                break;
2,816✔
1606
                                                        case 5:
1607
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1608
                                                                break;
2,816✔
1609
                                                }
1610

1611
                                                i++;
16,896✔
1612
                                                break;
16,896✔
1613
                                        case 309:
1614
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1615
                                                break;
2,816✔
1616
                                        default:
1617
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1618
                                                break;
×
1619
                                }
1620

1621
                                if (end)
22,528✔
1622
                                {
2,816✔
1623
                                        break;
2,816✔
1624
                                }
1625

1626
                                this._reader.ReadNext();
19,712✔
1627
                        }
19,712✔
1628
                }
2,816✔
1629

1630
                private void readCustomData()
1631
                {
8,000✔
1632
                        this._reader.ReadNext();
8,000✔
1633

1634
                        int ndata = 0;
8,000✔
1635
                        bool end = false;
8,000✔
1636
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1637
                        {
74,304✔
1638
                                switch (this._reader.Code)
74,304✔
1639
                                {
1640
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1641
                                                break;
8,000✔
1642
                                        case 90:
1643
                                                ndata = this._reader.ValueAsInt;
8,128✔
1644
                                                break;
8,128✔
1645
                                        case 300:
1646
                                                //Name
1647
                                                break;
5,248✔
1648
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1649
                                                this.readDataMapValue();
5,248✔
1650
                                                break;
5,248✔
1651
                                        case 309:
1652
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1653
                                                break;
7,872✔
1654
                                        default:
1655
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1656
                                                break;
39,808✔
1657
                                }
1658

1659
                                if (end)
74,304✔
1660
                                {
7,872✔
1661
                                        break;
7,872✔
1662
                                }
1663

1664
                                this._reader.ReadNext();
66,432✔
1665
                        }
66,432✔
1666
                }
8,000✔
1667

1668
                private void readDataMapValue()
1669
                {
8,960✔
1670
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1671
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1672

1673
                        this._reader.ReadNext();
8,960✔
1674

1675
                        bool end = false;
8,960✔
1676
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1677
                        {
330,112✔
1678
                                switch (this._reader.Code)
330,112✔
1679
                                {
1680
                                        case 11:
1681
                                        case 21:
1682
                                        case 31:
1683
                                                //Value as point
1684
                                                break;
768✔
1685
                                        case 91:
1686
                                        case 92:
1687
                                                //Value as int
1688
                                                break;
38,912✔
1689
                                        case 140:
1690
                                                //Value as double
1691
                                                break;
13,248✔
1692
                                        case 310:
1693
                                                //Value as byte array
1694
                                                break;
256✔
1695
                                        case 304:
1696
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1697
                                                break;
8,832✔
1698
                                        default:
1699
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1700
                                                {
106,880✔
1701
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1702
                                                }
106,880✔
1703
                                                break;
268,096✔
1704
                                }
1705

1706
                                if (end)
330,112✔
1707
                                {
8,832✔
1708
                                        break;
8,832✔
1709
                                }
1710

1711
                                this._reader.ReadNext();
321,280✔
1712
                        }
321,280✔
1713
                }
8,960✔
1714

1715
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1716
                {
379,506✔
1717
                        switch (this._reader.Code)
379,506✔
1718
                        {
1719
                                // Undocumented codes
1720
                                case 176:
1721
                                case 177:
1722
                                case 420:
1723
                                        return true;
123,592✔
1724
                                default:
1725
                                        //Avoid noise while is not implemented
1726
                                        return true;
255,914✔
1727
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1728
                        }
1729
                }
379,506✔
1730

1731
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1732
                {
4,032✔
1733
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1734
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1735

1736
                        switch (this._reader.Code)
4,032✔
1737
                        {
1738
                                case 10:
1739
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1740
                                        return true;
384✔
1741
                                case 20:
1742
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1743
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1744
                                        return true;
384✔
1745
                                case 40:
1746
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1747
                                        {
×
1748
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1749
                                                tmp.HasFrontPlane = true;
×
1750
                                        }
×
1751

1752
                                        double[] array = new double[16]
384✔
1753
                                        {
384✔
1754
                                                0.0, 0.0, 0.0, 0.0,
384✔
1755
                                                0.0, 0.0, 0.0, 0.0,
384✔
1756
                                                0.0, 0.0, 0.0, 0.0,
384✔
1757
                                                0.0, 0.0, 0.0, 1.0
384✔
1758
                                        };
384✔
1759

1760
                                        for (int i = 0; i < 12; i++)
9,984✔
1761
                                        {
4,608✔
1762
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1763

1764
                                                if (i < 11)
4,608✔
1765
                                                {
4,224✔
1766
                                                        this._reader.ReadNext();
4,224✔
1767
                                                }
4,224✔
1768
                                        }
4,608✔
1769

1770
                                        if (tmp.InsertTransformRead)
384!
1771
                                        {
×
1772
                                                filter.InsertTransform = new Matrix4(array);
×
1773
                                                tmp.InsertTransformRead = true;
×
1774
                                        }
×
1775
                                        else
1776
                                        {
384✔
1777
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1778
                                        }
384✔
1779

1780
                                        return true;
384✔
1781
                                case 73:
1782
                                default:
1783
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1784
                        }
1785
                }
4,032✔
1786

1787
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1788
                {
3,529✔
1789
                        var tmp = template as CadMLineStyleTemplate;
3,529✔
1790
                        var mLineStyle = template.CadObject as MLineStyle;
3,529✔
1791

1792
                        switch (this._reader.Code)
3,529✔
1793
                        {
1794
                                case 6:
1795
                                        var t = tmp.ElementTemplates.LastOrDefault();
418✔
1796
                                        if (t == null)
418!
1797
                                        {
×
1798
                                                return true;
×
1799
                                        }
1800
                                        t.LineTypeName = this._reader.ValueAsString;
418✔
1801
                                        return true;
418✔
1802
                                case 49:
1803
                                        MLineStyle.Element element = new MLineStyle.Element();
418✔
1804
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
418✔
1805
                                        element.Offset = this._reader.ValueAsDouble;
418✔
1806

1807
                                        tmp.ElementTemplates.Add(elementTemplate);
418✔
1808
                                        mLineStyle.AddElement(element);
418✔
1809
                                        return true;
418✔
1810
                                default:
1811
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,693✔
1812
                        }
1813
                }
3,529✔
1814

1815
                private bool readTableStyle(CadTemplate template, DxfMap map)
1816
                {
17,845✔
1817
                        var tmp = template as CadTableStyleTemplate;
17,845✔
1818
                        var style = tmp.CadObject;
17,845✔
1819
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,845✔
1820

1821
                        switch (this._reader.Code)
17,845!
1822
                        {
1823
                                case 7:
1824
                                        tmp.CreateCurrentCellStyleTemplate();
591✔
1825
                                        tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
591✔
1826
                                        return true;
591✔
1827
                                case 94:
1828
                                        cellStyle.Alignment = this._reader.ValueAsInt;
×
1829
                                        return true;
×
1830
                                case 62:
1831
                                        cellStyle.Color = new Color(this._reader.ValueAsShort);
591✔
1832
                                        return true;
591✔
1833
                                case 63:
1834
                                        cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
591✔
1835
                                        return true;
591✔
1836
                                case 140:
1837
                                        cellStyle.TextHeight = this._reader.ValueAsDouble;
591✔
1838
                                        return true;
591✔
1839
                                case 170:
1840
                                        cellStyle.CellAlignment = (TableEntity.Cell.CellAlignmentType)this._reader.ValueAsShort;
591✔
1841
                                        return true;
591✔
1842
                                case 283:
1843
                                        cellStyle.IsFillColorOn = this._reader.ValueAsBool;
591✔
1844
                                        return true;
591✔
1845
                                case 90:
1846
                                        cellStyle.Type = (TableEntity.CellStyleType)this._reader.ValueAsShort;
399✔
1847
                                        return true;
399✔
1848
                                case 91:
1849
                                        cellStyle.StyleClass = (TableEntity.CellStyleClass)this._reader.ValueAsShort;
399✔
1850
                                        return true;
399✔
1851
                                case 1:
1852
                                        //Undocumented
1853
                                        return true;
399✔
1854
                                case 274:
1855
                                        cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1856
                                        return true;
591✔
1857
                                case 275:
1858
                                        cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1859
                                        return true;
591✔
1860
                                case 276:
1861
                                        cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1862
                                        return true;
591✔
1863
                                case 277:
1864
                                        cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1865
                                        return true;
591✔
1866
                                case 278:
1867
                                        cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1868
                                        return true;
591✔
1869
                                case 279:
1870
                                        cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
591✔
1871
                                        return true;
591✔
1872
                                case 284:
1873
                                        cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1874
                                        return true;
591✔
1875
                                case 285:
1876
                                        cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1877
                                        return true;
591✔
1878
                                case 286:
1879
                                        cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1880
                                        return true;
591✔
1881
                                case 287:
1882
                                        cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1883
                                        return true;
591✔
1884
                                case 288:
1885
                                        cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1886
                                        return true;
591✔
1887
                                case 289:
1888
                                        cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
591✔
1889
                                        return true;
591✔
1890
                                case 64:
1891
                                        cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1892
                                        return true;
591✔
1893
                                case 65:
1894
                                        cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1895
                                        return true;
591✔
1896
                                case 66:
1897
                                        cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1898
                                        return true;
591✔
1899
                                case 67:
1900
                                        cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1901
                                        return true;
591✔
1902
                                case 68:
1903
                                        cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1904
                                        return true;
591✔
1905
                                case 69:
1906
                                        cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
591✔
1907
                                        return true;
591✔
1908
                                default:
1909
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,464✔
1910
                        }
1911
                }
17,845✔
1912

1913
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1914
                {
18,636✔
1915
                        var tmp = template as CadMLeaderStyleTemplate;
18,636✔
1916

1917
                        switch (this._reader.Code)
18,636✔
1918
                        {
1919
                                case 179:
1920
                                        return true;
212✔
1921
                                case 340:
1922
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
406✔
1923
                                        return true;
406✔
1924
                                case 342:
1925
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
406✔
1926
                                        return true;
406✔
1927
                                default:
1928
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,612✔
1929
                        }
1930
                }
18,636✔
1931

1932
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1933
                {
13,737✔
1934
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,737✔
1935

1936
                        switch (this._reader.Code)
13,737✔
1937
                        {
1938
                                case 1:
1939
                                        this._reader.ExpectedCode(70);
1,158✔
1940
                                        this._reader.ExpectedCode(140);
1,158✔
1941
                                        return true;
1,158✔
1942
                                default:
1943
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,579✔
1944
                        }
1945
                }
13,737✔
1946

1947
                private bool readBlockElement(CadTemplate template, DxfMap map)
1948
                {
5,249✔
1949
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,249✔
1950

1951
                        switch (this._reader.Code)
5,249✔
1952
                        {
1953
                                default:
1954
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,249✔
1955
                                        {
4,473✔
1956
                                                return this.readEvaluationExpression(template, map);
4,473✔
1957
                                        }
1958
                                        return true;
776✔
1959
                        }
1960
                }
5,249✔
1961

1962
                private bool readBlockAction(CadTemplate template, DxfMap map)
1963
                {
20✔
1964
                        CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
20✔
1965

1966
                        switch (this._reader.Code)
20✔
1967
                        {
1968
                                default:
1969
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
20✔
1970
                                        {
15✔
1971
                                                return this.readBlockElement(template, map);
15✔
1972
                                        }
1973
                                        return true;
5✔
1974
                        }
1975
                }
20✔
1976

1977
                private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
1978
                {
31✔
1979
                        CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
31✔
1980

1981
                        switch (this._reader.Code)
31✔
1982
                        {
1983
                                default:
1984
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
31✔
1985
                                        {
20✔
1986
                                                return this.readBlockAction(template, map);
20✔
1987
                                        }
1988
                                        return true;
11✔
1989
                        }
1990
                }
31✔
1991

1992
                private bool readBlockRotationAction(CadTemplate template, DxfMap map)
1993
                {
33✔
1994
                        CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
33✔
1995

1996
                        switch (this._reader.Code)
33✔
1997
                        {
1998
                                default:
1999
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
33✔
2000
                                        {
31✔
2001
                                                return this.readBlockActionBasePt(template, map);
31✔
2002
                                        }
2003
                                        return true;
2✔
2004
                        }
2005
                }
33✔
2006

2007
                private bool readBlockParameter(CadTemplate template, DxfMap map)
2008
                {
3,291✔
2009
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,291✔
2010

2011
                        switch (this._reader.Code)
3,291✔
2012
                        {
2013
                                default:
2014
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,291✔
2015
                                        {
2,712✔
2016
                                                return this.readBlockElement(template, map);
2,712✔
2017
                                        }
2018
                                        return true;
579✔
2019
                        }
2020
                }
3,291✔
2021

2022
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
2023
                {
4,246✔
2024
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
2025

2026
                        switch (this._reader.Code)
4,246✔
2027
                        {
2028
                                default:
2029
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
2030
                                        {
3,281✔
2031
                                                return this.readBlockParameter(template, map);
3,281✔
2032
                                        }
2033
                                        return true;
965✔
2034
                        }
2035
                }
4,246✔
2036

2037
                private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
2038
                {
14✔
2039
                        var tmp = template as CadBlock2PtParameterTemplate;
14✔
2040

2041
                        switch (this._reader.Code)
14✔
2042
                        {
2043
                                //Stores always 4 entries using this code
2044
                                case 91:
2045
                                        return true;
4✔
2046
                                default:
2047
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
10!
2048
                                        {
10✔
2049
                                                return this.readBlockParameter(template, map);
10✔
2050
                                        }
2051
                                        return true;
×
2052
                        }
2053
                }
14✔
2054

2055
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
2056
                {
5,404✔
2057
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
2058

2059
                        switch (this._reader.Code)
5,404✔
2060
                        {
2061
                                case 92:
2062
                                        var stateCount = this._reader.ValueAsInt;
193✔
2063
                                        for (int i = 0; i < stateCount; i++)
1,930✔
2064
                                        {
772✔
2065
                                                this._reader.ReadNext();
772✔
2066
                                                tmp.StateTemplates.Add(this.readState());
772✔
2067
                                        }
772✔
2068
                                        return true;
193✔
2069
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
2070
                                        var entityCount = this._reader.ValueAsInt;
193✔
2071
                                        for (int i = 0; i < entityCount; i++)
780✔
2072
                                        {
197✔
2073
                                                this._reader.ReadNext();
197✔
2074
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
197✔
2075
                                        }
197✔
2076
                                        return true;
193✔
2077
                                default:
2078
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
2079
                                        {
4,246✔
2080
                                                return this.readBlock1PtParameter(template, map);
4,246✔
2081
                                        }
2082
                                        return true;
772✔
2083
                        }
2084
                }
5,404✔
2085

2086
                private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2087
                {
49✔
2088
                        var tmp = template as CadBlockRotationParameterTemplate;
49✔
2089

2090
                        switch (this._reader.Code)
49✔
2091
                        {
2092
                                default:
2093
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
49✔
2094
                                        {
14✔
2095
                                                return this.readBlock2PtParameter(template, map);
14✔
2096
                                        }
2097
                                        return true;
35✔
2098
                        }
2099
                }
49✔
2100

2101
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2102
                {
772✔
2103
                        var state = new BlockVisibilityParameter.State();
772✔
2104
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
2105

2106
                        List<int> expectedCodes = new List<int>();
772✔
2107
                        expectedCodes.Add(303);
772✔
2108
                        expectedCodes.Add(94);
772✔
2109
                        expectedCodes.Add(95);
772✔
2110

2111
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
2112
                        {
2,316✔
2113
                                expectedCodes.Remove(this._reader.Code);
2,316✔
2114

2115
                                switch (this._reader.Code)
2,316!
2116
                                {
2117
                                        case 303:
2118
                                                state.Name = this._reader.ValueAsString;
772✔
2119
                                                break;
772✔
2120
                                        case 94:
2121
                                                var count = this._reader.ValueAsInt;
772✔
2122
                                                for (int i = 0; i < count; i++)
2,720✔
2123
                                                {
588✔
2124
                                                        this._reader.ReadNext();
588✔
2125
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
2126
                                                }
588✔
2127
                                                break;
772✔
2128
                                        case 95:
2129
                                                count = this._reader.ValueAsInt;
772✔
2130
                                                for (int i = 0; i < count; i++)
6,152✔
2131
                                                {
2,304✔
2132
                                                        this._reader.ReadNext();
2,304✔
2133
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2134
                                                }
2,304✔
2135
                                                break;
772✔
2136
                                        default:
2137
                                                return template;
×
2138
                                }
2139

2140
                                if (!expectedCodes.Any())
2,316✔
2141
                                {
772✔
2142
                                        break;
772✔
2143
                                }
2144

2145
                                this._reader.ReadNext();
1,544✔
2146
                        }
1,544✔
2147

2148
                        return template;
772✔
2149
                }
772✔
2150

2151
                private bool readBlockGrip(CadTemplate template, DxfMap map)
2152
                {
3,880✔
2153
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,880✔
2154

2155
                        switch (this._reader.Code)
3,880✔
2156
                        {
2157
                                default:
2158
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,880✔
2159
                                        {
2,522✔
2160
                                                return this.readBlockElement(template, map);
2,522✔
2161
                                        }
2162
                                        return true;
1,358✔
2163
                        }
2164
                }
3,880✔
2165

2166
                private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
2167
                {
20✔
2168
                        CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
20✔
2169

2170
                        switch (this._reader.Code)
20✔
2171
                        {
2172
                                default:
2173
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
20!
2174
                                        {
20✔
2175
                                                return this.readBlockGrip(template, map);
20✔
2176
                                        }
2177
                                        return true;
×
2178
                        }
2179
                }
20✔
2180

2181
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
2182
                {
3,860✔
2183
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2184

2185
                        switch (this._reader.Code)
3,860✔
2186
                        {
2187
                                default:
2188
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2189
                                        {
3,860✔
2190
                                                return this.readBlockGrip(template, map);
3,860✔
2191
                                        }
2192
                                        return true;
×
2193
                        }
2194
                }
3,860✔
2195

2196
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2197
                {
1,590✔
2198
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,590✔
2199

2200
                        switch (this._reader.Code)
1,590✔
2201
                        {
2202
                                case 340:
2203
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
265✔
2204
                                        return true;
265✔
2205
                                default:
2206
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,325✔
2207
                        }
2208
                }
1,590✔
2209

2210
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2211
                {
11,580✔
2212
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,580✔
2213

2214
                        switch (this._reader.Code)
11,580✔
2215
                        {
2216
                                default:
2217
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,580✔
2218
                                        {
9,264✔
2219
                                                return this.readEvaluationExpression(template, map);
9,264✔
2220
                                        }
2221
                                        return true;
2,316✔
2222
                        }
2223
                }
11,580✔
2224

2225
                private bool readXRecord(CadTemplate template, DxfMap map)
2226
                {
113,272✔
2227
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,272✔
2228

2229
                        switch (this._reader.Code)
113,272✔
2230
                        {
2231
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,926✔
2232
                                        this.readXRecordEntries(tmp);
28,926✔
2233
                                        return true;
28,926✔
2234
                                default:
2235
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,346✔
2236
                        }
2237
                }
113,272✔
2238

2239
                private void readXRecordEntries(CadXRecordTemplate template)
2240
                {
28,926✔
2241
                        this._reader.ReadNext();
28,926✔
2242

2243
                        while (this._reader.DxfCode != DxfCode.Start)
2,409,286✔
2244
                        {
2,380,360✔
2245
                                switch (this._reader.GroupCodeValue)
2,380,360✔
2246
                                {
2247
                                        case GroupCodeValueType.Point3D:
2248
                                                var code = this._reader.Code;
2,901✔
2249
                                                var x = this._reader.ValueAsDouble;
2,901✔
2250
                                                this._reader.ReadNext();
2,901✔
2251
                                                var y = this._reader.ValueAsDouble;
2,901✔
2252
                                                this._reader.ReadNext();
2,901✔
2253
                                                var z = this._reader.ValueAsDouble;
2,901✔
2254
                                                XYZ pt = new XYZ(x, y, z);
2,901✔
2255
                                                template.CadObject.CreateEntry(code, pt);
2,901✔
2256
                                                break;
2,901✔
2257
                                        case GroupCodeValueType.Handle:
2258
                                        case GroupCodeValueType.ObjectId:
2259
                                        case GroupCodeValueType.ExtendedDataHandle:
2260
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,041✔
2261
                                                break;
12,041✔
2262
                                        default:
2263
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,418✔
2264
                                                break;
2,365,418✔
2265
                                }
2266

2267
                                this._reader.ReadNext();
2,380,360✔
2268
                        }
2,380,360✔
2269
                }
28,926✔
2270

2271
                private bool readBookColor(CadTemplate template, DxfMap map)
2272
                {
1,376✔
2273
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2274
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2275

2276
                        switch (this._reader.Code)
1,376✔
2277
                        {
2278
                                case 430:
2279
                                        color.Name = this._reader.ValueAsString;
160✔
2280
                                        return true;
160✔
2281
                                default:
2282
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2283
                        }
2284
                }
1,376✔
2285

2286
                private bool readDictionary(CadTemplate template, DxfMap map)
2287
                {
224,204✔
2288
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
224,204✔
2289
                        CadDictionary cadDictionary = tmp.CadObject;
224,204✔
2290

2291
                        switch (this._reader.Code)
224,204✔
2292
                        {
2293
                                case 280:
2294
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,069✔
2295
                                        return true;
15,069✔
2296
                                case 281:
2297
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,522✔
2298
                                        return true;
21,522✔
2299
                                case 3:
2300
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,371✔
2301
                                        return true;
57,371✔
2302
                                case 350: // Soft-owner ID/handle to entry object 
2303
                                case 360: // Hard-owner ID/handle to entry object
2304
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,371✔
2305
                                        return true;
57,371✔
2306
                                default:
2307
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,871✔
2308
                        }
2309
                }
224,204✔
2310

2311
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2312
                {
1,773✔
2313
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,773✔
2314

2315
                        switch (this._reader.Code)
1,773✔
2316
                        {
2317
                                case 340:
2318
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
197✔
2319
                                        return true;
197✔
2320
                                default:
2321
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,576!
2322
                                        {
1,576✔
2323
                                                return this.readDictionary(template, map);
1,576✔
2324
                                        }
2325
                                        return true;
×
2326
                        }
2327
                }
1,773✔
2328

2329
                private CadTemplate readSortentsTable()
2330
                {
576✔
2331
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2332
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2333

2334
                        //Jump the 0 marker
2335
                        this._reader.ReadNext();
576✔
2336

2337
                        this.readCommonObjectData(template);
576✔
2338

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

2341
                        //Jump the 100 marker
2342
                        this._reader.ReadNext();
576✔
2343

2344
                        (ulong?, ulong?) pair = (null, null);
576✔
2345

2346
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2347
                        {
3,648✔
2348
                                switch (this._reader.Code)
3,648!
2349
                                {
2350
                                        case 5:
2351
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2352
                                                break;
1,536✔
2353
                                        case 330:
2354
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2355
                                                break;
576✔
2356
                                        case 331:
2357
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2358
                                                break;
1,536✔
2359
                                        default:
2360
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2361
                                                break;
×
2362
                                }
2363

2364
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2365
                                {
1,536✔
2366
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2367
                                        pair = (null, null);
1,536✔
2368
                                }
1,536✔
2369

2370
                                this._reader.ReadNext();
3,648✔
2371
                        }
3,648✔
2372

2373
                        return template;
576✔
2374
                }
576✔
2375
        }
2376
}
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