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

DomCR / ACadSharp / 21010648765

14 Jan 2026 09:33PM UTC coverage: 77.031% (+0.09%) from 76.943%
21010648765

push

github

web-flow
Merge pull request #949 from DomCR/issue-948_dynamic-blocks-refactor

issue-948 dynamic properties

8019 of 11259 branches covered (71.22%)

Branch coverage included in aggregate %.

301 of 324 new or added lines in 21 files covered. (92.9%)

19 existing lines in 6 files now uncovered.

29076 of 36897 relevant lines covered (78.8%)

149030.45 hits per line

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

86.22
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.Classes;
2
using ACadSharp.Entities;
3
using ACadSharp.IO.Templates;
4
using ACadSharp.Objects;
5
using ACadSharp.Objects.Evaluations;
6
using CSMath;
7
using System;
8
using System.Collections.Generic;
9
using System.Diagnostics;
10
using System.IO;
11
using System.Linq;
12
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
13
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
14

15
namespace ACadSharp.IO.DXF
16
{
17
        internal class DxfObjectsSectionReader : DxfSectionReaderBase
18
        {
19
                public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
20

21
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
22
                        : base(reader, builder)
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.ObjectBlockRepresentationData:
114
                                        return this.readObjectCodes<BlockRepresentationData>(new CadBlockRepresentationDataTemplate(), this.readBlockRepresentationData);
260✔
115
                                case DxfFileToken.ObjectBlockGripLocationComponent:
116
                                        return this.readObjectCodes<BlockGripExpression>(new CadBlockGripExpressionTemplate(), this.readBlockGripExpression);
1,154✔
117
                                case DxfFileToken.ObjectBlockVisibilityGrip:
118
                                        return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockVisibilityGripTemplate(), this.readBlockVisibilityGrip);
193✔
119
                                case DxfFileToken.ObjectBlockVisibilityParameter:
120
                                        return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
193✔
121
                                default:
122
                                        DxfMap map = DxfMap.Create<CadObject>();
4,044✔
123
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
4,044✔
124
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
4,044!
125
                                        {
4,044✔
126
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
4,044✔
127
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
4,044✔
128
                                        }
4,044✔
129
                                        else
130
                                        {
×
131
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
132
                                        }
×
133

134
                                        this._reader.ReadNext();
4,044✔
135

136
                                        do
137
                                        {
251,926✔
138
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
251,926!
139
                                                {
30,576✔
140
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
30,576✔
141
                                                        if (isExtendedData)
30,576✔
142
                                                                continue;
24✔
143
                                                }
30,552✔
144

145
                                                this._reader.ReadNext();
251,902✔
146
                                        }
251,902✔
147
                                        while (this._reader.DxfCode != DxfCode.Start);
251,926✔
148

149
                                        return unknownEntityTemplate;
4,044✔
150
                        }
151
                }
77,106✔
152

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

158
                        DxfMap map = DxfMap.Create<T>();
72,486✔
159

160
                        while (this._reader.DxfCode != DxfCode.Start)
1,033,886✔
161
                        {
961,400✔
162
                                if (!readObject(template, map))
961,400✔
163
                                {
232,264✔
164
                                        this.readCommonCodes(template, out bool isExtendedData, map);
232,264✔
165
                                        if (isExtendedData)
232,264✔
166
                                                continue;
2,982✔
167
                                }
229,282✔
168

169
                                if (this.lockPointer)
958,418✔
170
                                {
1,794✔
171
                                        this.lockPointer = false;
1,794✔
172
                                        continue;
1,794✔
173
                                }
174

175
                                if (this._reader.DxfCode != DxfCode.Start)
956,624✔
176
                                {
927,728✔
177
                                        this._reader.ReadNext();
927,728✔
178
                                }
927,728✔
179
                        }
956,624✔
180

181
                        return template;
72,486✔
182
                }
72,486✔
183

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

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

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

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

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

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

262
                                                node.Index = this._reader.ValueAsInt;
2,564✔
263

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

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

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

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

282
                                                this._reader.ReadNext();
2,564✔
283

284
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,564✔
285
                                        }
2,564✔
286

287
                                        this.lockPointer = true;
449✔
288
                                        return true;
449✔
289
                                case 92:
290
                                        //Edges
291
                                        while (this._reader.Code == 92)
2,116✔
292
                                        {
1,923✔
293
                                                this._reader.ExpectedCode(93);
1,923✔
294
                                                this._reader.ExpectedCode(94);
1,923✔
295
                                                this._reader.ExpectedCode(91);
1,923✔
296
                                                this._reader.ExpectedCode(91);
1,923✔
297
                                                this._reader.ExpectedCode(92);
1,923✔
298
                                                this._reader.ExpectedCode(92);
1,923✔
299
                                                this._reader.ExpectedCode(92);
1,923✔
300
                                                this._reader.ExpectedCode(92);
1,923✔
301
                                                this._reader.ExpectedCode(92);
1,923✔
302

303
                                                this._reader.ReadNext();
1,923✔
304
                                        }
1,923✔
305

306
                                        this.lockPointer = true;
193✔
307
                                        return true;
193✔
308
                                default:
309
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,438✔
310
                        }
311
                }
3,080✔
312

313
                private bool readLayout(CadTemplate template, DxfMap map)
314
                {
51,597✔
315
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,597✔
316

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

334
                private bool readGroup(CadTemplate template, DxfMap map)
335
                {
4,992✔
336
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
337

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

350
                private bool readGeoData(CadTemplate template, DxfMap map)
351
                {
102✔
352
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
353

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

394
                                                this._reader.ReadNext();
24✔
395
                                                double destX = this._reader.ValueAsDouble;
24✔
396
                                                this._reader.ReadNext();
24✔
397
                                                double destY = this._reader.ValueAsDouble;
24✔
398

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

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

458
                private bool readMaterial(CadTemplate template, DxfMap map)
459
                {
42,062✔
460
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,062✔
461
                        List<double> arr = null;
42,062✔
462

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

471
                                                arr.Add(this._reader.ValueAsDouble);
21,552✔
472

473
                                                this._reader.ReadNext();
21,552✔
474
                                        }
21,552✔
475

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

484
                                                arr.Add(this._reader.ValueAsDouble);
×
485

486
                                                this._reader.ReadNext();
×
487
                                        }
×
488

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

497
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
498

499
                                                this._reader.ReadNext();
3,120✔
500
                                        }
3,120✔
501

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

510
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
511

512
                                                this._reader.ReadNext();
3,120✔
513
                                        }
3,120✔
514

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

523
                                                arr.Add(this._reader.ValueAsDouble);
18,480✔
524

525
                                                this._reader.ReadNext();
18,480✔
526
                                        }
18,480✔
527

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

536
                                                arr.Add(this._reader.ValueAsDouble);
×
537

538
                                                this._reader.ReadNext();
×
539
                                        }
×
540

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

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

561
                private void readLinkedData(CadTemplate template, DxfMap map)
562
                {
320✔
563
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
564
                        LinkedData linkedData = tmp.CadObject;
320✔
565

566
                        this._reader.ReadNext();
320✔
567

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

580
                                this._reader.ReadNext();
640✔
581
                        }
640✔
582
                }
320✔
583

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

609
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
610
                {
256✔
611
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
612
                        TableContent tableContent = tmp.CadObject;
256✔
613

614
                        this._reader.ReadNext();
256✔
615

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

631
                                this._reader.ReadNext();
256✔
632
                        }
256✔
633
                }
256✔
634

635
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
636
                {
256✔
637
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
638
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
639

640
                        this._reader.ReadNext();
256✔
641

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

693
                                this._reader.ReadNext();
2,048✔
694
                        }
2,048✔
695
                }
256✔
696

697
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
698
                {
320✔
699
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
700
                        TableContent tableContent = tmp.CadObject;
320✔
701

702
                        this._reader.ReadNext();
320✔
703

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

733
                                this._reader.ReadNext();
3,904✔
734
                        }
3,904✔
735
                }
320✔
736

737

738
                private TableEntity.Column readTableColumn()
739
                {
1,216✔
740
                        this._reader.ReadNext();
1,216✔
741

742
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
743

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

764
                                if (end)
3,648✔
765
                                {
1,216✔
766
                                        return column;
1,216✔
767
                                }
768

769
                                this._reader.ReadNext();
2,432✔
770
                        }
2,432✔
771

772
                        return column;
×
773
                }
1,216✔
774

775
                private TableEntity.Row readTableRow()
776
                {
1,472✔
777
                        this._reader.ReadNext();
1,472✔
778

779
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
780

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

801
                                if (end)
11,840✔
802
                                {
1,408✔
803
                                        return row;
1,408✔
804
                                }
805

806
                                this._reader.ReadNext();
10,432✔
807
                        }
10,432✔
808

809
                        return row;
64✔
810
                }
1,472✔
811

812
                private void readTableRow(TableEntity.Row row)
813
                {
1,408✔
814
                        this._reader.ReadNext();
1,408✔
815

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

835
                                if (end)
4,224✔
836
                                {
1,408✔
837
                                        break;
1,408✔
838
                                }
839

840
                                this._reader.ReadNext();
2,816✔
841
                        }
2,816✔
842
                }
1,408✔
843

844
                private void readFormattedTableRow(TableEntity.Row row)
845
                {
1,408✔
846
                        this._reader.ReadNext();
1,408✔
847

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

866
                                if (end)
4,224✔
867
                                {
1,408✔
868
                                        break;
1,408✔
869
                                }
870

871
                                this._reader.ReadNext();
2,816✔
872
                        }
2,816✔
873
                }
1,408✔
874

875
                private void readTableColumn(TableEntity.Column column)
876
                {
1,216✔
877
                        this._reader.ReadNext();
1,216✔
878

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

903
                                if (end)
3,648✔
904
                                {
1,216✔
905
                                        break;
1,216✔
906
                                }
907

908
                                this._reader.ReadNext();
2,432✔
909
                        }
2,432✔
910
                }
1,216✔
911

912
                private void readLinkedTableColumn(TableEntity.Column column)
913
                {
1,216✔
914
                        this._reader.ReadNext();
1,216✔
915

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

943
                                if (end)
4,864✔
944
                                {
1,216✔
945
                                        break;
1,216✔
946
                                }
947

948
                                this._reader.ReadNext();
3,648✔
949
                        }
3,648✔
950
                }
1,216✔
951

952
                private void readLinkedTableRow(TableEntity.Row row)
953
                {
1,536✔
954
                        this._reader.ReadNext();
1,536✔
955

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

982
                                if (end)
12,480✔
983
                                {
1,408✔
984
                                        break;
1,408✔
985
                                }
986

987
                                this._reader.ReadNext();
11,072✔
988
                        }
11,072✔
989
                }
1,536✔
990

991
                private TableEntity.Cell readCell()
992
                {
5,376✔
993
                        this._reader.ReadNext();
5,376✔
994

995
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
996
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
997

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

1018
                                if (end)
16,832✔
1019
                                {
5,248✔
1020
                                        return cell;
5,248✔
1021
                                }
1022

1023
                                this._reader.ReadNext();
11,584✔
1024
                        }
11,584✔
1025

1026
                        return cell;
128✔
1027
                }
5,376✔
1028

1029
                private void readTableCell(TableEntity.Cell cell)
1030
                {
5,248✔
1031
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1032

1033
                        this._reader.ReadNext();
5,248✔
1034

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

1058
                                if (end)
16,384✔
1059
                                {
5,248✔
1060
                                        break;
5,248✔
1061
                                }
1062

1063
                                this._reader.ReadNext();
11,136✔
1064
                        }
11,136✔
1065
                }
5,248✔
1066

1067
                private void readFormattedTableCell(TableEntity.Cell cell)
1068
                {
5,248✔
1069
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1070

1071
                        this._reader.ReadNext();
5,248✔
1072

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

1092
                                if (end)
5,248!
1093
                                {
5,248✔
1094
                                        break;
5,248✔
1095
                                }
1096

1097
                                this._reader.ReadNext();
×
1098
                        }
×
1099
                }
5,248✔
1100

1101
                private void readCellTableFormat(TableEntity.Cell cell)
1102
                {
5,248✔
1103
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1104

1105
                        this._reader.ReadNext();
5,248✔
1106

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

1126
                                if (end)
5,248!
1127
                                {
×
1128
                                        break;
×
1129
                                }
1130

1131
                                this._reader.ReadNext();
5,248✔
1132
                        }
5,248✔
1133
                }
5,248✔
1134

1135
                private void readCellStyle(CadCellStyleTemplate template)
1136
                {
×
1137
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1138

1139
                        this._reader.ReadNext();
×
1140

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

1157
                                if (end)
×
1158
                                {
×
1159
                                        break;
×
1160
                                }
1161

1162
                                this._reader.ReadNext();
×
1163
                        }
×
1164
                }
×
1165

1166
                private void readLinkedTableCell(TableEntity.Cell cell)
1167
                {
5,376✔
1168
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1169

1170
                        this._reader.ReadNext();
5,376✔
1171

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

1197
                                if (end)
53,760✔
1198
                                {
5,248✔
1199
                                        break;
5,248✔
1200
                                }
1201

1202
                                this._reader.ReadNext();
48,512✔
1203
                        }
48,512✔
1204
                }
5,376✔
1205

1206
                private CadTableCellContentTemplate readLinkedTableCellContent()
1207
                {
4,096✔
1208
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1209
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1210
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1211

1212
                        this._reader.ReadNext();
4,096✔
1213

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

1234
                                if (end)
8,192✔
1235
                                {
4,096✔
1236
                                        break;
4,096✔
1237
                                }
1238

1239
                                this._reader.ReadNext();
4,096✔
1240
                        }
4,096✔
1241

1242
                        return template;
4,096✔
1243
                }
4,096✔
1244

1245
                private void readCellContent(CadTableCellContentTemplate template)
1246
                {
4,096✔
1247
                        TableEntity.CellContent content = template.Content;
4,096✔
1248
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1249

1250
                        this._reader.ReadNext();
4,096✔
1251

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

1276
                                if (end)
16,384✔
1277
                                {
4,096✔
1278
                                        break;
4,096✔
1279
                                }
1280

1281
                                this._reader.ReadNext();
12,288✔
1282
                        }
12,288✔
1283
                }
4,096✔
1284

1285
                private void readFormattedCellContent()
1286
                {
4,096✔
1287
                        TableEntity.ContentFormat format = new();
4,096✔
1288
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1289
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1290

1291
                        this._reader.ReadNext();
4,096✔
1292

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

1312
                                if (end)
12,288✔
1313
                                {
4,096✔
1314
                                        break;
4,096✔
1315
                                }
1316

1317
                                this._reader.ReadNext();
8,192✔
1318
                        }
8,192✔
1319
                }
4,096✔
1320

1321
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1322
                {
9,600✔
1323
                        var format = template.Format;
9,600✔
1324
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1325

1326
                        this._reader.ReadNext();
9,600✔
1327

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

1349
                                if (end)
124,800✔
1350
                                {
9,600✔
1351
                                        break;
9,600✔
1352
                                }
1353

1354
                                this._reader.ReadNext();
115,200✔
1355
                        }
115,200✔
1356
                }
9,600✔
1357

1358
                private void readFormattedTableColumn(TableEntity.Column column)
1359
                {
1,216✔
1360
                        this._reader.ReadNext();
1,216✔
1361

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

1380
                                if (end)
3,648✔
1381
                                {
1,216✔
1382
                                        break;
1,216✔
1383
                                }
1384

1385
                                this._reader.ReadNext();
2,432✔
1386
                        }
2,432✔
1387
                }
1,216✔
1388

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

1395
                        this._reader.ReadNext();
8,128✔
1396

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

1429
                                if (end)
89,536✔
1430
                                {
8,128✔
1431
                                        break;
8,128✔
1432
                                }
1433

1434
                                this._reader.ReadNext();
81,408✔
1435
                        }
81,408✔
1436
                }
8,128✔
1437

1438
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1439
                {
11,776✔
1440
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1441

1442
                        this._reader.ReadNext();
11,776✔
1443

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

1474
                                if (end)
105,984✔
1475
                                {
11,776✔
1476
                                        break;
11,776✔
1477
                                }
1478

1479
                                this._reader.ReadNext();
94,208✔
1480
                        }
94,208✔
1481
                }
11,776✔
1482

1483
                private void readCellMargin(CadCellStyleTemplate template)
1484
                {
2,816✔
1485
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1486

1487
                        this._reader.ReadNext();
2,816✔
1488

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

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

1530
                                if (end)
22,528✔
1531
                                {
2,816✔
1532
                                        break;
2,816✔
1533
                                }
1534

1535
                                this._reader.ReadNext();
19,712✔
1536
                        }
19,712✔
1537
                }
2,816✔
1538

1539
                private void readCustomData()
1540
                {
8,000✔
1541
                        this._reader.ReadNext();
8,000✔
1542

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

1568
                                if (end)
74,304✔
1569
                                {
7,872✔
1570
                                        break;
7,872✔
1571
                                }
1572

1573
                                this._reader.ReadNext();
66,432✔
1574
                        }
66,432✔
1575
                }
8,000✔
1576

1577
                private void readDataMapValue()
1578
                {
8,960✔
1579
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1580
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1581

1582
                        this._reader.ReadNext();
8,960✔
1583

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

1615
                                if (end)
330,112✔
1616
                                {
8,832✔
1617
                                        break;
8,832✔
1618
                                }
1619

1620
                                this._reader.ReadNext();
321,280✔
1621
                        }
321,280✔
1622
                }
8,960✔
1623

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

1640
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1641
                {
4,032✔
1642
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1643
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1644

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

1661
                                        double[] array = new double[16]
384✔
1662
                                        {
384✔
1663
                                                0.0, 0.0, 0.0, 0.0,
384✔
1664
                                                0.0, 0.0, 0.0, 0.0,
384✔
1665
                                                0.0, 0.0, 0.0, 0.0,
384✔
1666
                                                0.0, 0.0, 0.0, 1.0
384✔
1667
                                        };
384✔
1668

1669
                                        for (int i = 0; i < 12; i++)
9,984✔
1670
                                        {
4,608✔
1671
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1672

1673
                                                if (i < 11)
4,608✔
1674
                                                {
4,224✔
1675
                                                        this._reader.ReadNext();
4,224✔
1676
                                                }
4,224✔
1677
                                        }
4,608✔
1678

1679
                                        if (tmp.InsertTransformRead)
384!
1680
                                        {
×
1681
                                                filter.InsertTransform = new Matrix4(array);
×
1682
                                                tmp.InsertTransformRead = true;
×
1683
                                        }
×
1684
                                        else
1685
                                        {
384✔
1686
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1687
                                        }
384✔
1688

1689
                                        return true;
384✔
1690
                                case 73:
1691
                                default:
1692
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1693
                        }
1694
                }
4,032✔
1695

1696
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1697
                {
3,495✔
1698
                        var tmp = template as CadMLineStyleTemplate;
3,495✔
1699
                        var mLineStyle = template.CadObject as MLineStyle;
3,495✔
1700

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

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

1724
                private bool readTableStyle(CadTemplate template, DxfMap map)
1725
                {
17,657✔
1726
                        var tmp = template as CadTableStyleTemplate;
17,657✔
1727
                        var style = tmp.CadObject;
17,657✔
1728
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,657✔
1729

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

1822
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1823
                {
18,444✔
1824
                        var tmp = template as CadMLeaderStyleTemplate;
18,444✔
1825

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

1841
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1842
                {
13,671✔
1843
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
13,671✔
1844

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

1856
                private bool readBlockElement(CadTemplate template, DxfMap map)
1857
                {
5,211✔
1858
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,211✔
1859

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

1871
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1872
                {
3,281✔
1873
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,281✔
1874

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

1886
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1887
                {
4,246✔
1888
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1889

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

1901
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
1902
                {
5,404✔
1903
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
1904

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

1932
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
1933
                {
772✔
1934
                        var state = new BlockVisibilityParameter.State();
772✔
1935
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
1936

1937
                        List<int> expectedCodes = new List<int>();
772✔
1938
                        expectedCodes.Add(303);
772✔
1939
                        expectedCodes.Add(94);
772✔
1940
                        expectedCodes.Add(95);
772✔
1941

1942
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
1943
                        {
2,316✔
1944
                                expectedCodes.Remove(this._reader.Code);
2,316✔
1945

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

1971
                                if (!expectedCodes.Any())
2,316✔
1972
                                {
772✔
1973
                                        break;
772✔
1974
                                }
1975

1976
                                this._reader.ReadNext();
1,544✔
1977
                        }
1,544✔
1978

1979
                        return template;
772✔
1980
                }
772✔
1981

1982
                private bool readBlockGrip(CadTemplate template, DxfMap map)
1983
                {
3,860✔
1984
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,860✔
1985

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

1997
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
1998
                {
3,860✔
1999
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
2000

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

2012
                private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2013
                {
1,560✔
2014
                        CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,560✔
2015

2016
                        switch (this._reader.Code)
1,560✔
2017
                        {
2018
                                case 340:
2019
                                        tmp.BlockHandle = this._reader.ValueAsHandle;
260✔
2020
                                        return true;
260✔
2021
                                default:
2022
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,300✔
2023
                        }
2024
                }
1,560✔
2025

2026
                private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2027
                {
11,540✔
2028
                        CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
11,540✔
2029

2030
                        switch (this._reader.Code)
11,540✔
2031
                        {
2032
                                default:
2033
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
11,540✔
2034
                                        {
9,232✔
2035
                                                return this.readEvaluationExpression(template, map);
9,232✔
2036
                                        }
2037
                                        return true;
2,308✔
2038
                        }
2039
                }
11,540✔
2040

2041
                private bool readXRecord(CadTemplate template, DxfMap map)
2042
                {
113,152✔
2043
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,152✔
2044

2045
                        switch (this._reader.Code)
113,152✔
2046
                        {
2047
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,896✔
2048
                                        this.readXRecordEntries(tmp);
28,896✔
2049
                                        return true;
28,896✔
2050
                                default:
2051
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,256✔
2052
                        }
2053
                }
113,152✔
2054

2055
                private void readXRecordEntries(CadXRecordTemplate template)
2056
                {
28,896✔
2057
                        this._reader.ReadNext();
28,896✔
2058

2059
                        while (this._reader.DxfCode != DxfCode.Start)
2,408,845✔
2060
                        {
2,379,949✔
2061
                                switch (this._reader.GroupCodeValue)
2,379,949✔
2062
                                {
2063
                                        case GroupCodeValueType.Point3D:
2064
                                                var code = this._reader.Code;
2,884✔
2065
                                                var x = this._reader.ValueAsDouble;
2,884✔
2066
                                                this._reader.ReadNext();
2,884✔
2067
                                                var y = this._reader.ValueAsDouble;
2,884✔
2068
                                                this._reader.ReadNext();
2,884✔
2069
                                                var z = this._reader.ValueAsDouble;
2,884✔
2070
                                                XYZ pt = new XYZ(x, y, z);
2,884✔
2071
                                                template.CadObject.CreateEntry(code, pt);
2,884✔
2072
                                                break;
2,884✔
2073
                                        case GroupCodeValueType.Handle:
2074
                                        case GroupCodeValueType.ObjectId:
2075
                                        case GroupCodeValueType.ExtendedDataHandle:
2076
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,039✔
2077
                                                break;
12,039✔
2078
                                        default:
2079
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,026✔
2080
                                                break;
2,365,026✔
2081
                                }
2082

2083
                                this._reader.ReadNext();
2,379,949✔
2084
                        }
2,379,949✔
2085
                }
28,896✔
2086

2087
                private bool readBookColor(CadTemplate template, DxfMap map)
2088
                {
1,376✔
2089
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2090
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2091

2092
                        switch (this._reader.Code)
1,376✔
2093
                        {
2094
                                case 430:
2095
                                        color.Name = this._reader.ValueAsString;
160✔
2096
                                        return true;
160✔
2097
                                default:
2098
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2099
                        }
2100
                }
1,376✔
2101

2102
                private bool readDictionary(CadTemplate template, DxfMap map)
2103
                {
223,326✔
2104
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
223,326✔
2105
                        CadDictionary cadDictionary = tmp.CadObject;
223,326✔
2106

2107
                        switch (this._reader.Code)
223,326✔
2108
                        {
2109
                                case 280:
2110
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,026✔
2111
                                        return true;
15,026✔
2112
                                case 281:
2113
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,447✔
2114
                                        return true;
21,447✔
2115
                                case 3:
2116
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,127✔
2117
                                        return true;
57,127✔
2118
                                case 350: // Soft-owner ID/handle to entry object 
2119
                                case 360: // Hard-owner ID/handle to entry object
2120
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,127✔
2121
                                        return true;
57,127✔
2122
                                default:
2123
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,599✔
2124
                        }
2125
                }
223,326✔
2126

2127
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2128
                {
1,755✔
2129
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,755✔
2130

2131
                        switch (this._reader.Code)
1,755✔
2132
                        {
2133
                                case 340:
2134
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
195✔
2135
                                        return true;
195✔
2136
                                default:
2137
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,560!
2138
                                        {
1,560✔
2139
                                                return this.readDictionary(template, map);
1,560✔
2140
                                        }
2141
                                        return true;
×
2142
                        }
2143
                }
1,755✔
2144

2145
                private CadTemplate readSortentsTable()
2146
                {
576✔
2147
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2148
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2149

2150
                        //Jump the 0 marker
2151
                        this._reader.ReadNext();
576✔
2152

2153
                        this.readCommonObjectData(template);
576✔
2154

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

2157
                        //Jump the 100 marker
2158
                        this._reader.ReadNext();
576✔
2159

2160
                        (ulong?, ulong?) pair = (null, null);
576✔
2161

2162
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2163
                        {
3,648✔
2164
                                switch (this._reader.Code)
3,648!
2165
                                {
2166
                                        case 5:
2167
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2168
                                                break;
1,536✔
2169
                                        case 330:
2170
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2171
                                                break;
576✔
2172
                                        case 331:
2173
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2174
                                                break;
1,536✔
2175
                                        default:
2176
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2177
                                                break;
×
2178
                                }
2179

2180
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2181
                                {
1,536✔
2182
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2183
                                        pair = (null, null);
1,536✔
2184
                                }
1,536✔
2185

2186
                                this._reader.ReadNext();
3,648✔
2187
                        }
3,648✔
2188

2189
                        return template;
576✔
2190
                }
576✔
2191
        }
2192
}
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