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

DomCR / ACadSharp / 20987825577

14 Jan 2026 08:42AM UTC coverage: 77.003% (+0.1%) from 76.896%
20987825577

Pull #949

github

web-flow
Merge 9a946280d into 024480147
Pull Request #949: issue-948 dynamic properties

7990 of 11229 branches covered (71.16%)

Branch coverage included in aggregate %.

184 of 206 new or added lines in 17 files covered. (89.32%)

15 existing lines in 4 files now uncovered.

29026 of 36842 relevant lines covered (78.79%)

148694.17 hits per line

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

86.12
/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)
207✔
23
                {
207✔
24
                }
207✔
25

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

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

36
                                try
37
                                {
77,106✔
38
                                        template = this.readObject();
77,106✔
39
                                }
77,106✔
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,106✔
52
                                        continue;
×
53

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

59
                private CadTemplate readObject()
60
                {
77,106✔
61
                        switch (this._reader.ValueAsString)
77,106!
62
                        {
63
                                case DxfFileToken.ObjectPlaceholder:
64
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
195✔
65
                                case DxfFileToken.ObjectDBColor:
66
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
192✔
67
                                case DxfFileToken.ObjectDictionary:
68
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
21,252✔
69
                                case DxfFileToken.ObjectDictionaryWithDefault:
70
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
195✔
71
                                case DxfFileToken.ObjectLayout:
72
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
801✔
73
                                case DxfFileToken.ObjectPlotSettings:
74
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
75
                                case DxfFileToken.ObjectEvalGraph:
76
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
449✔
77
                                case DxfFileToken.ObjectImageDefinition:
78
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
192✔
79
                                case DxfFileToken.ObjectDictionaryVar:
80
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,796✔
81
                                case DxfFileToken.ObjectPdfDefinition:
82
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
192✔
83
                                case DxfFileToken.ObjectSortEntsTable:
84
                                        return this.readSortentsTable();
576✔
85
                                case DxfFileToken.ObjectImageDefinitionReactor:
86
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
192✔
87
                                case DxfFileToken.ObjectProxyObject:
88
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
89
                                case DxfFileToken.ObjectRasterVariables:
90
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
192✔
91
                                case DxfFileToken.ObjectGroup:
92
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
384✔
93
                                case DxfFileToken.ObjectGeoData:
94
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
95
                                case DxfFileToken.ObjectMaterial:
96
                                        return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,121✔
97
                                case DxfFileToken.ObjectScale:
98
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
6,639✔
99
                                case DxfFileToken.ObjectTableContent:
100
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
320✔
101
                                case DxfFileToken.ObjectVisualStyle:
102
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
4,680✔
103
                                case DxfFileToken.ObjectSpatialFilter:
104
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
192✔
105
                                case DxfFileToken.ObjectMLineStyle:
106
                                        return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
207✔
107
                                case DxfFileToken.ObjectMLeaderStyle:
108
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
402✔
109
                                case DxfFileToken.ObjectTableStyle:
110
                                        return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
195✔
111
                                case DxfFileToken.ObjectXRecord:
112
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
28,896✔
113
                                case DxfFileToken.ObjectBlockGripLocationComponent:
114
                                        return this.readObjectCodes<BlockGripExpression>(new CadBlockGripExpressionTemplate(), this.readBlockGripExpression);
1,154✔
115
                                case DxfFileToken.ObjectBlockVisibilityGrip:
116
                                        return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockVisibilityGripTemplate(), this.readBlockVisibilityGrip);
193✔
117
                                case DxfFileToken.ObjectBlockVisibilityParameter:
118
                                        return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
193✔
119
                                default:
120
                                        DxfMap map = DxfMap.Create<CadObject>();
4,304✔
121
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
4,304✔
122
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
4,304!
123
                                        {
4,304✔
124
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
4,304✔
125
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
4,304✔
126
                                        }
4,304✔
127
                                        else
128
                                        {
×
129
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
130
                                        }
×
131

132
                                        this._reader.ReadNext();
4,304✔
133

134
                                        do
135
                                        {
253,942✔
136
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
253,942!
137
                                                {
30,768✔
138
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
30,768✔
139
                                                        if (isExtendedData)
30,768✔
140
                                                                continue;
24✔
141
                                                }
30,744✔
142

143
                                                this._reader.ReadNext();
253,918✔
144
                                        }
253,918✔
145
                                        while (this._reader.DxfCode != DxfCode.Start);
253,942✔
146

147
                                        return unknownEntityTemplate;
4,304✔
148
                        }
149
                }
77,106✔
150

151
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
152
                        where T : CadObject
153
                {
72,226✔
154
                        this._reader.ReadNext();
72,226✔
155

156
                        DxfMap map = DxfMap.Create<T>();
72,226✔
157

158
                        while (this._reader.DxfCode != DxfCode.Start)
1,031,873✔
159
                        {
959,647✔
160
                                if (!readObject(template, map))
959,647✔
161
                                {
231,224✔
162
                                        this.readCommonCodes(template, out bool isExtendedData, map);
231,224✔
163
                                        if (isExtendedData)
231,224✔
164
                                                continue;
2,982✔
165
                                }
228,242✔
166

167
                                if (this.lockPointer)
956,665✔
168
                                {
1,152✔
169
                                        this.lockPointer = false;
1,152✔
170
                                        continue;
1,152✔
171
                                }
172

173
                                if (this._reader.DxfCode != DxfCode.Start)
955,513✔
174
                                {
926,168✔
175
                                        this._reader.ReadNext();
926,168✔
176
                                }
926,168✔
177
                        }
955,513✔
178

179
                        return template;
72,226✔
180
                }
72,226✔
181

182
                private bool readProxyObject(CadTemplate template, DxfMap map)
183
                {
×
184
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
185

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

229
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
230
                {
23,241✔
231
                        switch (this._reader.Code)
23,241✔
232
                        {
233
                                default:
234
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,241✔
235
                        }
236
                }
23,241✔
237

238
                private bool readPlotSettings(CadTemplate template, DxfMap map)
239
                {
25,346✔
240
                        switch (this._reader.Code)
25,346✔
241
                        {
242
                                default:
243
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,346✔
244
                        }
245
                }
25,346✔
246

247
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
248
                {
3,080✔
249
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,080✔
250
                        EvaluationGraph evGraph = tmp.CadObject;
3,080✔
251

252
                        switch (this._reader.Code)
3,080✔
253
                        {
254
                                case 91:
255
                                        while (this._reader.Code == 91)
3,013✔
256
                                        {
2,564✔
257
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,564✔
258
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,564✔
259

260
                                                node.Index = this._reader.ValueAsInt;
2,564✔
261

262
                                                this._reader.ExpectedCode(93);
2,564✔
263
                                                node.Flags = this._reader.ValueAsInt;
2,564✔
264

265
                                                this._reader.ExpectedCode(95);
2,564✔
266
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,564✔
267

268
                                                this._reader.ExpectedCode(360);
2,564✔
269
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,564✔
270

271
                                                this._reader.ExpectedCode(92);
2,564✔
272
                                                node.Data1 = this._reader.ValueAsInt;
2,564✔
273
                                                this._reader.ExpectedCode(92);
2,564✔
274
                                                node.Data2 = this._reader.ValueAsInt;
2,564✔
275
                                                this._reader.ExpectedCode(92);
2,564✔
276
                                                node.Data3 = this._reader.ValueAsInt;
2,564✔
277
                                                this._reader.ExpectedCode(92);
2,564✔
278
                                                node.Data4 = this._reader.ValueAsInt;
2,564✔
279

280
                                                this._reader.ReadNext();
2,564✔
281

282
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,564✔
283
                                        }
2,564✔
284

285
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
449✔
286
                                case 92:
287
                                        //Edges
288
                                        while (this._reader.Code == 92)
2,116✔
289
                                        {
1,923✔
290
                                                this._reader.ExpectedCode(93);
1,923✔
291
                                                this._reader.ExpectedCode(94);
1,923✔
292
                                                this._reader.ExpectedCode(91);
1,923✔
293
                                                this._reader.ExpectedCode(91);
1,923✔
294
                                                this._reader.ExpectedCode(92);
1,923✔
295
                                                this._reader.ExpectedCode(92);
1,923✔
296
                                                this._reader.ExpectedCode(92);
1,923✔
297
                                                this._reader.ExpectedCode(92);
1,923✔
298
                                                this._reader.ExpectedCode(92);
1,923✔
299

300
                                                this._reader.ReadNext();
1,923✔
301
                                        }
1,923✔
302

303
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
193✔
304
                                default:
305
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,438✔
306
                        }
307
                }
3,080✔
308

309
                private bool readLayout(CadTemplate template, DxfMap map)
310
                {
51,597✔
311
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,597✔
312

313
                        switch (this._reader.Code)
51,597✔
314
                        {
315
                                case 330:
316
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,602✔
317
                                        return true;
1,602✔
318
                                case 331:
319
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
771✔
320
                                        return true;
771✔
321
                                default:
322
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,224✔
323
                                        {
25,346✔
324
                                                return this.readPlotSettings(template, map);
25,346✔
325
                                        }
326
                                        return true;
23,878✔
327
                        }
328
                }
51,597✔
329

330
                private bool readGroup(CadTemplate template, DxfMap map)
331
                {
4,992✔
332
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
333

334
                        switch (this._reader.Code)
4,992✔
335
                        {
336
                                case 70:
337
                                        return true;
384✔
338
                                case 340:
339
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
340
                                        return true;
2,304✔
341
                                default:
342
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
343
                        }
344
                }
4,992✔
345

346
                private bool readGeoData(CadTemplate template, DxfMap map)
347
                {
102✔
348
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
349

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

390
                                                this._reader.ReadNext();
24✔
391
                                                double destX = this._reader.ValueAsDouble;
24✔
392
                                                this._reader.ReadNext();
24✔
393
                                                double destY = this._reader.ValueAsDouble;
24✔
394

395
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
396
                                                {
24✔
397
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
398
                                                        Destination = new CSMath.XY(destX, destY)
24✔
399
                                                });
24✔
400
                                        }
24✔
401
                                        return true;
3✔
402
                                // Number of Geo-Mesh points
403
                                case 96:
404
                                        var nfaces = this._reader.ValueAsInt;
2✔
405
                                        for (int i = 0; i < nfaces; i++)
4!
406
                                        {
×
407
                                                this._reader.ReadNext();
×
408
                                                Debug.Assert(this._reader.Code == 97);
×
409
                                                int index1 = this._reader.ValueAsInt;
×
410
                                                this._reader.ReadNext();
×
411
                                                Debug.Assert(this._reader.Code == 98);
×
412
                                                int index2 = this._reader.ValueAsInt;
×
413
                                                this._reader.ReadNext();
×
414
                                                Debug.Assert(this._reader.Code == 99);
×
415
                                                int index3 = this._reader.ValueAsInt;
×
416

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

454
                private bool readMaterial(CadTemplate template, DxfMap map)
455
                {
42,062✔
456
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,062✔
457
                        List<double> arr = null;
42,062✔
458

459
                        switch (this._reader.Code)
42,062!
460
                        {
461
                                case 43:
462
                                        arr = new();
1,347✔
463
                                        for (int i = 0; i < 16; i++)
45,798✔
464
                                        {
21,552✔
465
                                                Debug.Assert(this._reader.Code == 43);
21,552✔
466

467
                                                arr.Add(this._reader.ValueAsDouble);
21,552✔
468

469
                                                this._reader.ReadNext();
21,552✔
470
                                        }
21,552✔
471

472
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,347✔
473
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,347✔
474
                                case 47:
475
                                        arr = new();
×
476
                                        for (int i = 0; i < 16; i++)
×
477
                                        {
×
478
                                                Debug.Assert(this._reader.Code == 47);
×
479

480
                                                arr.Add(this._reader.ValueAsDouble);
×
481

482
                                                this._reader.ReadNext();
×
483
                                        }
×
484

485
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
486
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
487
                                case 49:
488
                                        arr = new();
195✔
489
                                        for (int i = 0; i < 16; i++)
6,630✔
490
                                        {
3,120✔
491
                                                Debug.Assert(this._reader.Code == 49);
3,120✔
492

493
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
494

495
                                                this._reader.ReadNext();
3,120✔
496
                                        }
3,120✔
497

498
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
195✔
499
                                        return this.checkObjectEnd(template, map, this.readMaterial);
195✔
500
                                case 142:
501
                                        arr = new();
195✔
502
                                        for (int i = 0; i < 16; i++)
6,630✔
503
                                        {
3,120✔
504
                                                Debug.Assert(this._reader.Code == 142);
3,120✔
505

506
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
507

508
                                                this._reader.ReadNext();
3,120✔
509
                                        }
3,120✔
510

511
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
195✔
512
                                        return this.checkObjectEnd(template, map, this.readMaterial);
195✔
513
                                case 144:
514
                                        arr = new();
1,155✔
515
                                        for (int i = 0; i < 16; i++)
39,270✔
516
                                        {
18,480✔
517
                                                Debug.Assert(this._reader.Code == 144);
18,480✔
518

519
                                                arr.Add(this._reader.ValueAsDouble);
18,480✔
520

521
                                                this._reader.ReadNext();
18,480✔
522
                                        }
18,480✔
523

524
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,155✔
525
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,155✔
526
                                case 147:
527
                                        arr = new();
×
528
                                        for (int i = 0; i < 16; i++)
×
529
                                        {
×
530
                                                Debug.Assert(this._reader.Code == 147);
×
531

532
                                                arr.Add(this._reader.ValueAsDouble);
×
533

534
                                                this._reader.ReadNext();
×
535
                                        }
×
536

537
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
538
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
539
                                default:
540
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,170✔
541
                        }
542
                }
42,062✔
543

544
                private bool readScale(CadTemplate template, DxfMap map)
545
                {
59,547✔
546
                        switch (this._reader.Code)
59,547✔
547
                        {
548
                                // Undocumented codes
549
                                case 70:
550
                                        //Always 0
551
                                        return true;
6,639✔
552
                                default:
553
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
52,908✔
554
                        }
555
                }
59,547✔
556

557
                private void readLinkedData(CadTemplate template, DxfMap map)
558
                {
320✔
559
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
560
                        LinkedData linkedData = tmp.CadObject;
320✔
561

562
                        this._reader.ReadNext();
320✔
563

564
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
565
                        {
640✔
566
                                switch (this._reader.Code)
640✔
567
                                {
568
                                        default:
569
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
570
                                                {
×
571
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
572
                                                }
×
573
                                                break;
640✔
574
                                }
575

576
                                this._reader.ReadNext();
640✔
577
                        }
640✔
578
                }
320✔
579

580
                private bool readTableContent(CadTemplate template, DxfMap map)
581
                {
2,368✔
582
                        switch (this._reader.Code)
2,368✔
583
                        {
584
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
585
                                        this.readTableContentSubclass(template, map);
256✔
586
                                        this.lockPointer = true;
256✔
587
                                        return true;
256✔
588
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
589
                                        this.readFormattedTableDataSubclass(template, map);
256✔
590
                                        this.lockPointer = true;
256✔
591
                                        return true;
256✔
592
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
593
                                        this.readLinkedTableDataSubclass(template, map);
320✔
594
                                        this.lockPointer = true;
320✔
595
                                        return true;
320✔
596
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
597
                                        this.readLinkedData(template, map);
320✔
598
                                        this.lockPointer = true;
320✔
599
                                        return true;
320✔
600
                                default:
601
                                        return false;
1,216✔
602
                        }
603
                }
2,368✔
604

605
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
606
                {
256✔
607
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
608
                        TableContent tableContent = tmp.CadObject;
256✔
609

610
                        this._reader.ReadNext();
256✔
611

612
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
613
                        {
256✔
614
                                switch (this._reader.Code)
256!
615
                                {
616
                                        case 340:
617
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
618
                                                break;
256✔
619
                                        default:
620
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
621
                                                {
×
622
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
623
                                                }
×
624
                                                break;
×
625
                                }
626

627
                                this._reader.ReadNext();
256✔
628
                        }
256✔
629
                }
256✔
630

631
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
632
                {
256✔
633
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
634
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
635

636
                        this._reader.ReadNext();
256✔
637

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

689
                                this._reader.ReadNext();
2,048✔
690
                        }
2,048✔
691
                }
256✔
692

693
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
694
                {
320✔
695
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
696
                        TableContent tableContent = tmp.CadObject;
320✔
697

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

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

729
                                this._reader.ReadNext();
3,904✔
730
                        }
3,904✔
731
                }
320✔
732

733

734
                private TableEntity.Column readTableColumn()
735
                {
1,216✔
736
                        this._reader.ReadNext();
1,216✔
737

738
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
739

740
                        bool end = false;
1,216✔
741
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
742
                        {
3,648✔
743
                                switch (this._reader.Code)
3,648!
744
                                {
745
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
746
                                                this.readLinkedTableColumn(column);
1,216✔
747
                                                break;
1,216✔
748
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
749
                                                this.readFormattedTableColumn(column);
1,216✔
750
                                                break;
1,216✔
751
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
752
                                                this.readTableColumn(column);
1,216✔
753
                                                end = true;
1,216✔
754
                                                break;
1,216✔
755
                                        default:
756
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
757
                                                break;
×
758
                                }
759

760
                                if (end)
3,648✔
761
                                {
1,216✔
762
                                        return column;
1,216✔
763
                                }
764

765
                                this._reader.ReadNext();
2,432✔
766
                        }
2,432✔
767

768
                        return column;
×
769
                }
1,216✔
770

771
                private TableEntity.Row readTableRow()
772
                {
1,472✔
773
                        this._reader.ReadNext();
1,472✔
774

775
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
776

777
                        bool end = false;
1,472✔
778
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
779
                        {
11,840✔
780
                                switch (this._reader.Code)
11,840✔
781
                                {
782
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
783
                                                this.readLinkedTableRow(row);
1,536✔
784
                                                break;
1,536✔
785
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
786
                                                this.readFormattedTableRow(row);
1,408✔
787
                                                break;
1,408✔
788
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
789
                                                this.readTableRow(row);
1,408✔
790
                                                end = true;
1,408✔
791
                                                break;
1,408✔
792
                                        default:
793
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
794
                                                break;
7,488✔
795
                                }
796

797
                                if (end)
11,840✔
798
                                {
1,408✔
799
                                        return row;
1,408✔
800
                                }
801

802
                                this._reader.ReadNext();
10,432✔
803
                        }
10,432✔
804

805
                        return row;
64✔
806
                }
1,472✔
807

808
                private void readTableRow(TableEntity.Row row)
809
                {
1,408✔
810
                        this._reader.ReadNext();
1,408✔
811

812
                        bool end = false;
1,408✔
813
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
814
                        {
4,224✔
815
                                switch (this._reader.Code)
4,224!
816
                                {
817
                                        case 40:
818
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
819
                                                break;
1,408✔
820
                                        case 90:
821
                                                //styleID
822
                                                break;
1,408✔
823
                                        case 309:
824
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
825
                                                break;
1,408✔
826
                                        default:
827
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
828
                                                break;
×
829
                                }
830

831
                                if (end)
4,224✔
832
                                {
1,408✔
833
                                        break;
1,408✔
834
                                }
835

836
                                this._reader.ReadNext();
2,816✔
837
                        }
2,816✔
838
                }
1,408✔
839

840
                private void readFormattedTableRow(TableEntity.Row row)
841
                {
1,408✔
842
                        this._reader.ReadNext();
1,408✔
843

844
                        bool end = false;
1,408✔
845
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
846
                        {
4,224✔
847
                                switch (this._reader.Code)
4,224!
848
                                {
849
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
850
                                                break;
1,408✔
851
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
852
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
853
                                                break;
1,408✔
854
                                        case 309:
855
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
856
                                                break;
1,408✔
857
                                        default:
858
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
859
                                                break;
×
860
                                }
861

862
                                if (end)
4,224✔
863
                                {
1,408✔
864
                                        break;
1,408✔
865
                                }
866

867
                                this._reader.ReadNext();
2,816✔
868
                        }
2,816✔
869
                }
1,408✔
870

871
                private void readTableColumn(TableEntity.Column column)
872
                {
1,216✔
873
                        this._reader.ReadNext();
1,216✔
874

875
                        bool end = false;
1,216✔
876
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
877
                        {
3,648✔
878
                                switch (this._reader.Code)
3,648!
879
                                {
880
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
881
                                                break;
×
882
                                        case 1:
883
                                                end = true;
×
884
                                                break;
×
885
                                        case 40:
886
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
887
                                                break;
1,216✔
888
                                        case 90:
889
                                                //StyleId
890
                                                break;
1,216✔
891
                                        case 309:
892
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
893
                                                break;
1,216✔
894
                                        default:
895
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
896
                                                break;
×
897
                                }
898

899
                                if (end)
3,648✔
900
                                {
1,216✔
901
                                        break;
1,216✔
902
                                }
903

904
                                this._reader.ReadNext();
2,432✔
905
                        }
2,432✔
906
                }
1,216✔
907

908
                private void readLinkedTableColumn(TableEntity.Column column)
909
                {
1,216✔
910
                        this._reader.ReadNext();
1,216✔
911

912
                        bool end = false;
1,216✔
913
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
914
                        {
4,864✔
915
                                switch (this._reader.Code)
4,864!
916
                                {
917
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
918
                                                break;
×
919
                                        case 1:
920
                                                end = true;
×
921
                                                break;
×
922
                                        case 91:
923
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
924
                                                break;
1,216✔
925
                                        case 300:
926
                                                column.Name = this._reader.ValueAsString;
1,216✔
927
                                                break;
1,216✔
928
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
929
                                                this.readCustomData();
1,216✔
930
                                                break;
1,216✔
931
                                        case 309:
932
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
933
                                                break;
1,216✔
934
                                        default:
935
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
936
                                                break;
×
937
                                }
938

939
                                if (end)
4,864✔
940
                                {
1,216✔
941
                                        break;
1,216✔
942
                                }
943

944
                                this._reader.ReadNext();
3,648✔
945
                        }
3,648✔
946
                }
1,216✔
947

948
                private void readLinkedTableRow(TableEntity.Row row)
949
                {
1,536✔
950
                        this._reader.ReadNext();
1,536✔
951

952
                        bool end = false;
1,536✔
953
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
954
                        {
12,480✔
955
                                switch (this._reader.Code)
12,480!
956
                                {
957
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
958
                                                break;
×
959
                                        case 90:
960
                                                break;
1,536✔
961
                                        case 91:
962
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
963
                                                break;
1,408✔
964
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
965
                                                this.readCell();
5,376✔
966
                                                break;
5,376✔
967
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
968
                                                this.readCustomData();
1,408✔
969
                                                break;
1,408✔
970
                                        case 309:
971
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
972
                                                break;
1,408✔
973
                                        default:
974
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
975
                                                break;
1,344✔
976
                                }
977

978
                                if (end)
12,480✔
979
                                {
1,408✔
980
                                        break;
1,408✔
981
                                }
982

983
                                this._reader.ReadNext();
11,072✔
984
                        }
11,072✔
985
                }
1,536✔
986

987
                private TableEntity.Cell readCell()
988
                {
5,376✔
989
                        this._reader.ReadNext();
5,376✔
990

991
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
992
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
993

994
                        bool end = false;
5,376✔
995
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
996
                        {
16,832✔
997
                                switch (this._reader.Code)
16,832✔
998
                                {
999
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
1000
                                                this.readLinkedTableCell(cell);
5,376✔
1001
                                                break;
5,376✔
1002
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
1003
                                                this.readFormattedTableCell(cell);
5,248✔
1004
                                                break;
5,248✔
1005
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1006
                                                this.readTableCell(cell);
5,248✔
1007
                                                end = true;
5,248✔
1008
                                                break;
5,248✔
1009
                                        default:
1010
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1011
                                                break;
960✔
1012
                                }
1013

1014
                                if (end)
16,832✔
1015
                                {
5,248✔
1016
                                        return cell;
5,248✔
1017
                                }
1018

1019
                                this._reader.ReadNext();
11,584✔
1020
                        }
11,584✔
1021

1022
                        return cell;
128✔
1023
                }
5,376✔
1024

1025
                private void readTableCell(TableEntity.Cell cell)
1026
                {
5,248✔
1027
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1028

1029
                        this._reader.ReadNext();
5,248✔
1030

1031
                        bool end = false;
5,248✔
1032
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1033
                        {
16,384✔
1034
                                switch (this._reader.Code)
16,384✔
1035
                                {
1036
                                        //Unknown
1037
                                        case 40:
1038
                                        case 41:
1039
                                                break;
256✔
1040
                                        case 309:
1041
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1042
                                                break;
5,248✔
1043
                                        case 330:
1044
                                                //Unknown handle
1045
                                                break;
128✔
1046
                                        default:
1047
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1048
                                                {
×
1049
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1050
                                                }
×
1051
                                                break;
10,752✔
1052
                                }
1053

1054
                                if (end)
16,384✔
1055
                                {
5,248✔
1056
                                        break;
5,248✔
1057
                                }
1058

1059
                                this._reader.ReadNext();
11,136✔
1060
                        }
11,136✔
1061
                }
5,248✔
1062

1063
                private void readFormattedTableCell(TableEntity.Cell cell)
1064
                {
5,248✔
1065
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1066

1067
                        this._reader.ReadNext();
5,248✔
1068

1069
                        bool end = false;
5,248✔
1070
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1071
                        {
10,496✔
1072
                                switch (this._reader.Code)
10,496!
1073
                                {
1074
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1075
                                                this.readCellTableFormat(cell);
5,248✔
1076
                                                continue;
5,248✔
1077
                                        case 309:
1078
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1079
                                                break;
5,248✔
1080
                                        default:
1081
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1082
                                                {
×
1083
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1084
                                                }
×
1085
                                                break;
×
1086
                                }
1087

1088
                                if (end)
5,248!
1089
                                {
5,248✔
1090
                                        break;
5,248✔
1091
                                }
1092

1093
                                this._reader.ReadNext();
×
1094
                        }
×
1095
                }
5,248✔
1096

1097
                private void readCellTableFormat(TableEntity.Cell cell)
1098
                {
5,248✔
1099
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1100

1101
                        this._reader.ReadNext();
5,248✔
1102

1103
                        bool end = false;
5,248✔
1104
                        while (this._reader.Code == 1)
10,496✔
1105
                        {
5,248✔
1106
                                switch (this._reader.Code)
5,248!
1107
                                {
1108
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1109
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1110
                                                break;
5,248✔
1111
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1112
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1113
                                                break;
×
1114
                                        default:
1115
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1116
                                                {
×
1117
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1118
                                                }
×
1119
                                                break;
×
1120
                                }
1121

1122
                                if (end)
5,248!
1123
                                {
×
1124
                                        break;
×
1125
                                }
1126

1127
                                this._reader.ReadNext();
5,248✔
1128
                        }
5,248✔
1129
                }
5,248✔
1130

1131
                private void readCellStyle(CadCellStyleTemplate template)
1132
                {
×
1133
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1134

1135
                        this._reader.ReadNext();
×
1136

1137
                        bool end = false;
×
1138
                        while (this._reader.Code != 1)
×
1139
                        {
×
1140
                                switch (this._reader.Code)
×
1141
                                {
1142
                                        case 309:
1143
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1144
                                                break;
×
1145
                                        default:
1146
                                                //if (!this.tryAssignCurrentValue(cell, map))
1147
                                                {
×
1148
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1149
                                                }
×
1150
                                                break;
×
1151
                                }
1152

1153
                                if (end)
×
1154
                                {
×
1155
                                        break;
×
1156
                                }
1157

1158
                                this._reader.ReadNext();
×
1159
                        }
×
1160
                }
×
1161

1162
                private void readLinkedTableCell(TableEntity.Cell cell)
1163
                {
5,376✔
1164
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1165

1166
                        this._reader.ReadNext();
5,376✔
1167

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

1193
                                if (end)
53,760✔
1194
                                {
5,248✔
1195
                                        break;
5,248✔
1196
                                }
1197

1198
                                this._reader.ReadNext();
48,512✔
1199
                        }
48,512✔
1200
                }
5,376✔
1201

1202
                private CadTableCellContentTemplate readLinkedTableCellContent()
1203
                {
4,096✔
1204
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1205
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1206
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1207

1208
                        this._reader.ReadNext();
4,096✔
1209

1210
                        bool end = false;
4,096✔
1211
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1212
                        {
8,192✔
1213
                                switch (this._reader.Code)
8,192!
1214
                                {
1215
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1216
                                                readFormattedCellContent();
4,096✔
1217
                                                end = true;
4,096✔
1218
                                                break;
4,096✔
1219
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1220
                                                readCellContent(template);
4,096✔
1221
                                                break;
4,096✔
1222
                                        default:
1223
                                                if (!this.tryAssignCurrentValue(content, map))
×
1224
                                                {
×
1225
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1226
                                                }
×
1227
                                                break;
×
1228
                                }
1229

1230
                                if (end)
8,192✔
1231
                                {
4,096✔
1232
                                        break;
4,096✔
1233
                                }
1234

1235
                                this._reader.ReadNext();
4,096✔
1236
                        }
4,096✔
1237

1238
                        return template;
4,096✔
1239
                }
4,096✔
1240

1241
                private void readCellContent(CadTableCellContentTemplate template)
1242
                {
4,096✔
1243
                        TableEntity.CellContent content = template.Content;
4,096✔
1244
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1245

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

1248
                        bool end = false;
4,096✔
1249
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1250
                        {
16,384✔
1251
                                switch (this._reader.Code)
16,384✔
1252
                                {
1253
                                        case 91:
1254
                                                break;
4,096✔
1255
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1256
                                                this.readDataMapValue();
3,712✔
1257
                                                break;
3,712✔
1258
                                        case 309:
1259
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1260
                                                break;
4,096✔
1261
                                        case 340:
1262
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1263
                                                break;
384✔
1264
                                        default:
1265
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1266
                                                {
×
1267
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1268
                                                }
×
1269
                                                break;
4,096✔
1270
                                }
1271

1272
                                if (end)
16,384✔
1273
                                {
4,096✔
1274
                                        break;
4,096✔
1275
                                }
1276

1277
                                this._reader.ReadNext();
12,288✔
1278
                        }
12,288✔
1279
                }
4,096✔
1280

1281
                private void readFormattedCellContent()
1282
                {
4,096✔
1283
                        TableEntity.ContentFormat format = new();
4,096✔
1284
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1285
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1286

1287
                        this._reader.ReadNext();
4,096✔
1288

1289
                        bool end = false;
4,096✔
1290
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1291
                        {
12,288✔
1292
                                switch (this._reader.Code)
12,288✔
1293
                                {
1294
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1295
                                                readContentFormat(template);
4,096✔
1296
                                                break;
4,096✔
1297
                                        case 309:
1298
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1299
                                                break;
4,096✔
1300
                                        default:
1301
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1302
                                                {
×
1303
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1304
                                                }
×
1305
                                                break;
4,096✔
1306
                                }
1307

1308
                                if (end)
12,288✔
1309
                                {
4,096✔
1310
                                        break;
4,096✔
1311
                                }
1312

1313
                                this._reader.ReadNext();
8,192✔
1314
                        }
8,192✔
1315
                }
4,096✔
1316

1317
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1318
                {
9,600✔
1319
                        var format = template.Format;
9,600✔
1320
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1321

1322
                        this._reader.ReadNext();
9,600✔
1323

1324
                        bool end = false;
9,600✔
1325
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1326
                        {
124,800✔
1327
                                switch (this._reader.Code)
124,800✔
1328
                                {
1329
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1330
                                                break;
9,600✔
1331
                                        case 309:
1332
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1333
                                                break;
9,600✔
1334
                                        case 340:
1335
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1336
                                                break;
9,600✔
1337
                                        default:
1338
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1339
                                                {
×
1340
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1341
                                                }
×
1342
                                                break;
96,000✔
1343
                                }
1344

1345
                                if (end)
124,800✔
1346
                                {
9,600✔
1347
                                        break;
9,600✔
1348
                                }
1349

1350
                                this._reader.ReadNext();
115,200✔
1351
                        }
115,200✔
1352
                }
9,600✔
1353

1354
                private void readFormattedTableColumn(TableEntity.Column column)
1355
                {
1,216✔
1356
                        this._reader.ReadNext();
1,216✔
1357

1358
                        bool end = false;
1,216✔
1359
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1360
                        {
3,648✔
1361
                                switch (this._reader.Code)
3,648!
1362
                                {
1363
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1364
                                                break;
1,216✔
1365
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1366
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1367
                                                break;
1,216✔
1368
                                        case 309:
1369
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1370
                                                break;
1,216✔
1371
                                        default:
1372
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1373
                                                break;
×
1374
                                }
1375

1376
                                if (end)
3,648✔
1377
                                {
1,216✔
1378
                                        break;
1,216✔
1379
                                }
1380

1381
                                this._reader.ReadNext();
2,432✔
1382
                        }
2,432✔
1383
                }
1,216✔
1384

1385
                private void readStyleOverride(CadCellStyleTemplate template)
1386
                {
8,128✔
1387
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1388
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1389
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1390

1391
                        this._reader.ReadNext();
8,128✔
1392

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

1425
                                if (end)
89,536✔
1426
                                {
8,128✔
1427
                                        break;
8,128✔
1428
                                }
1429

1430
                                this._reader.ReadNext();
81,408✔
1431
                        }
81,408✔
1432
                }
8,128✔
1433

1434
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1435
                {
11,776✔
1436
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1437

1438
                        this._reader.ReadNext();
11,776✔
1439

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

1470
                                if (end)
105,984✔
1471
                                {
11,776✔
1472
                                        break;
11,776✔
1473
                                }
1474

1475
                                this._reader.ReadNext();
94,208✔
1476
                        }
94,208✔
1477
                }
11,776✔
1478

1479
                private void readCellMargin(CadCellStyleTemplate template)
1480
                {
2,816✔
1481
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1482

1483
                        this._reader.ReadNext();
2,816✔
1484

1485
                        bool end = false;
2,816✔
1486
                        int i = 0;
2,816✔
1487
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1488
                        {
22,528✔
1489
                                switch (this._reader.Code)
22,528!
1490
                                {
1491
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1492
                                                break;
2,816✔
1493
                                        case 40:
1494
                                                switch (i)
16,896✔
1495
                                                {
1496
                                                        case 0:
1497
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1498
                                                                break;
2,816✔
1499
                                                        case 1:
1500
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1501
                                                                break;
2,816✔
1502
                                                        case 2:
1503
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1504
                                                                break;
2,816✔
1505
                                                        case 3:
1506
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1507
                                                                break;
2,816✔
1508
                                                        case 4:
1509
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1510
                                                                break;
2,816✔
1511
                                                        case 5:
1512
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1513
                                                                break;
2,816✔
1514
                                                }
1515

1516
                                                i++;
16,896✔
1517
                                                break;
16,896✔
1518
                                        case 309:
1519
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1520
                                                break;
2,816✔
1521
                                        default:
1522
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1523
                                                break;
×
1524
                                }
1525

1526
                                if (end)
22,528✔
1527
                                {
2,816✔
1528
                                        break;
2,816✔
1529
                                }
1530

1531
                                this._reader.ReadNext();
19,712✔
1532
                        }
19,712✔
1533
                }
2,816✔
1534

1535
                private void readCustomData()
1536
                {
8,000✔
1537
                        this._reader.ReadNext();
8,000✔
1538

1539
                        int ndata = 0;
8,000✔
1540
                        bool end = false;
8,000✔
1541
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1542
                        {
74,304✔
1543
                                switch (this._reader.Code)
74,304✔
1544
                                {
1545
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1546
                                                break;
8,000✔
1547
                                        case 90:
1548
                                                ndata = this._reader.ValueAsInt;
8,128✔
1549
                                                break;
8,128✔
1550
                                        case 300:
1551
                                                //Name
1552
                                                break;
5,248✔
1553
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1554
                                                this.readDataMapValue();
5,248✔
1555
                                                break;
5,248✔
1556
                                        case 309:
1557
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1558
                                                break;
7,872✔
1559
                                        default:
1560
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1561
                                                break;
39,808✔
1562
                                }
1563

1564
                                if (end)
74,304✔
1565
                                {
7,872✔
1566
                                        break;
7,872✔
1567
                                }
1568

1569
                                this._reader.ReadNext();
66,432✔
1570
                        }
66,432✔
1571
                }
8,000✔
1572

1573
                private void readDataMapValue()
1574
                {
8,960✔
1575
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1576
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1577

1578
                        this._reader.ReadNext();
8,960✔
1579

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

1611
                                if (end)
330,112✔
1612
                                {
8,832✔
1613
                                        break;
8,832✔
1614
                                }
1615

1616
                                this._reader.ReadNext();
321,280✔
1617
                        }
321,280✔
1618
                }
8,960✔
1619

1620
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1621
                {
373,262✔
1622
                        switch (this._reader.Code)
373,262✔
1623
                        {
1624
                                // Undocumented codes
1625
                                case 176:
1626
                                case 177:
1627
                                case 420:
1628
                                        return true;
120,612✔
1629
                                default:
1630
                                        //Avoid noise while is not implemented
1631
                                        return true;
252,650✔
1632
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1633
                        }
1634
                }
373,262✔
1635

1636
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1637
                {
4,032✔
1638
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1639
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1640

1641
                        switch (this._reader.Code)
4,032✔
1642
                        {
1643
                                case 10:
1644
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1645
                                        return true;
384✔
1646
                                case 20:
1647
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1648
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1649
                                        return true;
384✔
1650
                                case 40:
1651
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1652
                                        {
×
1653
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1654
                                                tmp.HasFrontPlane = true;
×
1655
                                        }
×
1656

1657
                                        double[] array = new double[16]
384✔
1658
                                        {
384✔
1659
                                                0.0, 0.0, 0.0, 0.0,
384✔
1660
                                                0.0, 0.0, 0.0, 0.0,
384✔
1661
                                                0.0, 0.0, 0.0, 0.0,
384✔
1662
                                                0.0, 0.0, 0.0, 1.0
384✔
1663
                                        };
384✔
1664

1665
                                        for (int i = 0; i < 12; i++)
9,984✔
1666
                                        {
4,608✔
1667
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1668

1669
                                                if (i < 11)
4,608✔
1670
                                                {
4,224✔
1671
                                                        this._reader.ReadNext();
4,224✔
1672
                                                }
4,224✔
1673
                                        }
4,608✔
1674

1675
                                        if (tmp.InsertTransformRead)
384!
1676
                                        {
×
1677
                                                filter.InsertTransform = new Matrix4(array);
×
1678
                                                tmp.InsertTransformRead = true;
×
1679
                                        }
×
1680
                                        else
1681
                                        {
384✔
1682
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1683
                                        }
384✔
1684

1685
                                        return true;
384✔
1686
                                case 73:
1687
                                default:
1688
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1689
                        }
1690
                }
4,032✔
1691

1692
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1693
                {
3,495✔
1694
                        var tmp = template as CadMLineStyleTemplate;
3,495✔
1695
                        var mLineStyle = template.CadObject as MLineStyle;
3,495✔
1696

1697
                        switch (this._reader.Code)
3,495✔
1698
                        {
1699
                                case 6:
1700
                                        var t = tmp.ElementTemplates.LastOrDefault();
414✔
1701
                                        if (t == null)
414!
1702
                                        {
×
1703
                                                return true;
×
1704
                                        }
1705
                                        t.LineTypeName = this._reader.ValueAsString;
414✔
1706
                                        return true;
414✔
1707
                                case 49:
1708
                                        MLineStyle.Element element = new MLineStyle.Element();
414✔
1709
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
414✔
1710
                                        element.Offset = this._reader.ValueAsDouble;
414✔
1711

1712
                                        tmp.ElementTemplates.Add(elementTemplate);
414✔
1713
                                        mLineStyle.AddElement(element);
414✔
1714
                                        return true;
414✔
1715
                                default:
1716
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,667✔
1717
                        }
1718
                }
3,495✔
1719

1720
                private bool readTableStyle(CadTemplate template, DxfMap map)
1721
                {
17,657✔
1722
                        var tmp = template as CadTableStyleTemplate;
17,657✔
1723
                        var style = tmp.CadObject;
17,657✔
1724
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,657✔
1725

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

1818
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1819
                {
18,444✔
1820
                        var tmp = template as CadMLeaderStyleTemplate;
18,444✔
1821

1822
                        switch (this._reader.Code)
18,444✔
1823
                        {
1824
                                case 179:
1825
                                        return true;
208✔
1826
                                case 340:
1827
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
402✔
1828
                                        return true;
402✔
1829
                                case 342:
1830
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
402✔
1831
                                        return true;
402✔
1832
                                default:
1833
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,432✔
1834
                        }
1835
                }
18,444✔
1836

1837
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1838
                {
13,671✔
1839
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,671✔
1840

1841
                        switch (this._reader.Code)
13,671✔
1842
                        {
1843
                                case 1:
1844
                                        this._reader.ExpectedCode(70);
1,154✔
1845
                                        this._reader.ExpectedCode(140);
1,154✔
1846
                                        return true;
1,154✔
1847
                                default:
1848
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
12,517✔
1849
                        }
1850
                }
13,671✔
1851

1852
                private bool readBlockElement(CadTemplate template, DxfMap map)
1853
                {
5,211✔
1854
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,211✔
1855

1856
                        switch (this._reader.Code)
5,211✔
1857
                        {
1858
                                default:
1859
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,211✔
1860
                                        {
4,439✔
1861
                                                return this.readEvaluationExpression(template, map);
4,439✔
1862
                                        }
1863
                                        return true;
772✔
1864
                        }
1865
                }
5,211✔
1866

1867
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1868
                {
3,281✔
1869
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,281✔
1870

1871
                        switch (this._reader.Code)
3,281✔
1872
                        {
1873
                                default:
1874
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,281✔
1875
                                        {
2,702✔
1876
                                                return this.readBlockElement(template, map);
2,702✔
1877
                                        }
1878
                                        return true;
579✔
1879
                        }
1880
                }
3,281✔
1881

1882
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1883
                {
4,246✔
1884
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1885

1886
                        switch (this._reader.Code)
4,246✔
1887
                        {
1888
                                default:
1889
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
1890
                                        {
3,281✔
1891
                                                return this.readBlockParameter(template, map);
3,281✔
1892
                                        }
1893
                                        return true;
965✔
1894
                        }
1895
                }
4,246✔
1896

1897
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
1898
                {
5,404✔
1899
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
1900

1901
                        switch (this._reader.Code)
5,404✔
1902
                        {
1903
                                case 92:
1904
                                        var stateCount = this._reader.ValueAsInt;
193✔
1905
                                        for (int i = 0; i < stateCount; i++)
1,930✔
1906
                                        {
772✔
1907
                                                this._reader.ReadNext();
772✔
1908
                                                tmp.StateTemplates.Add(this.readState());
772✔
1909
                                        }
772✔
1910
                                        return true;
193✔
1911
                                case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
386✔
1912
                                        var entityCount = this._reader.ValueAsInt;
193✔
1913
                                        for (int i = 0; i < entityCount; i++)
780✔
1914
                                        {
197✔
1915
                                                this._reader.ReadNext();
197✔
1916
                                                tmp.EntityHandles.Add(this._reader.ValueAsHandle);
197✔
1917
                                        }
197✔
1918
                                        return true;
193✔
1919
                                default:
1920
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,018✔
1921
                                        {
4,246✔
1922
                                                return this.readBlock1PtParameter(template, map);
4,246✔
1923
                                        }
1924
                                        return true;
772✔
1925
                        }
1926
                }
5,404✔
1927

1928
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
1929
                {
772✔
1930
                        var state = new BlockVisibilityParameter.State();
772✔
1931
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
1932

1933
                        List<int> expectedCodes = new List<int>();
772✔
1934
                        expectedCodes.Add(303);
772✔
1935
                        expectedCodes.Add(94);
772✔
1936
                        expectedCodes.Add(95);
772✔
1937

1938
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
1939
                        {
2,316✔
1940
                                expectedCodes.Remove(this._reader.Code);
2,316✔
1941

1942
                                switch (this._reader.Code)
2,316!
1943
                                {
1944
                                        case 303:
1945
                                                state.Name = this._reader.ValueAsString;
772✔
1946
                                                break;
772✔
1947
                                        case 94:
1948
                                                var count = this._reader.ValueAsInt;
772✔
1949
                                                for (int i = 0; i < count; i++)
2,720✔
1950
                                                {
588✔
1951
                                                        this._reader.ReadNext();
588✔
1952
                                                        template.EntityHandles.Add(this._reader.ValueAsHandle);
588✔
1953
                                                }
588✔
1954
                                                break;
772✔
1955
                                        case 95:
1956
                                                count = this._reader.ValueAsInt;
772✔
1957
                                                for (int i = 0; i < count; i++)
6,152✔
1958
                                                {
2,304✔
1959
                                                        this._reader.ReadNext();
2,304✔
1960
                                                        template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
1961
                                                }
2,304✔
1962
                                                break;
772✔
1963
                                        default:
NEW
1964
                                                return template;
×
1965
                                }
1966

1967
                                if (!expectedCodes.Any())
2,316✔
1968
                                {
772✔
1969
                                        break;
772✔
1970
                                }
1971

1972
                                this._reader.ReadNext();
1,544✔
1973
                        }
1,544✔
1974

1975
                        return template;
772✔
1976
                }
772✔
1977

1978
                private bool readBlockGrip(CadTemplate template, DxfMap map)
1979
                {
3,860✔
1980
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,860✔
1981

1982
                        switch (this._reader.Code)
3,860✔
1983
                        {
1984
                                default:
1985
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,860✔
1986
                                        {
2,509✔
1987
                                                return this.readBlockElement(template, map);
2,509✔
1988
                                        }
1989
                                        return true;
1,351✔
1990
                        }
1991
                }
3,860✔
1992

1993
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
1994
                {
3,860✔
1995
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
1996

1997
                        switch (this._reader.Code)
3,860✔
1998
                        {
1999
                                default:
2000
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
2001
                                        {
3,860✔
2002
                                                return this.readBlockGrip(template, map);
3,860✔
2003
                                        }
NEW
2004
                                        return true;
×
2005
                        }
2006
                }
3,860✔
2007

2008
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2009
                {
11,540✔
2010
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,540✔
2011

2012
                        switch (this._reader.Code)
11,540✔
2013
                        {
2014
                                default:
2015
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,540✔
2016
                                        {
9,232✔
2017
                                                return this.readEvaluationExpression(template, map);
9,232✔
2018
                                        }
2019
                                        return true;
2,308✔
2020
                        }
2021
                }
11,540✔
2022

2023
                private bool readXRecord(CadTemplate template, DxfMap map)
2024
                {
113,152✔
2025
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,152✔
2026

2027
                        switch (this._reader.Code)
113,152✔
2028
                        {
2029
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,896✔
2030
                                        this.readXRecordEntries(tmp);
28,896✔
2031
                                        return true;
28,896✔
2032
                                default:
2033
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,256✔
2034
                        }
2035
                }
113,152✔
2036

2037
                private void readXRecordEntries(CadXRecordTemplate template)
2038
                {
28,896✔
2039
                        this._reader.ReadNext();
28,896✔
2040

2041
                        while (this._reader.DxfCode != DxfCode.Start)
2,408,845✔
2042
                        {
2,379,949✔
2043
                                switch (this._reader.GroupCodeValue)
2,379,949✔
2044
                                {
2045
                                        case GroupCodeValueType.Point3D:
2046
                                                var code = this._reader.Code;
2,884✔
2047
                                                var x = this._reader.ValueAsDouble;
2,884✔
2048
                                                this._reader.ReadNext();
2,884✔
2049
                                                var y = this._reader.ValueAsDouble;
2,884✔
2050
                                                this._reader.ReadNext();
2,884✔
2051
                                                var z = this._reader.ValueAsDouble;
2,884✔
2052
                                                XYZ pt = new XYZ(x, y, z);
2,884✔
2053
                                                template.CadObject.CreateEntry(code, pt);
2,884✔
2054
                                                break;
2,884✔
2055
                                        case GroupCodeValueType.Handle:
2056
                                        case GroupCodeValueType.ObjectId:
2057
                                        case GroupCodeValueType.ExtendedDataHandle:
2058
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,039✔
2059
                                                break;
12,039✔
2060
                                        default:
2061
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,026✔
2062
                                                break;
2,365,026✔
2063
                                }
2064

2065
                                this._reader.ReadNext();
2,379,949✔
2066
                        }
2,379,949✔
2067
                }
28,896✔
2068

2069
                private bool readBookColor(CadTemplate template, DxfMap map)
2070
                {
1,376✔
2071
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2072
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2073

2074
                        switch (this._reader.Code)
1,376✔
2075
                        {
2076
                                case 430:
2077
                                        color.Name = this._reader.ValueAsString;
160✔
2078
                                        return true;
160✔
2079
                                default:
2080
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2081
                        }
2082
                }
1,376✔
2083

2084
                private bool readDictionary(CadTemplate template, DxfMap map)
2085
                {
223,326✔
2086
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
223,326✔
2087
                        CadDictionary cadDictionary = tmp.CadObject;
223,326✔
2088

2089
                        switch (this._reader.Code)
223,326✔
2090
                        {
2091
                                case 280:
2092
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,026✔
2093
                                        return true;
15,026✔
2094
                                case 281:
2095
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,447✔
2096
                                        return true;
21,447✔
2097
                                case 3:
2098
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,127✔
2099
                                        return true;
57,127✔
2100
                                case 350: // Soft-owner ID/handle to entry object 
2101
                                case 360: // Hard-owner ID/handle to entry object
2102
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,127✔
2103
                                        return true;
57,127✔
2104
                                default:
2105
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,599✔
2106
                        }
2107
                }
223,326✔
2108

2109
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2110
                {
1,755✔
2111
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,755✔
2112

2113
                        switch (this._reader.Code)
1,755✔
2114
                        {
2115
                                case 340:
2116
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
195✔
2117
                                        return true;
195✔
2118
                                default:
2119
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,560!
2120
                                        {
1,560✔
2121
                                                return this.readDictionary(template, map);
1,560✔
2122
                                        }
2123
                                        return true;
×
2124
                        }
2125
                }
1,755✔
2126

2127
                private CadTemplate readSortentsTable()
2128
                {
576✔
2129
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2130
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2131

2132
                        //Jump the 0 marker
2133
                        this._reader.ReadNext();
576✔
2134

2135
                        this.readCommonObjectData(template);
576✔
2136

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

2139
                        //Jump the 100 marker
2140
                        this._reader.ReadNext();
576✔
2141

2142
                        (ulong?, ulong?) pair = (null, null);
576✔
2143

2144
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2145
                        {
3,648✔
2146
                                switch (this._reader.Code)
3,648!
2147
                                {
2148
                                        case 5:
2149
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2150
                                                break;
1,536✔
2151
                                        case 330:
2152
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2153
                                                break;
576✔
2154
                                        case 331:
2155
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2156
                                                break;
1,536✔
2157
                                        default:
2158
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2159
                                                break;
×
2160
                                }
2161

2162
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2163
                                {
1,536✔
2164
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2165
                                        pair = (null, null);
1,536✔
2166
                                }
1,536✔
2167

2168
                                this._reader.ReadNext();
3,648✔
2169
                        }
3,648✔
2170

2171
                        return template;
576✔
2172
                }
576✔
2173
        }
2174
}
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