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

DomCR / ACadSharp / 20990989439

14 Jan 2026 10:33AM UTC coverage: 77.001% (+0.1%) from 76.896%
20990989439

Pull #949

github

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

7997 of 11239 branches covered (71.15%)

Branch coverage included in aggregate %.

265 of 285 new or added lines in 18 files covered. (92.98%)

19 existing lines in 7 files now uncovered.

29038 of 36858 relevant lines covered (78.78%)

148638.49 hits per line

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

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

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

21
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
22
                        : base(reader, builder)
207✔
23
                {
207✔
24
                }
207✔
25

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

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

36
                                try
37
                                {
77,106✔
38
                                        template = this.readObject();
77,106✔
39
                                }
77,106✔
40
                                catch (Exception ex)
×
41
                                {
×
42
                                        if (!this._builder.Configuration.Failsafe)
×
43
                                                throw;
×
44

45
                                        this._builder.Notify($"Error while reading an object at line {this._reader.Position}", NotificationType.Error, ex);
×
46

47
                                        while (this._reader.DxfCode != DxfCode.Start)
×
48
                                                this._reader.ReadNext();
×
49
                                }
×
50

51
                                if (template == null)
77,106✔
52
                                        continue;
×
53

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

469
                                                arr.Add(this._reader.ValueAsDouble);
21,552✔
470

471
                                                this._reader.ReadNext();
21,552✔
472
                                        }
21,552✔
473

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

482
                                                arr.Add(this._reader.ValueAsDouble);
×
483

484
                                                this._reader.ReadNext();
×
485
                                        }
×
486

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

495
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
496

497
                                                this._reader.ReadNext();
3,120✔
498
                                        }
3,120✔
499

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

508
                                                arr.Add(this._reader.ValueAsDouble);
3,120✔
509

510
                                                this._reader.ReadNext();
3,120✔
511
                                        }
3,120✔
512

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

521
                                                arr.Add(this._reader.ValueAsDouble);
18,480✔
522

523
                                                this._reader.ReadNext();
18,480✔
524
                                        }
18,480✔
525

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

534
                                                arr.Add(this._reader.ValueAsDouble);
×
535

536
                                                this._reader.ReadNext();
×
537
                                        }
×
538

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

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

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

564
                        this._reader.ReadNext();
320✔
565

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

578
                                this._reader.ReadNext();
640✔
579
                        }
640✔
580
                }
320✔
581

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

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

612
                        this._reader.ReadNext();
256✔
613

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

629
                                this._reader.ReadNext();
256✔
630
                        }
256✔
631
                }
256✔
632

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

638
                        this._reader.ReadNext();
256✔
639

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

691
                                this._reader.ReadNext();
2,048✔
692
                        }
2,048✔
693
                }
256✔
694

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

700
                        this._reader.ReadNext();
320✔
701

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

731
                                this._reader.ReadNext();
3,904✔
732
                        }
3,904✔
733
                }
320✔
734

735

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

740
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
741

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

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

767
                                this._reader.ReadNext();
2,432✔
768
                        }
2,432✔
769

770
                        return column;
×
771
                }
1,216✔
772

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

777
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
778

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

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

804
                                this._reader.ReadNext();
10,432✔
805
                        }
10,432✔
806

807
                        return row;
64✔
808
                }
1,472✔
809

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1021
                                this._reader.ReadNext();
11,584✔
1022
                        }
11,584✔
1023

1024
                        return cell;
128✔
1025
                }
5,376✔
1026

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

1031
                        this._reader.ReadNext();
5,248✔
1032

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

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

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

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

1069
                        this._reader.ReadNext();
5,248✔
1070

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

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

1095
                                this._reader.ReadNext();
×
1096
                        }
×
1097
                }
5,248✔
1098

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

1103
                        this._reader.ReadNext();
5,248✔
1104

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

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

1129
                                this._reader.ReadNext();
5,248✔
1130
                        }
5,248✔
1131
                }
5,248✔
1132

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

1137
                        this._reader.ReadNext();
×
1138

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

1155
                                if (end)
×
1156
                                {
×
1157
                                        break;
×
1158
                                }
1159

1160
                                this._reader.ReadNext();
×
1161
                        }
×
1162
                }
×
1163

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

1168
                        this._reader.ReadNext();
5,376✔
1169

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

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

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

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

1210
                        this._reader.ReadNext();
4,096✔
1211

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

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

1237
                                this._reader.ReadNext();
4,096✔
1238
                        }
4,096✔
1239

1240
                        return template;
4,096✔
1241
                }
4,096✔
1242

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

1248
                        this._reader.ReadNext();
4,096✔
1249

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

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

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

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

1289
                        this._reader.ReadNext();
4,096✔
1290

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

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

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

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

1324
                        this._reader.ReadNext();
9,600✔
1325

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

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

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

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

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

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

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

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

1393
                        this._reader.ReadNext();
8,128✔
1394

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

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

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

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

1440
                        this._reader.ReadNext();
11,776✔
1441

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

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

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

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

1485
                        this._reader.ReadNext();
2,816✔
1486

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

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

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

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

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

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

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

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

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

1580
                        this._reader.ReadNext();
8,960✔
1581

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1974
                                this._reader.ReadNext();
1,544✔
1975
                        }
1,544✔
1976

1977
                        return template;
772✔
1978
                }
772✔
1979

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2134
                        //Jump the 0 marker
2135
                        this._reader.ReadNext();
576✔
2136

2137
                        this.readCommonObjectData(template);
576✔
2138

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

2141
                        //Jump the 100 marker
2142
                        this._reader.ReadNext();
576✔
2143

2144
                        (ulong?, ulong?) pair = (null, null);
576✔
2145

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

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

2170
                                this._reader.ReadNext();
3,648✔
2171
                        }
3,648✔
2172

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