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

DomCR / ACadSharp / 20973069846

13 Jan 2026 09:22PM UTC coverage: 76.984% (+0.09%) from 76.896%
20973069846

Pull #949

github

web-flow
Merge 2db6bacee into 024480147
Pull Request #949: issue-948 dynamic properties

7976 of 11219 branches covered (71.09%)

Branch coverage included in aggregate %.

161 of 178 new or added lines in 14 files covered. (90.45%)

16 existing lines in 5 files now uncovered.

29007 of 36821 relevant lines covered (78.78%)

148757.07 hits per line

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

85.89
/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.ObjectBlockVisibilityGrip:
114
                                        return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockVisibilityGripTemplate(), this.readBlockVisibilityGrip);
193✔
115
                                case DxfFileToken.ObjectBlockVisibilityParameter:
116
                                        return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
193✔
117
                                default:
118
                                        DxfMap map = DxfMap.Create<CadObject>();
5,458✔
119
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
5,458✔
120
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
5,458!
121
                                        {
5,458✔
122
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
5,458✔
123
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
5,458✔
124
                                        }
5,458✔
125
                                        else
126
                                        {
×
127
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
128
                                        }
×
129

130
                                        this._reader.ReadNext();
5,458✔
131

132
                                        do
133
                                        {
267,790✔
134
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
267,790!
135
                                                {
32,496✔
136
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
32,496✔
137
                                                        if (isExtendedData)
32,496✔
138
                                                                continue;
24✔
139
                                                }
32,472✔
140

141
                                                this._reader.ReadNext();
267,766✔
142
                                        }
267,766✔
143
                                        while (this._reader.DxfCode != DxfCode.Start);
267,790✔
144

145
                                        return unknownEntityTemplate;
5,458✔
146
                        }
147
                }
77,106✔
148

149
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
150
                        where T : CadObject
151
                {
71,072✔
152
                        this._reader.ReadNext();
71,072✔
153

154
                        DxfMap map = DxfMap.Create<T>();
71,072✔
155

156
                        while (this._reader.DxfCode != DxfCode.Start)
1,019,179✔
157
                        {
948,107✔
158
                                if (!readObject(template, map))
948,107✔
159
                                {
226,608✔
160
                                        this.readCommonCodes(template, out bool isExtendedData, map);
226,608✔
161
                                        if (isExtendedData)
226,608✔
162
                                                continue;
2,982✔
163
                                }
223,626✔
164

165
                                if (this.lockPointer)
945,125✔
166
                                {
1,152✔
167
                                        this.lockPointer = false;
1,152✔
168
                                        continue;
1,152✔
169
                                }
170

171
                                if (this._reader.DxfCode != DxfCode.Start)
943,973✔
172
                                {
914,628✔
173
                                        this._reader.ReadNext();
914,628✔
174
                                }
914,628✔
175
                        }
943,973✔
176

177
                        return template;
71,072✔
178
                }
71,072✔
179

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

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

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

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

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

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

258
                                                node.Index = this._reader.ValueAsInt;
2,564✔
259

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

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

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

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

278
                                                this._reader.ReadNext();
2,564✔
279

280
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,564✔
281
                                        }
2,564✔
282

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

298
                                                this._reader.ReadNext();
1,923✔
299
                                        }
1,923✔
300

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

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

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

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

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

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

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

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

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

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

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

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

465
                                                arr.Add(this._reader.ValueAsDouble);
21,552✔
466

467
                                                this._reader.ReadNext();
21,552✔
468
                                        }
21,552✔
469

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

478
                                                arr.Add(this._reader.ValueAsDouble);
×
479

480
                                                this._reader.ReadNext();
×
481
                                        }
×
482

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

491
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
492

493
                                                this._reader.ReadNext();
3,120✔
494
                                        }
3,120✔
495

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

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

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

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

517
                                                arr.Add(this._reader.ValueAsDouble);
18,480✔
518

519
                                                this._reader.ReadNext();
18,480✔
520
                                        }
18,480✔
521

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

530
                                                arr.Add(this._reader.ValueAsDouble);
×
531

532
                                                this._reader.ReadNext();
×
533
                                        }
×
534

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

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

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

560
                        this._reader.ReadNext();
320✔
561

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

574
                                this._reader.ReadNext();
640✔
575
                        }
640✔
576
                }
320✔
577

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

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

608
                        this._reader.ReadNext();
256✔
609

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

625
                                this._reader.ReadNext();
256✔
626
                        }
256✔
627
                }
256✔
628

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

634
                        this._reader.ReadNext();
256✔
635

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

687
                                this._reader.ReadNext();
2,048✔
688
                        }
2,048✔
689
                }
256✔
690

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

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

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

727
                                this._reader.ReadNext();
3,904✔
728
                        }
3,904✔
729
                }
320✔
730

731

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

736
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
737

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

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

763
                                this._reader.ReadNext();
2,432✔
764
                        }
2,432✔
765

766
                        return column;
×
767
                }
1,216✔
768

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

773
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
774

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

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

800
                                this._reader.ReadNext();
10,432✔
801
                        }
10,432✔
802

803
                        return row;
64✔
804
                }
1,472✔
805

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1017
                                this._reader.ReadNext();
11,584✔
1018
                        }
11,584✔
1019

1020
                        return cell;
128✔
1021
                }
5,376✔
1022

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

1027
                        this._reader.ReadNext();
5,248✔
1028

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

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

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

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

1065
                        this._reader.ReadNext();
5,248✔
1066

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

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

1091
                                this._reader.ReadNext();
×
1092
                        }
×
1093
                }
5,248✔
1094

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

1099
                        this._reader.ReadNext();
5,248✔
1100

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

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

1125
                                this._reader.ReadNext();
5,248✔
1126
                        }
5,248✔
1127
                }
5,248✔
1128

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

1133
                        this._reader.ReadNext();
×
1134

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

1151
                                if (end)
×
1152
                                {
×
1153
                                        break;
×
1154
                                }
1155

1156
                                this._reader.ReadNext();
×
1157
                        }
×
1158
                }
×
1159

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

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

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

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

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

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

1206
                        this._reader.ReadNext();
4,096✔
1207

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

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

1233
                                this._reader.ReadNext();
4,096✔
1234
                        }
4,096✔
1235

1236
                        return template;
4,096✔
1237
                }
4,096✔
1238

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

1244
                        this._reader.ReadNext();
4,096✔
1245

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

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

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

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

1285
                        this._reader.ReadNext();
4,096✔
1286

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

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

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

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

1320
                        this._reader.ReadNext();
9,600✔
1321

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

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

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

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

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

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

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

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

1389
                        this._reader.ReadNext();
8,128✔
1390

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

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

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

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

1436
                        this._reader.ReadNext();
11,776✔
1437

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

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

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

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

1481
                        this._reader.ReadNext();
2,816✔
1482

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

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

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

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

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

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

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

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

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

1576
                        this._reader.ReadNext();
8,960✔
1577

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1835
                private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1836
                {
4,439✔
1837
                        CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
4,439✔
1838

1839
                        switch (this._reader.Code)
4,439✔
1840
                        {
1841
                                default:
1842
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
4,439✔
1843
                        }
1844
                }
4,439✔
1845

1846
                private bool readBlockElement(CadTemplate template, DxfMap map)
1847
                {
5,211✔
1848
                        CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
5,211✔
1849

1850
                        switch (this._reader.Code)
5,211✔
1851
                        {
1852
                                default:
1853
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
5,211✔
1854
                                        {
4,439✔
1855
                                                return this.readEvaluationExpression(template, map);
4,439✔
1856
                                        }
1857
                                        return true;
772✔
1858
                        }
1859
                }
5,211✔
1860

1861
                private bool readBlockParameter(CadTemplate template, DxfMap map)
1862
                {
3,281✔
1863
                        CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
3,281✔
1864

1865
                        switch (this._reader.Code)
3,281✔
1866
                        {
1867
                                default:
1868
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
3,281✔
1869
                                        {
2,702✔
1870
                                                return this.readBlockElement(template, map);
2,702✔
1871
                                        }
1872
                                        return true;
579✔
1873
                        }
1874
                }
3,281✔
1875

1876
                private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
1877
                {
4,246✔
1878
                        CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,246✔
1879

1880
                        switch (this._reader.Code)
4,246✔
1881
                        {
1882
                                default:
1883
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
4,246✔
1884
                                        {
3,281✔
1885
                                                return this.readBlockParameter(template, map);
3,281✔
1886
                                        }
1887
                                        return true;
965✔
1888
                        }
1889
                }
4,246✔
1890

1891
                private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
1892
                {
5,404✔
1893
                        CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,404✔
1894

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

1922
                private CadBlockVisibilityParameterTemplate.StateTemplate readState()
1923
                {
772✔
1924
                        var state = new BlockVisibilityParameter.State();
772✔
1925
                        var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
772✔
1926

1927
                        List<int> expectedCodes = new List<int>();
772✔
1928
                        expectedCodes.Add(303);
772✔
1929
                        expectedCodes.Add(94);
772✔
1930
                        expectedCodes.Add(95);
772✔
1931

1932
                        while (this._reader.DxfCode != DxfCode.Start)
2,316✔
1933
                        {
2,316✔
1934
                                expectedCodes.Remove(this._reader.Code);
2,316✔
1935

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

1961
                                if (!expectedCodes.Any())
2,316✔
1962
                                {
772✔
1963
                                        break;
772✔
1964
                                }
1965

1966
                                this._reader.ReadNext();
1,544✔
1967
                        }
1,544✔
1968

1969
                        return template;
772✔
1970
                }
772✔
1971

1972
                private bool readBlockGrip(CadTemplate template, DxfMap map)
1973
                {
3,860✔
1974
                        CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
3,860✔
1975

1976
                        switch (this._reader.Code)
3,860✔
1977
                        {
1978
                                default:
1979
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
3,860✔
1980
                                        {
2,509✔
1981
                                                return this.readBlockElement(template, map);
2,509✔
1982
                                        }
1983
                                        return true;
1,351✔
1984
                        }
1985
                }
3,860✔
1986

1987
                private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
1988
                {
3,860✔
1989
                        CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
3,860✔
1990

1991
                        switch (this._reader.Code)
3,860✔
1992
                        {
1993
                                default:
1994
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
3,860!
1995
                                        {
3,860✔
1996
                                                return this.readBlockGrip(template, map);
3,860✔
1997
                                        }
NEW
1998
                                        return true;
×
1999
                        }
2000
                }
3,860✔
2001

2002
                private bool readXRecord(CadTemplate template, DxfMap map)
2003
                {
113,152✔
2004
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,152✔
2005

2006
                        switch (this._reader.Code)
113,152✔
2007
                        {
2008
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,896✔
2009
                                        this.readXRecordEntries(tmp);
28,896✔
2010
                                        return true;
28,896✔
2011
                                default:
2012
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,256✔
2013
                        }
2014
                }
113,152✔
2015

2016
                private void readXRecordEntries(CadXRecordTemplate template)
2017
                {
28,896✔
2018
                        this._reader.ReadNext();
28,896✔
2019

2020
                        while (this._reader.DxfCode != DxfCode.Start)
2,408,845✔
2021
                        {
2,379,949✔
2022
                                switch (this._reader.GroupCodeValue)
2,379,949✔
2023
                                {
2024
                                        case GroupCodeValueType.Point3D:
2025
                                                var code = this._reader.Code;
2,884✔
2026
                                                var x = this._reader.ValueAsDouble;
2,884✔
2027
                                                this._reader.ReadNext();
2,884✔
2028
                                                var y = this._reader.ValueAsDouble;
2,884✔
2029
                                                this._reader.ReadNext();
2,884✔
2030
                                                var z = this._reader.ValueAsDouble;
2,884✔
2031
                                                XYZ pt = new XYZ(x, y, z);
2,884✔
2032
                                                template.CadObject.CreateEntry(code, pt);
2,884✔
2033
                                                break;
2,884✔
2034
                                        case GroupCodeValueType.Handle:
2035
                                        case GroupCodeValueType.ObjectId:
2036
                                        case GroupCodeValueType.ExtendedDataHandle:
2037
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,039✔
2038
                                                break;
12,039✔
2039
                                        default:
2040
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,365,026✔
2041
                                                break;
2,365,026✔
2042
                                }
2043

2044
                                this._reader.ReadNext();
2,379,949✔
2045
                        }
2,379,949✔
2046
                }
28,896✔
2047

2048
                private bool readBookColor(CadTemplate template, DxfMap map)
2049
                {
1,376✔
2050
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
2051
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
2052

2053
                        switch (this._reader.Code)
1,376✔
2054
                        {
2055
                                case 430:
2056
                                        color.Name = this._reader.ValueAsString;
160✔
2057
                                        return true;
160✔
2058
                                default:
2059
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
2060
                        }
2061
                }
1,376✔
2062

2063
                private bool readDictionary(CadTemplate template, DxfMap map)
2064
                {
223,326✔
2065
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
223,326✔
2066
                        CadDictionary cadDictionary = tmp.CadObject;
223,326✔
2067

2068
                        switch (this._reader.Code)
223,326✔
2069
                        {
2070
                                case 280:
2071
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,026✔
2072
                                        return true;
15,026✔
2073
                                case 281:
2074
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,447✔
2075
                                        return true;
21,447✔
2076
                                case 3:
2077
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,127✔
2078
                                        return true;
57,127✔
2079
                                case 350: // Soft-owner ID/handle to entry object 
2080
                                case 360: // Hard-owner ID/handle to entry object
2081
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,127✔
2082
                                        return true;
57,127✔
2083
                                default:
2084
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,599✔
2085
                        }
2086
                }
223,326✔
2087

2088
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2089
                {
1,755✔
2090
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,755✔
2091

2092
                        switch (this._reader.Code)
1,755✔
2093
                        {
2094
                                case 340:
2095
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
195✔
2096
                                        return true;
195✔
2097
                                default:
2098
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,560!
2099
                                        {
1,560✔
2100
                                                return this.readDictionary(template, map);
1,560✔
2101
                                        }
2102
                                        return true;
×
2103
                        }
2104
                }
1,755✔
2105

2106
                private CadTemplate readSortentsTable()
2107
                {
576✔
2108
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2109
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2110

2111
                        //Jump the 0 marker
2112
                        this._reader.ReadNext();
576✔
2113

2114
                        this.readCommonObjectData(template);
576✔
2115

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

2118
                        //Jump the 100 marker
2119
                        this._reader.ReadNext();
576✔
2120

2121
                        (ulong?, ulong?) pair = (null, null);
576✔
2122

2123
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2124
                        {
3,648✔
2125
                                switch (this._reader.Code)
3,648!
2126
                                {
2127
                                        case 5:
2128
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2129
                                                break;
1,536✔
2130
                                        case 330:
2131
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2132
                                                break;
576✔
2133
                                        case 331:
2134
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2135
                                                break;
1,536✔
2136
                                        default:
2137
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2138
                                                break;
×
2139
                                }
2140

2141
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2142
                                {
1,536✔
2143
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2144
                                        pair = (null, null);
1,536✔
2145
                                }
1,536✔
2146

2147
                                this._reader.ReadNext();
3,648✔
2148
                        }
3,648✔
2149

2150
                        return template;
576✔
2151
                }
576✔
2152
        }
2153
}
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