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

DomCR / ACadSharp / 21668989262

04 Feb 2026 11:04AM UTC coverage: 77.413% (+0.2%) from 77.238%
21668989262

push

github

web-flow
Merge pull request #963 from DomCR/issue-962_dynamic-parameter-rotation-translation

issue-962

8111 of 11339 branches covered (71.53%)

Branch coverage included in aggregate %.

273 of 301 new or added lines in 16 files covered. (90.7%)

11 existing lines in 2 files now uncovered.

29385 of 37097 relevant lines covered (79.21%)

148585.46 hits per line

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

86.51
/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:
89
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), 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
                                default:
129
                                        DxfMap map = DxfMap.Create<CadObject>();
4,055✔
130
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
4,055✔
131
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
4,055!
132
                                        {
4,055✔
133
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
4,055✔
134
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
4,055✔
135
                                        }
4,055✔
136
                                        else
137
                                        {
×
138
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
139
                                        }
×
140

141
                                        this._reader.ReadNext();
4,055✔
142

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

152
                                                this._reader.ReadNext();
252,855✔
153
                                        }
252,855✔
154
                                        while (this._reader.DxfCode != DxfCode.Start);
252,879✔
155

156
                                        return unknownEntityTemplate;
4,055✔
157
                        }
158
                }
77,390✔
159

160
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
161
                        where T : CadObject
162
                {
72,759✔
163
                        this._reader.ReadNext();
72,759✔
164

165
                        DxfMap map = DxfMap.Create<T>();
72,759✔
166

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

176
                                if (this.lockPointer)
967,395✔
177
                                {
1,798✔
178
                                        this.lockPointer = false;
1,798✔
179
                                        continue;
1,798✔
180
                                }
181

182
                                if (this._reader.DxfCode != DxfCode.Start)
965,597✔
183
                                {
936,671✔
184
                                        this._reader.ReadNext();
936,671✔
185
                                }
936,671✔
186
                        }
965,597✔
187

188
                        return template;
72,759✔
189
                }
72,759✔
190

191
                private bool readProxyObject(CadTemplate template, DxfMap map)
192
                {
×
193
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
194

195
                        switch (this._reader.Code)
×
196
                        {
197
                                case 90:
198
                                case 94:
199
                                //Undocumented
200
                                case 97:
201
                                case 71:
202
                                        return true;
×
203
                                case 95:
204
                                        int format = this._reader.ValueAsInt;
×
205
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
206
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
207
                                        return true;
×
208
                                case 91:
209
                                        var classId = this._reader.ValueAsShort;
×
210
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
211
                                        {
×
212
                                                proxy.DxfClass = dxfClass;
×
213
                                        }
×
214
                                        return true;
×
215
                                case 161:
216
                                        return true;
×
217
                                case 162:
218
                                        return true;
×
219
                                case 310:
220
                                        if (proxy.BinaryData == null)
×
221
                                        {
×
222
                                                proxy.BinaryData = new MemoryStream();
×
223
                                        }
×
224
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
225
                                        return true;
×
226
                                case 311:
227
                                        if (proxy.Data == null)
×
228
                                        {
×
229
                                                proxy.Data = new MemoryStream();
×
230
                                        }
×
231
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
232
                                        return true;
×
233
                                default:
234
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
235
                        }
236
                }
×
237

238
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
239
                {
23,355✔
240
                        switch (this._reader.Code)
23,355✔
241
                        {
242
                                default:
243
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,355✔
244
                        }
245
                }
23,355✔
246

247
                private bool readPlotSettings(CadTemplate template, DxfMap map)
248
                {
25,534✔
249
                        switch (this._reader.Code)
25,534✔
250
                        {
251
                                default:
252
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,534✔
253
                        }
254
                }
25,534✔
255

256
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
257
                {
3,096✔
258
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,096✔
259
                        EvaluationGraph evGraph = tmp.CadObject;
3,096✔
260

261
                        switch (this._reader.Code)
3,096✔
262
                        {
263
                                case 91:
264
                                        while (this._reader.Code == 91)
3,025✔
265
                                        {
2,574✔
266
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,574✔
267
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,574✔
268

269
                                                node.Index = this._reader.ValueAsInt;
2,574✔
270

271
                                                this._reader.ExpectedCode(93);
2,574✔
272
                                                node.Flags = this._reader.ValueAsInt;
2,574✔
273

274
                                                this._reader.ExpectedCode(95);
2,574✔
275
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,574✔
276

277
                                                this._reader.ExpectedCode(360);
2,574✔
278
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,574✔
279

280
                                                this._reader.ExpectedCode(92);
2,574✔
281
                                                node.Data1 = this._reader.ValueAsInt;
2,574✔
282
                                                this._reader.ExpectedCode(92);
2,574✔
283
                                                node.Data2 = this._reader.ValueAsInt;
2,574✔
284
                                                this._reader.ExpectedCode(92);
2,574✔
285
                                                node.Data3 = this._reader.ValueAsInt;
2,574✔
286
                                                this._reader.ExpectedCode(92);
2,574✔
287
                                                node.Data4 = this._reader.ValueAsInt;
2,574✔
288

289
                                                this._reader.ReadNext();
2,574✔
290

291
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,574✔
292
                                        }
2,574✔
293

294
                                        this.lockPointer = true;
451✔
295
                                        return true;
451✔
296
                                case 92:
297
                                        //Edges
298
                                        while (this._reader.Code == 92)
2,126✔
299
                                        {
1,931✔
300
                                                this._reader.ExpectedCode(93);
1,931✔
301
                                                this._reader.ExpectedCode(94);
1,931✔
302
                                                this._reader.ExpectedCode(91);
1,931✔
303
                                                this._reader.ExpectedCode(91);
1,931✔
304
                                                this._reader.ExpectedCode(92);
1,931✔
305
                                                this._reader.ExpectedCode(92);
1,931✔
306
                                                this._reader.ExpectedCode(92);
1,931✔
307
                                                this._reader.ExpectedCode(92);
1,931✔
308
                                                this._reader.ExpectedCode(92);
1,931✔
309

310
                                                this._reader.ReadNext();
1,931✔
311
                                        }
1,931✔
312

313
                                        this.lockPointer = true;
195✔
314
                                        return true;
195✔
315
                                default:
316
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,450✔
317
                        }
318
                }
3,096✔
319

320
                private bool readLayout(CadTemplate template, DxfMap map)
321
                {
51,979✔
322
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,979✔
323

324
                        switch (this._reader.Code)
51,979✔
325
                        {
326
                                case 330:
327
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,614✔
328
                                        return true;
1,614✔
329
                                case 331:
330
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
773✔
331
                                        return true;
773✔
332
                                default:
333
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,592✔
334
                                        {
25,534✔
335
                                                return this.readPlotSettings(template, map);
25,534✔
336
                                        }
337
                                        return true;
24,058✔
338
                        }
339
                }
51,979✔
340

341
                private bool readGroup(CadTemplate template, DxfMap map)
342
                {
4,992✔
343
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
344

345
                        switch (this._reader.Code)
4,992✔
346
                        {
347
                                case 70:
348
                                        return true;
384✔
349
                                case 340:
350
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
351
                                        return true;
2,304✔
352
                                default:
353
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
354
                        }
355
                }
4,992✔
356

357
                private bool readGeoData(CadTemplate template, DxfMap map)
358
                {
102✔
359
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
360

361
                        switch (this._reader.Code)
102✔
362
                        {
363
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
364
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
365
                                                tmp.CadObject.ReferencePoint.X,
1✔
366
                                                this._reader.ValueAsDouble,
1✔
367
                                                tmp.CadObject.ReferencePoint.Z
1✔
368
                                                );
1✔
369
                                        return true;
1✔
370
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
371
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
372
                                                this._reader.ValueAsDouble,
1✔
373
                                                tmp.CadObject.ReferencePoint.Y,
1✔
374
                                                tmp.CadObject.ReferencePoint.Z
1✔
375
                                                );
1✔
376
                                        return true;
1✔
377
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
378
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
379
                                                tmp.CadObject.ReferencePoint.X,
1✔
380
                                                tmp.CadObject.ReferencePoint.Y,
1✔
381
                                                this._reader.ValueAsDouble
1✔
382
                                                );
1✔
383
                                        return true;
1✔
384
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
385
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
386
                                        return true;
1✔
387
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
388
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
389
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
390
                                        return true;
1✔
391
                                // Number of Geo-Mesh points
392
                                case 93:
393
                                        var npts = this._reader.ValueAsInt;
3✔
394
                                        for (int i = 0; i < npts; i++)
54✔
395
                                        {
24✔
396
                                                this._reader.ReadNext();
24✔
397
                                                double sourceX = this._reader.ValueAsDouble;
24✔
398
                                                this._reader.ReadNext();
24✔
399
                                                double sourceY = this._reader.ValueAsDouble;
24✔
400

401
                                                this._reader.ReadNext();
24✔
402
                                                double destX = this._reader.ValueAsDouble;
24✔
403
                                                this._reader.ReadNext();
24✔
404
                                                double destY = this._reader.ValueAsDouble;
24✔
405

406
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
407
                                                {
24✔
408
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
409
                                                        Destination = new CSMath.XY(destX, destY)
24✔
410
                                                });
24✔
411
                                        }
24✔
412
                                        return true;
3✔
413
                                // Number of Geo-Mesh points
414
                                case 96:
415
                                        var nfaces = this._reader.ValueAsInt;
2✔
416
                                        for (int i = 0; i < nfaces; i++)
4!
417
                                        {
×
418
                                                this._reader.ReadNext();
×
419
                                                Debug.Assert(this._reader.Code == 97);
×
420
                                                int index1 = this._reader.ValueAsInt;
×
421
                                                this._reader.ReadNext();
×
422
                                                Debug.Assert(this._reader.Code == 98);
×
423
                                                int index2 = this._reader.ValueAsInt;
×
424
                                                this._reader.ReadNext();
×
425
                                                Debug.Assert(this._reader.Code == 99);
×
426
                                                int index3 = this._reader.ValueAsInt;
×
427

428
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
429
                                                {
×
430
                                                        Index1 = index1,
×
431
                                                        Index2 = index2,
×
432
                                                        Index3 = index3
×
433
                                                });
×
434
                                        }
×
435
                                        return true;
2✔
436
                                case 303:
437
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
438
                                        return true;
13✔
439
                                //Obsolete codes for version GeoDataVersion.R2009
440
                                case 3:
441
                                case 4:
442
                                case 14:
443
                                case 24:
444
                                case 15:
445
                                case 25:
446
                                case 43:
447
                                case 44:
448
                                case 45:
449
                                case 94:
450
                                case 293:
451
                                case 16:
452
                                case 26:
453
                                case 17:
454
                                case 27:
455
                                case 54:
456
                                case 140:
457
                                case 304:
458
                                case 292:
459
                                        return true;
19✔
460
                                default:
461
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
462
                        }
463
                }
102✔
464

465
                private bool readMaterial(CadTemplate template, DxfMap map)
466
                {
42,114✔
467
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,114✔
468
                        List<double> arr = null;
42,114✔
469

470
                        switch (this._reader.Code)
42,114!
471
                        {
472
                                case 43:
473
                                        arr = new();
1,349✔
474
                                        for (int i = 0; i < 16; i++)
45,866✔
475
                                        {
21,584✔
476
                                                Debug.Assert(this._reader.Code == 43);
21,584✔
477

478
                                                arr.Add(this._reader.ValueAsDouble);
21,584✔
479

480
                                                this._reader.ReadNext();
21,584✔
481
                                        }
21,584✔
482

483
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,349✔
484
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,349✔
485
                                case 47:
486
                                        arr = new();
×
487
                                        for (int i = 0; i < 16; i++)
×
488
                                        {
×
489
                                                Debug.Assert(this._reader.Code == 47);
×
490

491
                                                arr.Add(this._reader.ValueAsDouble);
×
492

493
                                                this._reader.ReadNext();
×
494
                                        }
×
495

496
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
497
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
498
                                case 49:
499
                                        arr = new();
197✔
500
                                        for (int i = 0; i < 16; i++)
6,698✔
501
                                        {
3,152✔
502
                                                Debug.Assert(this._reader.Code == 49);
3,152✔
503

504
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
505

506
                                                this._reader.ReadNext();
3,152✔
507
                                        }
3,152✔
508

509
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
510
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
511
                                case 142:
512
                                        arr = new();
197✔
513
                                        for (int i = 0; i < 16; i++)
6,698✔
514
                                        {
3,152✔
515
                                                Debug.Assert(this._reader.Code == 142);
3,152✔
516

517
                                                arr.Add(this._reader.ValueAsDouble);
3,152✔
518

519
                                                this._reader.ReadNext();
3,152✔
520
                                        }
3,152✔
521

522
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
197✔
523
                                        return this.checkObjectEnd(template, map, this.readMaterial);
197✔
524
                                case 144:
525
                                        arr = new();
1,157✔
526
                                        for (int i = 0; i < 16; i++)
39,338✔
527
                                        {
18,512✔
528
                                                Debug.Assert(this._reader.Code == 144);
18,512✔
529

530
                                                arr.Add(this._reader.ValueAsDouble);
18,512✔
531

532
                                                this._reader.ReadNext();
18,512✔
533
                                        }
18,512✔
534

535
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,157✔
536
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,157✔
537
                                case 147:
538
                                        arr = new();
×
539
                                        for (int i = 0; i < 16; i++)
×
540
                                        {
×
541
                                                Debug.Assert(this._reader.Code == 147);
×
542

543
                                                arr.Add(this._reader.ValueAsDouble);
×
544

545
                                                this._reader.ReadNext();
×
546
                                        }
×
547

548
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
549
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
550
                                default:
551
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,214✔
552
                        }
553
                }
42,114✔
554

555
                private bool readScale(CadTemplate template, DxfMap map)
556
                {
60,141✔
557
                        switch (this._reader.Code)
60,141✔
558
                        {
559
                                // Undocumented codes
560
                                case 70:
561
                                        //Always 0
562
                                        return true;
6,705✔
563
                                default:
564
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
53,436✔
565
                        }
566
                }
60,141✔
567

568
                private void readLinkedData(CadTemplate template, DxfMap map)
569
                {
320✔
570
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
571
                        LinkedData linkedData = tmp.CadObject;
320✔
572

573
                        this._reader.ReadNext();
320✔
574

575
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
576
                        {
640✔
577
                                switch (this._reader.Code)
640✔
578
                                {
579
                                        default:
580
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
581
                                                {
×
582
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
583
                                                }
×
584
                                                break;
640✔
585
                                }
586

587
                                this._reader.ReadNext();
640✔
588
                        }
640✔
589
                }
320✔
590

591
                private bool readTableContent(CadTemplate template, DxfMap map)
592
                {
2,368✔
593
                        switch (this._reader.Code)
2,368✔
594
                        {
595
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
596
                                        this.readTableContentSubclass(template, map);
256✔
597
                                        this.lockPointer = true;
256✔
598
                                        return true;
256✔
599
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
600
                                        this.readFormattedTableDataSubclass(template, map);
256✔
601
                                        this.lockPointer = true;
256✔
602
                                        return true;
256✔
603
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
604
                                        this.readLinkedTableDataSubclass(template, map);
320✔
605
                                        this.lockPointer = true;
320✔
606
                                        return true;
320✔
607
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
608
                                        this.readLinkedData(template, map);
320✔
609
                                        this.lockPointer = true;
320✔
610
                                        return true;
320✔
611
                                default:
612
                                        return false;
1,216✔
613
                        }
614
                }
2,368✔
615

616
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
617
                {
256✔
618
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
619
                        TableContent tableContent = tmp.CadObject;
256✔
620

621
                        this._reader.ReadNext();
256✔
622

623
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
624
                        {
256✔
625
                                switch (this._reader.Code)
256!
626
                                {
627
                                        case 340:
628
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
629
                                                break;
256✔
630
                                        default:
631
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
632
                                                {
×
633
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
634
                                                }
×
635
                                                break;
×
636
                                }
637

638
                                this._reader.ReadNext();
256✔
639
                        }
256✔
640
                }
256✔
641

642
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
643
                {
256✔
644
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
645
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
646

647
                        this._reader.ReadNext();
256✔
648

649
                        TableEntity.CellRange cellRange = null;
256✔
650
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
651
                        {
2,048✔
652
                                switch (this._reader.Code)
2,048!
653
                                {
654
                                        case 90:
655
                                                break;
256✔
656
                                        case 91:
657
                                                if (cellRange == null)
384✔
658
                                                {
384✔
659
                                                        cellRange = new();
384✔
660
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
661
                                                }
384✔
662
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
663
                                                break;
384✔
664
                                        case 92:
665
                                                if (cellRange == null)
384!
666
                                                {
×
667
                                                        cellRange = new();
×
668
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
669
                                                }
×
670
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
671
                                                break;
384✔
672
                                        case 93:
673
                                                if (cellRange == null)
384!
674
                                                {
×
675
                                                        cellRange = new();
×
676
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
677
                                                }
×
678
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
679
                                                break;
384✔
680
                                        case 94:
681
                                                if (cellRange == null)
384!
682
                                                {
×
683
                                                        cellRange = new();
×
684
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
685
                                                }
×
686
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
687
                                                cellRange = null;
384✔
688
                                                break;
384✔
689
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
690
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
691
                                                break;
256✔
692
                                        default:
693
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
694
                                                {
×
695
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
696
                                                }
×
697
                                                break;
×
698
                                }
699

700
                                this._reader.ReadNext();
2,048✔
701
                        }
2,048✔
702
                }
256✔
703

704
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
705
                {
320✔
706
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
707
                        TableContent tableContent = tmp.CadObject;
320✔
708

709
                        this._reader.ReadNext();
320✔
710

711
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
712
                        {
3,904✔
713
                                switch (this._reader.Code)
3,904✔
714
                                {
715
                                        case 90:
716
                                                //Column count
717
                                                break;
320✔
718
                                        case 91:
719
                                                //Row count
720
                                                break;
320✔
721
                                        //Unknown
722
                                        case 92:
723
                                                break;
256✔
724
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
725
                                                //Read Column
726
                                                this.readTableColumn();
1,216✔
727
                                                break;
1,216✔
728
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
729
                                                //Read Row
730
                                                this.readTableRow();
1,472✔
731
                                                break;
1,472✔
732
                                        default:
733
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
734
                                                {
320✔
735
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
736
                                                }
320✔
737
                                                break;
320✔
738
                                }
739

740
                                this._reader.ReadNext();
3,904✔
741
                        }
3,904✔
742
                }
320✔
743

744

745
                private TableEntity.Column readTableColumn()
746
                {
1,216✔
747
                        this._reader.ReadNext();
1,216✔
748

749
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
750

751
                        bool end = false;
1,216✔
752
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
753
                        {
3,648✔
754
                                switch (this._reader.Code)
3,648!
755
                                {
756
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
757
                                                this.readLinkedTableColumn(column);
1,216✔
758
                                                break;
1,216✔
759
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
760
                                                this.readFormattedTableColumn(column);
1,216✔
761
                                                break;
1,216✔
762
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
763
                                                this.readTableColumn(column);
1,216✔
764
                                                end = true;
1,216✔
765
                                                break;
1,216✔
766
                                        default:
767
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
768
                                                break;
×
769
                                }
770

771
                                if (end)
3,648✔
772
                                {
1,216✔
773
                                        return column;
1,216✔
774
                                }
775

776
                                this._reader.ReadNext();
2,432✔
777
                        }
2,432✔
778

779
                        return column;
×
780
                }
1,216✔
781

782
                private TableEntity.Row readTableRow()
783
                {
1,472✔
784
                        this._reader.ReadNext();
1,472✔
785

786
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
787

788
                        bool end = false;
1,472✔
789
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
790
                        {
11,840✔
791
                                switch (this._reader.Code)
11,840✔
792
                                {
793
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
794
                                                this.readLinkedTableRow(row);
1,536✔
795
                                                break;
1,536✔
796
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
797
                                                this.readFormattedTableRow(row);
1,408✔
798
                                                break;
1,408✔
799
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
800
                                                this.readTableRow(row);
1,408✔
801
                                                end = true;
1,408✔
802
                                                break;
1,408✔
803
                                        default:
804
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
805
                                                break;
7,488✔
806
                                }
807

808
                                if (end)
11,840✔
809
                                {
1,408✔
810
                                        return row;
1,408✔
811
                                }
812

813
                                this._reader.ReadNext();
10,432✔
814
                        }
10,432✔
815

816
                        return row;
64✔
817
                }
1,472✔
818

819
                private void readTableRow(TableEntity.Row row)
820
                {
1,408✔
821
                        this._reader.ReadNext();
1,408✔
822

823
                        bool end = false;
1,408✔
824
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
825
                        {
4,224✔
826
                                switch (this._reader.Code)
4,224!
827
                                {
828
                                        case 40:
829
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
830
                                                break;
1,408✔
831
                                        case 90:
832
                                                //styleID
833
                                                break;
1,408✔
834
                                        case 309:
835
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
836
                                                break;
1,408✔
837
                                        default:
838
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
839
                                                break;
×
840
                                }
841

842
                                if (end)
4,224✔
843
                                {
1,408✔
844
                                        break;
1,408✔
845
                                }
846

847
                                this._reader.ReadNext();
2,816✔
848
                        }
2,816✔
849
                }
1,408✔
850

851
                private void readFormattedTableRow(TableEntity.Row row)
852
                {
1,408✔
853
                        this._reader.ReadNext();
1,408✔
854

855
                        bool end = false;
1,408✔
856
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
857
                        {
4,224✔
858
                                switch (this._reader.Code)
4,224!
859
                                {
860
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
861
                                                break;
1,408✔
862
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
863
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
864
                                                break;
1,408✔
865
                                        case 309:
866
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
867
                                                break;
1,408✔
868
                                        default:
869
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
870
                                                break;
×
871
                                }
872

873
                                if (end)
4,224✔
874
                                {
1,408✔
875
                                        break;
1,408✔
876
                                }
877

878
                                this._reader.ReadNext();
2,816✔
879
                        }
2,816✔
880
                }
1,408✔
881

882
                private void readTableColumn(TableEntity.Column column)
883
                {
1,216✔
884
                        this._reader.ReadNext();
1,216✔
885

886
                        bool end = false;
1,216✔
887
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
888
                        {
3,648✔
889
                                switch (this._reader.Code)
3,648!
890
                                {
891
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
892
                                                break;
×
893
                                        case 1:
894
                                                end = true;
×
895
                                                break;
×
896
                                        case 40:
897
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
898
                                                break;
1,216✔
899
                                        case 90:
900
                                                //StyleId
901
                                                break;
1,216✔
902
                                        case 309:
903
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
904
                                                break;
1,216✔
905
                                        default:
906
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
907
                                                break;
×
908
                                }
909

910
                                if (end)
3,648✔
911
                                {
1,216✔
912
                                        break;
1,216✔
913
                                }
914

915
                                this._reader.ReadNext();
2,432✔
916
                        }
2,432✔
917
                }
1,216✔
918

919
                private void readLinkedTableColumn(TableEntity.Column column)
920
                {
1,216✔
921
                        this._reader.ReadNext();
1,216✔
922

923
                        bool end = false;
1,216✔
924
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
925
                        {
4,864✔
926
                                switch (this._reader.Code)
4,864!
927
                                {
928
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
929
                                                break;
×
930
                                        case 1:
931
                                                end = true;
×
932
                                                break;
×
933
                                        case 91:
934
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
935
                                                break;
1,216✔
936
                                        case 300:
937
                                                column.Name = this._reader.ValueAsString;
1,216✔
938
                                                break;
1,216✔
939
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
940
                                                this.readCustomData();
1,216✔
941
                                                break;
1,216✔
942
                                        case 309:
943
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
944
                                                break;
1,216✔
945
                                        default:
946
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
947
                                                break;
×
948
                                }
949

950
                                if (end)
4,864✔
951
                                {
1,216✔
952
                                        break;
1,216✔
953
                                }
954

955
                                this._reader.ReadNext();
3,648✔
956
                        }
3,648✔
957
                }
1,216✔
958

959
                private void readLinkedTableRow(TableEntity.Row row)
960
                {
1,536✔
961
                        this._reader.ReadNext();
1,536✔
962

963
                        bool end = false;
1,536✔
964
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
965
                        {
12,480✔
966
                                switch (this._reader.Code)
12,480!
967
                                {
968
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
969
                                                break;
×
970
                                        case 90:
971
                                                break;
1,536✔
972
                                        case 91:
973
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
974
                                                break;
1,408✔
975
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
976
                                                this.readCell();
5,376✔
977
                                                break;
5,376✔
978
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
979
                                                this.readCustomData();
1,408✔
980
                                                break;
1,408✔
981
                                        case 309:
982
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
983
                                                break;
1,408✔
984
                                        default:
985
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
986
                                                break;
1,344✔
987
                                }
988

989
                                if (end)
12,480✔
990
                                {
1,408✔
991
                                        break;
1,408✔
992
                                }
993

994
                                this._reader.ReadNext();
11,072✔
995
                        }
11,072✔
996
                }
1,536✔
997

998
                private TableEntity.Cell readCell()
999
                {
5,376✔
1000
                        this._reader.ReadNext();
5,376✔
1001

1002
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
1003
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
1004

1005
                        bool end = false;
5,376✔
1006
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
1007
                        {
16,832✔
1008
                                switch (this._reader.Code)
16,832✔
1009
                                {
1010
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
1011
                                                this.readLinkedTableCell(cell);
5,376✔
1012
                                                break;
5,376✔
1013
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
1014
                                                this.readFormattedTableCell(cell);
5,248✔
1015
                                                break;
5,248✔
1016
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1017
                                                this.readTableCell(cell);
5,248✔
1018
                                                end = true;
5,248✔
1019
                                                break;
5,248✔
1020
                                        default:
1021
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1022
                                                break;
960✔
1023
                                }
1024

1025
                                if (end)
16,832✔
1026
                                {
5,248✔
1027
                                        return cell;
5,248✔
1028
                                }
1029

1030
                                this._reader.ReadNext();
11,584✔
1031
                        }
11,584✔
1032

1033
                        return cell;
128✔
1034
                }
5,376✔
1035

1036
                private void readTableCell(TableEntity.Cell cell)
1037
                {
5,248✔
1038
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1039

1040
                        this._reader.ReadNext();
5,248✔
1041

1042
                        bool end = false;
5,248✔
1043
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1044
                        {
16,384✔
1045
                                switch (this._reader.Code)
16,384✔
1046
                                {
1047
                                        //Unknown
1048
                                        case 40:
1049
                                        case 41:
1050
                                                break;
256✔
1051
                                        case 309:
1052
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1053
                                                break;
5,248✔
1054
                                        case 330:
1055
                                                //Unknown handle
1056
                                                break;
128✔
1057
                                        default:
1058
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1059
                                                {
×
1060
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1061
                                                }
×
1062
                                                break;
10,752✔
1063
                                }
1064

1065
                                if (end)
16,384✔
1066
                                {
5,248✔
1067
                                        break;
5,248✔
1068
                                }
1069

1070
                                this._reader.ReadNext();
11,136✔
1071
                        }
11,136✔
1072
                }
5,248✔
1073

1074
                private void readFormattedTableCell(TableEntity.Cell cell)
1075
                {
5,248✔
1076
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1077

1078
                        this._reader.ReadNext();
5,248✔
1079

1080
                        bool end = false;
5,248✔
1081
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1082
                        {
10,496✔
1083
                                switch (this._reader.Code)
10,496!
1084
                                {
1085
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1086
                                                this.readCellTableFormat(cell);
5,248✔
1087
                                                continue;
5,248✔
1088
                                        case 309:
1089
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1090
                                                break;
5,248✔
1091
                                        default:
1092
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1093
                                                {
×
1094
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1095
                                                }
×
1096
                                                break;
×
1097
                                }
1098

1099
                                if (end)
5,248!
1100
                                {
5,248✔
1101
                                        break;
5,248✔
1102
                                }
1103

1104
                                this._reader.ReadNext();
×
1105
                        }
×
1106
                }
5,248✔
1107

1108
                private void readCellTableFormat(TableEntity.Cell cell)
1109
                {
5,248✔
1110
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1111

1112
                        this._reader.ReadNext();
5,248✔
1113

1114
                        bool end = false;
5,248✔
1115
                        while (this._reader.Code == 1)
10,496✔
1116
                        {
5,248✔
1117
                                switch (this._reader.Code)
5,248!
1118
                                {
1119
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1120
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1121
                                                break;
5,248✔
1122
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1123
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1124
                                                break;
×
1125
                                        default:
1126
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1127
                                                {
×
1128
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1129
                                                }
×
1130
                                                break;
×
1131
                                }
1132

1133
                                if (end)
5,248!
1134
                                {
×
1135
                                        break;
×
1136
                                }
1137

1138
                                this._reader.ReadNext();
5,248✔
1139
                        }
5,248✔
1140
                }
5,248✔
1141

1142
                private void readCellStyle(CadCellStyleTemplate template)
1143
                {
×
1144
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1145

1146
                        this._reader.ReadNext();
×
1147

1148
                        bool end = false;
×
1149
                        while (this._reader.Code != 1)
×
1150
                        {
×
1151
                                switch (this._reader.Code)
×
1152
                                {
1153
                                        case 309:
1154
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1155
                                                break;
×
1156
                                        default:
1157
                                                //if (!this.tryAssignCurrentValue(cell, map))
1158
                                                {
×
1159
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1160
                                                }
×
1161
                                                break;
×
1162
                                }
1163

1164
                                if (end)
×
1165
                                {
×
1166
                                        break;
×
1167
                                }
1168

1169
                                this._reader.ReadNext();
×
1170
                        }
×
1171
                }
×
1172

1173
                private void readLinkedTableCell(TableEntity.Cell cell)
1174
                {
5,376✔
1175
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1176

1177
                        this._reader.ReadNext();
5,376✔
1178

1179
                        bool end = false;
5,376✔
1180
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1181
                        {
53,760✔
1182
                                switch (this._reader.Code)
53,760✔
1183
                                {
1184
                                        case 95:
1185
                                                //BL 95 Number of cell contents
1186
                                                break;
5,248✔
1187
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1188
                                                this.readCustomData();
5,376✔
1189
                                                break;
5,376✔
1190
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1191
                                                var c = this.readLinkedTableCellContent();
4,096✔
1192
                                                break;
4,096✔
1193
                                        case 309:
1194
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1195
                                                break;
5,248✔
1196
                                        default:
1197
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1198
                                                {
11,648✔
1199
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1200
                                                }
11,648✔
1201
                                                break;
33,792✔
1202
                                }
1203

1204
                                if (end)
53,760✔
1205
                                {
5,248✔
1206
                                        break;
5,248✔
1207
                                }
1208

1209
                                this._reader.ReadNext();
48,512✔
1210
                        }
48,512✔
1211
                }
5,376✔
1212

1213
                private CadTableCellContentTemplate readLinkedTableCellContent()
1214
                {
4,096✔
1215
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1216
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1217
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1218

1219
                        this._reader.ReadNext();
4,096✔
1220

1221
                        bool end = false;
4,096✔
1222
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1223
                        {
8,192✔
1224
                                switch (this._reader.Code)
8,192!
1225
                                {
1226
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1227
                                                readFormattedCellContent();
4,096✔
1228
                                                end = true;
4,096✔
1229
                                                break;
4,096✔
1230
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1231
                                                readCellContent(template);
4,096✔
1232
                                                break;
4,096✔
1233
                                        default:
1234
                                                if (!this.tryAssignCurrentValue(content, map))
×
1235
                                                {
×
1236
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1237
                                                }
×
1238
                                                break;
×
1239
                                }
1240

1241
                                if (end)
8,192✔
1242
                                {
4,096✔
1243
                                        break;
4,096✔
1244
                                }
1245

1246
                                this._reader.ReadNext();
4,096✔
1247
                        }
4,096✔
1248

1249
                        return template;
4,096✔
1250
                }
4,096✔
1251

1252
                private void readCellContent(CadTableCellContentTemplate template)
1253
                {
4,096✔
1254
                        TableEntity.CellContent content = template.Content;
4,096✔
1255
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1256

1257
                        this._reader.ReadNext();
4,096✔
1258

1259
                        bool end = false;
4,096✔
1260
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1261
                        {
16,384✔
1262
                                switch (this._reader.Code)
16,384✔
1263
                                {
1264
                                        case 91:
1265
                                                break;
4,096✔
1266
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1267
                                                this.readDataMapValue();
3,712✔
1268
                                                break;
3,712✔
1269
                                        case 309:
1270
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1271
                                                break;
4,096✔
1272
                                        case 340:
1273
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1274
                                                break;
384✔
1275
                                        default:
1276
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1277
                                                {
×
1278
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1279
                                                }
×
1280
                                                break;
4,096✔
1281
                                }
1282

1283
                                if (end)
16,384✔
1284
                                {
4,096✔
1285
                                        break;
4,096✔
1286
                                }
1287

1288
                                this._reader.ReadNext();
12,288✔
1289
                        }
12,288✔
1290
                }
4,096✔
1291

1292
                private void readFormattedCellContent()
1293
                {
4,096✔
1294
                        TableEntity.ContentFormat format = new();
4,096✔
1295
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1296
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1297

1298
                        this._reader.ReadNext();
4,096✔
1299

1300
                        bool end = false;
4,096✔
1301
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1302
                        {
12,288✔
1303
                                switch (this._reader.Code)
12,288✔
1304
                                {
1305
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1306
                                                readContentFormat(template);
4,096✔
1307
                                                break;
4,096✔
1308
                                        case 309:
1309
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1310
                                                break;
4,096✔
1311
                                        default:
1312
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1313
                                                {
×
1314
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1315
                                                }
×
1316
                                                break;
4,096✔
1317
                                }
1318

1319
                                if (end)
12,288✔
1320
                                {
4,096✔
1321
                                        break;
4,096✔
1322
                                }
1323

1324
                                this._reader.ReadNext();
8,192✔
1325
                        }
8,192✔
1326
                }
4,096✔
1327

1328
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1329
                {
9,600✔
1330
                        var format = template.Format;
9,600✔
1331
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1332

1333
                        this._reader.ReadNext();
9,600✔
1334

1335
                        bool end = false;
9,600✔
1336
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1337
                        {
124,800✔
1338
                                switch (this._reader.Code)
124,800✔
1339
                                {
1340
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1341
                                                break;
9,600✔
1342
                                        case 309:
1343
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1344
                                                break;
9,600✔
1345
                                        case 340:
1346
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1347
                                                break;
9,600✔
1348
                                        default:
1349
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1350
                                                {
×
1351
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1352
                                                }
×
1353
                                                break;
96,000✔
1354
                                }
1355

1356
                                if (end)
124,800✔
1357
                                {
9,600✔
1358
                                        break;
9,600✔
1359
                                }
1360

1361
                                this._reader.ReadNext();
115,200✔
1362
                        }
115,200✔
1363
                }
9,600✔
1364

1365
                private void readFormattedTableColumn(TableEntity.Column column)
1366
                {
1,216✔
1367
                        this._reader.ReadNext();
1,216✔
1368

1369
                        bool end = false;
1,216✔
1370
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1371
                        {
3,648✔
1372
                                switch (this._reader.Code)
3,648!
1373
                                {
1374
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1375
                                                break;
1,216✔
1376
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1377
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1378
                                                break;
1,216✔
1379
                                        case 309:
1380
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1381
                                                break;
1,216✔
1382
                                        default:
1383
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1384
                                                break;
×
1385
                                }
1386

1387
                                if (end)
3,648✔
1388
                                {
1,216✔
1389
                                        break;
1,216✔
1390
                                }
1391

1392
                                this._reader.ReadNext();
2,432✔
1393
                        }
2,432✔
1394
                }
1,216✔
1395

1396
                private void readStyleOverride(CadCellStyleTemplate template)
1397
                {
8,128✔
1398
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1399
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1400
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1401

1402
                        this._reader.ReadNext();
8,128✔
1403

1404
                        bool end = false;
8,128✔
1405
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1406
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1407
                        {
89,536✔
1408
                                switch (this._reader.Code)
89,536✔
1409
                                {
1410
                                        case 95:
1411
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1412
                                                break;
11,776✔
1413
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1414
                                                break;
256✔
1415
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1416
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1417
                                                break;
5,504✔
1418
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1419
                                                this.readCellMargin(template);
2,816✔
1420
                                                break;
2,816✔
1421
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1422
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1423
                                                this.readGridFormat(template, border);
11,776✔
1424
                                                break;
11,776✔
1425
                                        case 309:
1426
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1427
                                                break;
8,128✔
1428
                                        default:
1429
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
1430
                                                {
×
1431
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1432
                                                }
×
1433
                                                break;
49,280✔
1434
                                }
1435

1436
                                if (end)
89,536✔
1437
                                {
8,128✔
1438
                                        break;
8,128✔
1439
                                }
1440

1441
                                this._reader.ReadNext();
81,408✔
1442
                        }
81,408✔
1443
                }
8,128✔
1444

1445
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1446
                {
11,776✔
1447
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1448

1449
                        this._reader.ReadNext();
11,776✔
1450

1451
                        bool end = false;
11,776✔
1452
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1453
                        {
105,984✔
1454
                                switch (this._reader.Code)
105,984✔
1455
                                {
1456
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1457
                                                break;
11,776✔
1458
                                        case 62:
1459
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1460
                                                break;
11,776✔
1461
                                        case 92:
1462
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1463
                                                break;
11,776✔
1464
                                        case 93:
1465
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1466
                                                break;
11,776✔
1467
                                        case 340:
1468
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1469
                                                break;
11,776✔
1470
                                        case 309:
1471
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1472
                                                break;
11,776✔
1473
                                        default:
1474
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
1475
                                                {
×
1476
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1477
                                                }
×
1478
                                                break;
35,328✔
1479
                                }
1480

1481
                                if (end)
105,984✔
1482
                                {
11,776✔
1483
                                        break;
11,776✔
1484
                                }
1485

1486
                                this._reader.ReadNext();
94,208✔
1487
                        }
94,208✔
1488
                }
11,776✔
1489

1490
                private void readCellMargin(CadCellStyleTemplate template)
1491
                {
2,816✔
1492
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1493

1494
                        this._reader.ReadNext();
2,816✔
1495

1496
                        bool end = false;
2,816✔
1497
                        int i = 0;
2,816✔
1498
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1499
                        {
22,528✔
1500
                                switch (this._reader.Code)
22,528!
1501
                                {
1502
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1503
                                                break;
2,816✔
1504
                                        case 40:
1505
                                                switch (i)
16,896✔
1506
                                                {
1507
                                                        case 0:
1508
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1509
                                                                break;
2,816✔
1510
                                                        case 1:
1511
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1512
                                                                break;
2,816✔
1513
                                                        case 2:
1514
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1515
                                                                break;
2,816✔
1516
                                                        case 3:
1517
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1518
                                                                break;
2,816✔
1519
                                                        case 4:
1520
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1521
                                                                break;
2,816✔
1522
                                                        case 5:
1523
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1524
                                                                break;
2,816✔
1525
                                                }
1526

1527
                                                i++;
16,896✔
1528
                                                break;
16,896✔
1529
                                        case 309:
1530
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1531
                                                break;
2,816✔
1532
                                        default:
1533
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1534
                                                break;
×
1535
                                }
1536

1537
                                if (end)
22,528✔
1538
                                {
2,816✔
1539
                                        break;
2,816✔
1540
                                }
1541

1542
                                this._reader.ReadNext();
19,712✔
1543
                        }
19,712✔
1544
                }
2,816✔
1545

1546
                private void readCustomData()
1547
                {
8,000✔
1548
                        this._reader.ReadNext();
8,000✔
1549

1550
                        int ndata = 0;
8,000✔
1551
                        bool end = false;
8,000✔
1552
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1553
                        {
74,304✔
1554
                                switch (this._reader.Code)
74,304✔
1555
                                {
1556
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1557
                                                break;
8,000✔
1558
                                        case 90:
1559
                                                ndata = this._reader.ValueAsInt;
8,128✔
1560
                                                break;
8,128✔
1561
                                        case 300:
1562
                                                //Name
1563
                                                break;
5,248✔
1564
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1565
                                                this.readDataMapValue();
5,248✔
1566
                                                break;
5,248✔
1567
                                        case 309:
1568
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1569
                                                break;
7,872✔
1570
                                        default:
1571
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1572
                                                break;
39,808✔
1573
                                }
1574

1575
                                if (end)
74,304✔
1576
                                {
7,872✔
1577
                                        break;
7,872✔
1578
                                }
1579

1580
                                this._reader.ReadNext();
66,432✔
1581
                        }
66,432✔
1582
                }
8,000✔
1583

1584
                private void readDataMapValue()
1585
                {
8,960✔
1586
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1587
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1588

1589
                        this._reader.ReadNext();
8,960✔
1590

1591
                        bool end = false;
8,960✔
1592
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1593
                        {
330,112✔
1594
                                switch (this._reader.Code)
330,112✔
1595
                                {
1596
                                        case 11:
1597
                                        case 21:
1598
                                        case 31:
1599
                                                //Value as point
1600
                                                break;
768✔
1601
                                        case 91:
1602
                                        case 92:
1603
                                                //Value as int
1604
                                                break;
38,912✔
1605
                                        case 140:
1606
                                                //Value as double
1607
                                                break;
13,248✔
1608
                                        case 310:
1609
                                                //Value as byte array
1610
                                                break;
256✔
1611
                                        case 304:
1612
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1613
                                                break;
8,832✔
1614
                                        default:
1615
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1616
                                                {
106,880✔
1617
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1618
                                                }
106,880✔
1619
                                                break;
268,096✔
1620
                                }
1621

1622
                                if (end)
330,112✔
1623
                                {
8,832✔
1624
                                        break;
8,832✔
1625
                                }
1626

1627
                                this._reader.ReadNext();
321,280✔
1628
                        }
321,280✔
1629
                }
8,960✔
1630

1631
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1632
                {
379,506✔
1633
                        switch (this._reader.Code)
379,506✔
1634
                        {
1635
                                // Undocumented codes
1636
                                case 176:
1637
                                case 177:
1638
                                case 420:
1639
                                        return true;
123,592✔
1640
                                default:
1641
                                        //Avoid noise while is not implemented
1642
                                        return true;
255,914✔
1643
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1644
                        }
1645
                }
379,506✔
1646

1647
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1648
                {
4,032✔
1649
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1650
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1651

1652
                        switch (this._reader.Code)
4,032✔
1653
                        {
1654
                                case 10:
1655
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1656
                                        return true;
384✔
1657
                                case 20:
1658
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1659
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1660
                                        return true;
384✔
1661
                                case 40:
1662
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1663
                                        {
×
1664
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1665
                                                tmp.HasFrontPlane = true;
×
1666
                                        }
×
1667

1668
                                        double[] array = new double[16]
384✔
1669
                                        {
384✔
1670
                                                0.0, 0.0, 0.0, 0.0,
384✔
1671
                                                0.0, 0.0, 0.0, 0.0,
384✔
1672
                                                0.0, 0.0, 0.0, 0.0,
384✔
1673
                                                0.0, 0.0, 0.0, 1.0
384✔
1674
                                        };
384✔
1675

1676
                                        for (int i = 0; i < 12; i++)
9,984✔
1677
                                        {
4,608✔
1678
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1679

1680
                                                if (i < 11)
4,608✔
1681
                                                {
4,224✔
1682
                                                        this._reader.ReadNext();
4,224✔
1683
                                                }
4,224✔
1684
                                        }
4,608✔
1685

1686
                                        if (tmp.InsertTransformRead)
384!
1687
                                        {
×
1688
                                                filter.InsertTransform = new Matrix4(array);
×
1689
                                                tmp.InsertTransformRead = true;
×
1690
                                        }
×
1691
                                        else
1692
                                        {
384✔
1693
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1694
                                        }
384✔
1695

1696
                                        return true;
384✔
1697
                                case 73:
1698
                                default:
1699
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1700
                        }
1701
                }
4,032✔
1702

1703
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1704
                {
3,529✔
1705
                        var tmp = template as CadMLineStyleTemplate;
3,529✔
1706
                        var mLineStyle = template.CadObject as MLineStyle;
3,529✔
1707

1708
                        switch (this._reader.Code)
3,529✔
1709
                        {
1710
                                case 6:
1711
                                        var t = tmp.ElementTemplates.LastOrDefault();
418✔
1712
                                        if (t == null)
418!
1713
                                        {
×
1714
                                                return true;
×
1715
                                        }
1716
                                        t.LineTypeName = this._reader.ValueAsString;
418✔
1717
                                        return true;
418✔
1718
                                case 49:
1719
                                        MLineStyle.Element element = new MLineStyle.Element();
418✔
1720
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
418✔
1721
                                        element.Offset = this._reader.ValueAsDouble;
418✔
1722

1723
                                        tmp.ElementTemplates.Add(elementTemplate);
418✔
1724
                                        mLineStyle.AddElement(element);
418✔
1725
                                        return true;
418✔
1726
                                default:
1727
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,693✔
1728
                        }
1729
                }
3,529✔
1730

1731
                private bool readTableStyle(CadTemplate template, DxfMap map)
1732
                {
17,845✔
1733
                        var tmp = template as CadTableStyleTemplate;
17,845✔
1734
                        var style = tmp.CadObject;
17,845✔
1735
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,845✔
1736

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

1829
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1830
                {
18,636✔
1831
                        var tmp = template as CadMLeaderStyleTemplate;
18,636✔
1832

1833
                        switch (this._reader.Code)
18,636✔
1834
                        {
1835
                                case 179:
1836
                                        return true;
212✔
1837
                                case 340:
1838
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
406✔
1839
                                        return true;
406✔
1840
                                case 342:
1841
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
406✔
1842
                                        return true;
406✔
1843
                                default:
1844
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,612✔
1845
                        }
1846
                }
18,636✔
1847

1848
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1849
                {
13,737✔
1850
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,737✔
1851

1852
                        switch (this._reader.Code)
13,737✔
1853
                        {
1854
                                case 1:
1855
                                        this._reader.ExpectedCode(70);
1,158✔
1856
                                        this._reader.ExpectedCode(140);
1,158✔
1857
                                        return true;
1,158✔
1858
                                default:
1859
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,579✔
1860
                        }
1861
                }
13,737✔
1862

1863
                private bool readBlockElement(CadTemplate template, DxfMap map)
1864
                {
5,249✔
1865
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,249✔
1866

1867
                        switch (this._reader.Code)
5,249✔
1868
                        {
1869
                                default:
1870
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,249✔
1871
                                        {
4,473✔
1872
                                                return this.readEvaluationExpression(template, map);
4,473✔
1873
                                        }
1874
                                        return true;
776✔
1875
                        }
1876
                }
5,249✔
1877

1878
                private bool readBlockAction(CadTemplate template, DxfMap map)
1879
                {
20✔
1880
                        CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
20✔
1881

1882
                        switch (this._reader.Code)
20✔
1883
                        {
1884
                                default:
1885
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
20✔
1886
                                        {
15✔
1887
                                                return this.readBlockElement(template, map);
15✔
1888
                                        }
1889
                                        return true;
5✔
1890
                        }
1891
                }
20✔
1892

1893
                private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
1894
                {
31✔
1895
                        CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
31✔
1896

1897
                        switch (this._reader.Code)
31✔
1898
                        {
1899
                                default:
1900
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
31✔
1901
                                        {
20✔
1902
                                                return this.readBlockAction(template, map);
20✔
1903
                                        }
1904
                                        return true;
11✔
1905
                        }
1906
                }
31✔
1907

1908
                private bool readBlockRotationAction(CadTemplate template, DxfMap map)
1909
                {
33✔
1910
                        CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
33✔
1911

1912
                        switch (this._reader.Code)
33✔
1913
                        {
1914
                                default:
1915
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
33✔
1916
                                        {
31✔
1917
                                                return this.readBlockActionBasePt(template, map);
31✔
1918
                                        }
1919
                                        return true;
2✔
1920
                        }
1921
                }
33✔
1922

1923
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1924
                {
3,291✔
1925
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,291✔
1926

1927
                        switch (this._reader.Code)
3,291✔
1928
                        {
1929
                                default:
1930
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,291✔
1931
                                        {
2,712✔
1932
                                                return this.readBlockElement(template, map);
2,712✔
1933
                                        }
1934
                                        return true;
579✔
1935
                        }
1936
                }
3,291✔
1937

1938
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1939
                {
4,246✔
1940
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1941

1942
                        switch (this._reader.Code)
4,246✔
1943
                        {
1944
                                default:
1945
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
1946
                                        {
3,281✔
1947
                                                return this.readBlockParameter(template, map);
3,281✔
1948
                                        }
1949
                                        return true;
965✔
1950
                        }
1951
                }
4,246✔
1952

1953
                private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
1954
                {
14✔
1955
                        var tmp = template as CadBlock2PtParameterTemplate;
14✔
1956

1957
                        switch (this._reader.Code)
14✔
1958
                        {
1959
                                //Stores always 4 entries using this code
1960
                                case 91:
1961
                                        return true;
4✔
1962
                                default:
1963
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
10!
1964
                                        {
10✔
1965
                                                return this.readBlockParameter(template, map);
10✔
1966
                                        }
NEW
1967
                                        return true;
×
1968
                        }
1969
                }
14✔
1970

1971
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
1972
                {
5,404✔
1973
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
1974

1975
                        switch (this._reader.Code)
5,404✔
1976
                        {
1977
                                case 92:
1978
                                        var stateCount = this._reader.ValueAsInt;
193✔
1979
                                        for (int i = 0; i < stateCount; i++)
1,930✔
1980
                                        {
772✔
1981
                                                this._reader.ReadNext();
772✔
1982
                                                tmp.StateTemplates.Add(this.readState());
772✔
1983
                                        }
772✔
1984
                                        return true;
193✔
1985
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
1986
                                        var entityCount = this._reader.ValueAsInt;
193✔
1987
                                        for (int i = 0; i < entityCount; i++)
780✔
1988
                                        {
197✔
1989
                                                this._reader.ReadNext();
197✔
1990
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
197✔
1991
                                        }
197✔
1992
                                        return true;
193✔
1993
                                default:
1994
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
1995
                                        {
4,246✔
1996
                                                return this.readBlock1PtParameter(template, map);
4,246✔
1997
                                        }
1998
                                        return true;
772✔
1999
                        }
2000
                }
5,404✔
2001

2002
                private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2003
                {
49✔
2004
                        var tmp = template as CadBlockRotationParameterTemplate;
49✔
2005

2006
                        switch (this._reader.Code)
49✔
2007
                        {
2008
                                default:
2009
                                        if (!this.tryAssignCurrentValue(template.CadObject, map))
49✔
2010
                                        {
14✔
2011
                                                return this.readBlock2PtParameter(template, map);
14✔
2012
                                        }
2013
                                        return true;
35✔
2014
                        }
2015
                }
49✔
2016

2017
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2018
                {
772✔
2019
                        var state = new BlockVisibilityParameter.State();
772✔
2020
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
2021

2022
                        List<int> expectedCodes = new List<int>();
772✔
2023
                        expectedCodes.Add(303);
772✔
2024
                        expectedCodes.Add(94);
772✔
2025
                        expectedCodes.Add(95);
772✔
2026

2027
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
2028
                        {
2,316✔
2029
                                expectedCodes.Remove(this._reader.Code);
2,316✔
2030

2031
                                switch (this._reader.Code)
2,316!
2032
                                {
2033
                                        case 303:
2034
                                                state.Name = this._reader.ValueAsString;
772✔
2035
                                                break;
772✔
2036
                                        case 94:
2037
                                                var count = this._reader.ValueAsInt;
772✔
2038
                                                for (int i = 0; i < count; i++)
2,720✔
2039
                                                {
588✔
2040
                                                        this._reader.ReadNext();
588✔
2041
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
2042
                                                }
588✔
2043
                                                break;
772✔
2044
                                        case 95:
2045
                                                count = this._reader.ValueAsInt;
772✔
2046
                                                for (int i = 0; i < count; i++)
6,152✔
2047
                                                {
2,304✔
2048
                                                        this._reader.ReadNext();
2,304✔
2049
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2050
                                                }
2,304✔
2051
                                                break;
772✔
2052
                                        default:
2053
                                                return template;
×
2054
                                }
2055

2056
                                if (!expectedCodes.Any())
2,316✔
2057
                                {
772✔
2058
                                        break;
772✔
2059
                                }
2060

2061
                                this._reader.ReadNext();
1,544✔
2062
                        }
1,544✔
2063

2064
                        return template;
772✔
2065
                }
772✔
2066

2067
                private bool readBlockGrip(CadTemplate template, DxfMap map)
2068
                {
3,880✔
2069
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,880✔
2070

2071
                        switch (this._reader.Code)
3,880✔
2072
                        {
2073
                                default:
2074
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,880✔
2075
                                        {
2,522✔
2076
                                                return this.readBlockElement(template, map);
2,522✔
2077
                                        }
2078
                                        return true;
1,358✔
2079
                        }
2080
                }
3,880✔
2081

2082
                private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
2083
                {
20✔
2084
                        CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
20✔
2085

2086
                        switch (this._reader.Code)
20✔
2087
                        {
2088
                                default:
2089
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
20!
2090
                                        {
20✔
2091
                                                return this.readBlockGrip(template, map);
20✔
2092
                                        }
NEW
2093
                                        return true;
×
2094
                        }
2095
                }
20✔
2096

2097
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
2098
                {
3,860✔
2099
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2100

2101
                        switch (this._reader.Code)
3,860✔
2102
                        {
2103
                                default:
2104
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2105
                                        {
3,860✔
2106
                                                return this.readBlockGrip(template, map);
3,860✔
2107
                                        }
2108
                                        return true;
×
2109
                        }
2110
                }
3,860✔
2111

2112
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2113
                {
1,590✔
2114
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,590✔
2115

2116
                        switch (this._reader.Code)
1,590✔
2117
                        {
2118
                                case 340:
2119
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
265✔
2120
                                        return true;
265✔
2121
                                default:
2122
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,325✔
2123
                        }
2124
                }
1,590✔
2125

2126
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2127
                {
11,580✔
2128
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,580✔
2129

2130
                        switch (this._reader.Code)
11,580✔
2131
                        {
2132
                                default:
2133
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,580✔
2134
                                        {
9,264✔
2135
                                                return this.readEvaluationExpression(template, map);
9,264✔
2136
                                        }
2137
                                        return true;
2,316✔
2138
                        }
2139
                }
11,580✔
2140

2141
                private bool readXRecord(CadTemplate template, DxfMap map)
2142
                {
113,272✔
2143
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,272✔
2144

2145
                        switch (this._reader.Code)
113,272✔
2146
                        {
2147
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,926✔
2148
                                        this.readXRecordEntries(tmp);
28,926✔
2149
                                        return true;
28,926✔
2150
                                default:
2151
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,346✔
2152
                        }
2153
                }
113,272✔
2154

2155
                private void readXRecordEntries(CadXRecordTemplate template)
2156
                {
28,926✔
2157
                        this._reader.ReadNext();
28,926✔
2158

2159
                        while (this._reader.DxfCode != DxfCode.Start)
2,409,286✔
2160
                        {
2,380,360✔
2161
                                switch (this._reader.GroupCodeValue)
2,380,360✔
2162
                                {
2163
                                        case GroupCodeValueType.Point3D:
2164
                                                var code = this._reader.Code;
2,901✔
2165
                                                var x = this._reader.ValueAsDouble;
2,901✔
2166
                                                this._reader.ReadNext();
2,901✔
2167
                                                var y = this._reader.ValueAsDouble;
2,901✔
2168
                                                this._reader.ReadNext();
2,901✔
2169
                                                var z = this._reader.ValueAsDouble;
2,901✔
2170
                                                XYZ pt = new XYZ(x, y, z);
2,901✔
2171
                                                template.CadObject.CreateEntry(code, pt);
2,901✔
2172
                                                break;
2,901✔
2173
                                        case GroupCodeValueType.Handle:
2174
                                        case GroupCodeValueType.ObjectId:
2175
                                        case GroupCodeValueType.ExtendedDataHandle:
2176
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,041✔
2177
                                                break;
12,041✔
2178
                                        default:
2179
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,418✔
2180
                                                break;
2,365,418✔
2181
                                }
2182

2183
                                this._reader.ReadNext();
2,380,360✔
2184
                        }
2,380,360✔
2185
                }
28,926✔
2186

2187
                private bool readBookColor(CadTemplate template, DxfMap map)
2188
                {
1,376✔
2189
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2190
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2191

2192
                        switch (this._reader.Code)
1,376✔
2193
                        {
2194
                                case 430:
2195
                                        color.Name = this._reader.ValueAsString;
160✔
2196
                                        return true;
160✔
2197
                                default:
2198
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2199
                        }
2200
                }
1,376✔
2201

2202
                private bool readDictionary(CadTemplate template, DxfMap map)
2203
                {
224,204✔
2204
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
224,204✔
2205
                        CadDictionary cadDictionary = tmp.CadObject;
224,204✔
2206

2207
                        switch (this._reader.Code)
224,204✔
2208
                        {
2209
                                case 280:
2210
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,069✔
2211
                                        return true;
15,069✔
2212
                                case 281:
2213
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,522✔
2214
                                        return true;
21,522✔
2215
                                case 3:
2216
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,371✔
2217
                                        return true;
57,371✔
2218
                                case 350: // Soft-owner ID/handle to entry object 
2219
                                case 360: // Hard-owner ID/handle to entry object
2220
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,371✔
2221
                                        return true;
57,371✔
2222
                                default:
2223
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,871✔
2224
                        }
2225
                }
224,204✔
2226

2227
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2228
                {
1,773✔
2229
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,773✔
2230

2231
                        switch (this._reader.Code)
1,773✔
2232
                        {
2233
                                case 340:
2234
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
197✔
2235
                                        return true;
197✔
2236
                                default:
2237
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,576!
2238
                                        {
1,576✔
2239
                                                return this.readDictionary(template, map);
1,576✔
2240
                                        }
2241
                                        return true;
×
2242
                        }
2243
                }
1,773✔
2244

2245
                private CadTemplate readSortentsTable()
2246
                {
576✔
2247
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2248
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2249

2250
                        //Jump the 0 marker
2251
                        this._reader.ReadNext();
576✔
2252

2253
                        this.readCommonObjectData(template);
576✔
2254

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

2257
                        //Jump the 100 marker
2258
                        this._reader.ReadNext();
576✔
2259

2260
                        (ulong?, ulong?) pair = (null, null);
576✔
2261

2262
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2263
                        {
3,648✔
2264
                                switch (this._reader.Code)
3,648!
2265
                                {
2266
                                        case 5:
2267
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2268
                                                break;
1,536✔
2269
                                        case 330:
2270
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2271
                                                break;
576✔
2272
                                        case 331:
2273
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2274
                                                break;
1,536✔
2275
                                        default:
2276
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2277
                                                break;
×
2278
                                }
2279

2280
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2281
                                {
1,536✔
2282
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2283
                                        pair = (null, null);
1,536✔
2284
                                }
1,536✔
2285

2286
                                this._reader.ReadNext();
3,648✔
2287
                        }
3,648✔
2288

2289
                        return template;
576✔
2290
                }
576✔
2291
        }
2292
}
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