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

DomCR / ACadSharp / 17036095696

18 Aug 2025 09:04AM UTC coverage: 78.427% (-0.02%) from 78.449%
17036095696

push

github

web-flow
Merge pull request #740 from DomCR/dxfreader-plotsettings

DxfReader PlotSettings

6493 of 9000 branches covered (72.14%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

6 existing lines in 1 file now uncovered.

25241 of 31463 relevant lines covered (80.22%)

105107.39 hits per line

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

91.42
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.IO.Templates;
2
using ACadSharp.Objects;
3
using ACadSharp.Objects.Evaluations;
4
using CSMath;
5
using System;
6
using System.Diagnostics;
7
using System.Linq;
8
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
9

10
namespace ACadSharp.IO.DXF
11
{
12
        internal class DxfObjectsSectionReader : DxfSectionReaderBase
13
        {
14
                public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
15

16
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
17
                        : base(reader, builder)
230✔
18
                {
230✔
19
                }
230✔
20

21
                public override void Read()
22
                {
230✔
23
                        //Advance to the first value in the section
24
                        this._reader.ReadNext();
230✔
25

26
                        //Loop until the section ends
27
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
67,321✔
28
                        {
67,091✔
29
                                CadTemplate template = null;
67,091✔
30

31
                                try
32
                                {
67,091✔
33
                                        template = this.readObject();
67,091✔
34
                                }
67,091✔
35
                                catch (Exception ex)
×
36
                                {
×
37
                                        if (!this._builder.Configuration.Failsafe)
×
38
                                                throw;
×
39

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

42
                                        while (this._reader.DxfCode != DxfCode.Start)
×
43
                                                this._reader.ReadNext();
×
44
                                }
×
45

46
                                if (template == null)
67,091✔
47
                                        continue;
412✔
48

49
                                //Add the object and the template to the builder
50
                                this._builder.AddTemplate(template);
66,679✔
51
                        }
66,679✔
52
                }
230✔
53

54
                private CadTemplate readObject()
55
                {
67,091✔
56
                        switch (this._reader.ValueAsString)
67,091!
57
                        {
58
                                case DxfFileToken.ObjectDBColor:
59
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
216✔
60
                                case DxfFileToken.ObjectDictionary:
61
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
22,376✔
62
                                case DxfFileToken.ObjectDictionaryWithDefault:
63
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
218✔
64
                                case DxfFileToken.ObjectLayout:
65
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
894✔
66
                                case DxfFileToken.ObjectPlotSettings:
NEW
67
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
68
                                case DxfFileToken.ObjectEvalGraph:
69
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
216✔
70
                                case DxfFileToken.ObjectDictionaryVar:
71
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,721✔
72
                                case DxfFileToken.ObjectPdfDefinition:
73
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
216✔
74
                                case DxfFileToken.ObjectSortEntsTable:
75
                                        return this.readSortentsTable();
648✔
76
                                case DxfFileToken.ObjectRasterVariables:
77
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
216✔
78
                                case DxfFileToken.ObjectGroup:
79
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
432✔
80
                                case DxfFileToken.ObjectGeoData:
81
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
82
                                case DxfFileToken.ObjectScale:
83
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,398✔
84
                                case DxfFileToken.ObjectTableContent:
85
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
432✔
86
                                case DxfFileToken.ObjectVisualStyle:
87
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,232✔
88
                                case DxfFileToken.ObjectSpatialFilter:
89
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
216✔
90
                                case DxfFileToken.ObjectXRecord:
91
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
17,474✔
92
                                default:
93
                                        DxfMap map = DxfMap.Create<CadObject>();
8,184✔
94
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
8,184✔
95
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
8,184✔
96
                                        {
7,772✔
97
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
7,772✔
98
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
7,772✔
99
                                        }
7,772✔
100
                                        else
101
                                        {
412✔
102
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
412✔
103
                                        }
412✔
104

105
                                        this._reader.ReadNext();
8,184✔
106

107
                                        do
108
                                        {
427,188✔
109
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
427,188✔
110
                                                {
44,896✔
111
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
44,896✔
112
                                                        if (isExtendedData)
44,896✔
113
                                                                continue;
72✔
114
                                                }
44,824✔
115

116
                                                this._reader.ReadNext();
427,116✔
117
                                        }
427,116✔
118
                                        while (this._reader.DxfCode != DxfCode.Start);
427,188✔
119

120
                                        return unknownEntityTemplate;
8,184✔
121
                        }
122
                }
67,091✔
123

124
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
125
                        where T : CadObject
126
                {
58,259✔
127
                        this._reader.ReadNext();
58,259✔
128

129
                        DxfMap map = DxfMap.Create<T>();
58,259✔
130

131
                        while (this._reader.DxfCode != DxfCode.Start)
1,880,536✔
132
                        {
1,822,277✔
133
                                if (!readObject(template, map))
1,822,277✔
134
                                {
1,066,541✔
135
                                        this.readCommonCodes(template, out bool isExtendedData, map);
1,066,541✔
136
                                        if (isExtendedData)
1,066,541✔
137
                                                continue;
5,533✔
138
                                }
1,061,008✔
139

140
                                if (this._reader.DxfCode != DxfCode.Start)
1,816,744✔
141
                                        this._reader.ReadNext();
1,799,054✔
142
                        }
1,816,744✔
143

144
                        return template;
58,259✔
145
                }
58,259✔
146

147
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
148
                {
19,350✔
149
                        switch (this._reader.Code)
19,350✔
150
                        {
151
                                default:
152
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
19,350✔
153
                        }
154
                }
19,350✔
155

156
                private bool readPlotSettings(CadTemplate template, DxfMap map)
157
                {
28,304✔
158
                        switch (this._reader.Code)
28,304✔
159
                        {
160
                                default:
161
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
28,304✔
162
                        }
163
                }
28,304✔
164

165
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
166
                {
1,728✔
167
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
1,728✔
168
                        EvaluationGraph evGraph = tmp.CadObject;
1,728✔
169

170
                        switch (this._reader.Code)
1,728✔
171
                        {
172
                                case 91:
173
                                        while (this._reader.Code == 91)
2,808✔
174
                                        {
2,592✔
175
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,592✔
176
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,592✔
177

178
                                                node.Index = this._reader.ValueAsInt;
2,592✔
179

180
                                                this._reader.ExpectedCode(93);
2,592✔
181
                                                node.Flags = this._reader.ValueAsInt;
2,592✔
182

183
                                                this._reader.ExpectedCode(95);
2,592✔
184
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,592✔
185

186
                                                this._reader.ExpectedCode(360);
2,592✔
187
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,592✔
188

189
                                                this._reader.ExpectedCode(92);
2,592✔
190
                                                node.Data1 = this._reader.ValueAsInt;
2,592✔
191
                                                this._reader.ExpectedCode(92);
2,592✔
192
                                                node.Data2 = this._reader.ValueAsInt;
2,592✔
193
                                                this._reader.ExpectedCode(92);
2,592✔
194
                                                node.Data3 = this._reader.ValueAsInt;
2,592✔
195
                                                this._reader.ExpectedCode(92);
2,592✔
196
                                                node.Data4 = this._reader.ValueAsInt;
2,592✔
197

198
                                                this._reader.ReadNext();
2,592✔
199

200
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,592✔
201
                                        }
2,592✔
202

203
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
204
                                case 92:
205
                                        //Edges
206
                                        while (this._reader.Code == 92)
2,376✔
207
                                        {
2,160✔
208
                                                this._reader.ExpectedCode(93);
2,160✔
209
                                                this._reader.ExpectedCode(94);
2,160✔
210
                                                this._reader.ExpectedCode(91);
2,160✔
211
                                                this._reader.ExpectedCode(91);
2,160✔
212
                                                this._reader.ExpectedCode(92);
2,160✔
213
                                                this._reader.ExpectedCode(92);
2,160✔
214
                                                this._reader.ExpectedCode(92);
2,160✔
215
                                                this._reader.ExpectedCode(92);
2,160✔
216
                                                this._reader.ExpectedCode(92);
2,160✔
217

218
                                                this._reader.ReadNext();
2,160✔
219
                                        }
2,160✔
220

221
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
222
                                default:
223
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
1,296✔
224
                        }
225
                }
1,728✔
226

227
                private bool readLayout(CadTemplate template, DxfMap map)
228
                {
57,610✔
229
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
57,610✔
230

231
                        switch (this._reader.Code)
57,610✔
232
                        {
233
                                case 330:
234
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,788✔
235
                                        return true;
1,788✔
236
                                case 331:
237
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
866✔
238
                                        return true;
866✔
239
                                default:
240
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
54,956✔
241
                                        {
28,304✔
242
                                                return this.readPlotSettings(template, map);
28,304✔
243
                                        }
244
                                        return true;
26,652✔
245
                        }
246
                }
57,610✔
247

248
                private bool readGroup(CadTemplate template, DxfMap map)
249
                {
5,616✔
250
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,616✔
251

252
                        switch (this._reader.Code)
5,616✔
253
                        {
254
                                case 70:
255
                                        return true;
432✔
256
                                case 340:
257
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,592✔
258
                                        return true;
2,592✔
259
                                default:
260
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,592✔
261
                        }
262
                }
5,616✔
263

264
                private bool readGeoData(CadTemplate template, DxfMap map)
265
                {
102✔
266
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
267

268
                        switch (this._reader.Code)
102✔
269
                        {
270
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
271
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
272
                                                tmp.CadObject.ReferencePoint.X,
1✔
273
                                                this._reader.ValueAsDouble,
1✔
274
                                                tmp.CadObject.ReferencePoint.Z
1✔
275
                                                );
1✔
276
                                        return true;
1✔
277
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
278
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
279
                                                this._reader.ValueAsDouble,
1✔
280
                                                tmp.CadObject.ReferencePoint.Y,
1✔
281
                                                tmp.CadObject.ReferencePoint.Z
1✔
282
                                                );
1✔
283
                                        return true;
1✔
284
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
285
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
286
                                                tmp.CadObject.ReferencePoint.X,
1✔
287
                                                tmp.CadObject.ReferencePoint.Y,
1✔
288
                                                this._reader.ValueAsDouble
1✔
289
                                                );
1✔
290
                                        return true;
1✔
291
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
292
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
293
                                        return true;
1✔
294
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
295
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
296
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
297
                                        return true;
1✔
298
                                // Number of Geo-Mesh points
299
                                case 93:
300
                                        var npts = this._reader.ValueAsInt;
3✔
301
                                        for (int i = 0; i < npts; i++)
54✔
302
                                        {
24✔
303
                                                this._reader.ReadNext();
24✔
304
                                                double sourceX = this._reader.ValueAsDouble;
24✔
305
                                                this._reader.ReadNext();
24✔
306
                                                double sourceY = this._reader.ValueAsDouble;
24✔
307

308
                                                this._reader.ReadNext();
24✔
309
                                                double destX = this._reader.ValueAsDouble;
24✔
310
                                                this._reader.ReadNext();
24✔
311
                                                double destY = this._reader.ValueAsDouble;
24✔
312

313
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
314
                                                {
24✔
315
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
316
                                                        Destination = new CSMath.XY(destX, destY)
24✔
317
                                                });
24✔
318
                                        }
24✔
319
                                        return true;
3✔
320
                                // Number of Geo-Mesh points
321
                                case 96:
322
                                        var nfaces = this._reader.ValueAsInt;
2✔
323
                                        for (int i = 0; i < nfaces; i++)
4!
324
                                        {
×
325
                                                this._reader.ReadNext();
×
326
                                                Debug.Assert(this._reader.Code == 97);
×
327
                                                int index1 = this._reader.ValueAsInt;
×
328
                                                this._reader.ReadNext();
×
329
                                                Debug.Assert(this._reader.Code == 98);
×
330
                                                int index2 = this._reader.ValueAsInt;
×
331
                                                this._reader.ReadNext();
×
332
                                                Debug.Assert(this._reader.Code == 99);
×
333
                                                int index3 = this._reader.ValueAsInt;
×
334

335
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
336
                                                {
×
337
                                                        Index1 = index1,
×
338
                                                        Index2 = index2,
×
339
                                                        Index3 = index3
×
340
                                                });
×
341
                                        }
×
342
                                        return true;
2✔
343
                                case 303:
344
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
345
                                        return true;
13✔
346
                                //Obsolete codes for version GeoDataVersion.R2009
347
                                case 3:
348
                                case 4:
349
                                case 14:
350
                                case 24:
351
                                case 15:
352
                                case 25:
353
                                case 43:
354
                                case 44:
355
                                case 45:
356
                                case 94:
357
                                case 293:
358
                                case 16:
359
                                case 26:
360
                                case 17:
361
                                case 27:
362
                                case 54:
363
                                case 140:
364
                                case 304:
365
                                case 292:
366
                                        return true;
19✔
367
                                default:
368
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
369
                        }
370
                }
102✔
371

372
                private bool readScale(CadTemplate template, DxfMap map)
373
                {
66,378✔
374
                        switch (this._reader.Code)
66,378✔
375
                        {
376
                                // Undocumented codes
377
                                case 70:
378
                                        //Always 0
379
                                        return true;
7,398✔
380
                                default:
381
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
58,980✔
382
                        }
383
                }
66,378✔
384

385
                private bool readTableContent(CadTemplate template, DxfMap map)
386
                {
999,648✔
387
                        switch (this._reader.Code)
999,648✔
388
                        {
389
                                default:
390
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.TableContent]);
999,648✔
391
                        }
392
                }
999,648✔
393

394
                private bool readVisualStyle(CadTemplate template, DxfMap map)
395
                {
389,764✔
396
                        switch (this._reader.Code)
389,764✔
397
                        {
398
                                // Undocumented codes
399
                                case 176:
400
                                case 177:
401
                                case 420:
402
                                        return true;
133,826✔
403
                                default:
404
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
255,938✔
405
                        }
406
                }
389,764✔
407

408
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
409
                {
4,536✔
410
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,536✔
411
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,536✔
412

413
                        switch (this._reader.Code)
4,536✔
414
                        {
415
                                case 10:
416
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
432✔
417
                                        return true;
432✔
418
                                case 20:
419
                                        var pt = filter.BoundaryPoints.LastOrDefault();
432✔
420
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
432✔
421
                                        return true;
432✔
422
                                case 40:
423
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
432!
424
                                        {
×
425
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
426
                                                tmp.HasFrontPlane = true;
×
427
                                        }
×
428

429
                                        double[] array = new double[16]
432✔
430
                                        {
432✔
431
                                                0.0, 0.0, 0.0, 0.0,
432✔
432
                                                0.0, 0.0, 0.0, 0.0,
432✔
433
                                                0.0, 0.0, 0.0, 0.0,
432✔
434
                                                0.0, 0.0, 0.0, 1.0
432✔
435
                                        };
432✔
436

437
                                        for (int i = 0; i < 12; i++)
11,232✔
438
                                        {
5,184✔
439
                                                array[i] = this._reader.ValueAsDouble;
5,184✔
440

441
                                                if (i < 11)
5,184✔
442
                                                {
4,752✔
443
                                                        this._reader.ReadNext();
4,752✔
444
                                                }
4,752✔
445
                                        }
5,184✔
446

447
                                        if (tmp.InsertTransformRead)
432!
448
                                        {
×
449
                                                filter.InsertTransform = new Matrix4(array);
×
450
                                                tmp.InsertTransformRead = true;
×
451
                                        }
×
452
                                        else
453
                                        {
432✔
454
                                                filter.InverseInsertTransform = new Matrix4(array);
432✔
455
                                        }
432✔
456

457
                                        return true;
432✔
458
                                case 73:
459
                                default:
460
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,240✔
461
                        }
462
                }
4,536✔
463

464
                private bool readXRecord(CadTemplate template, DxfMap map)
465
                {
67,160✔
466
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
67,160✔
467

468
                        switch (this._reader.Code)
67,160✔
469
                        {
470
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
17,474✔
471
                                        this.readXRecordEntries(tmp);
17,474✔
472
                                        return true;
17,474✔
473
                                default:
474
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
49,686✔
475
                        }
476
                }
67,160✔
477

478
                private void readXRecordEntries(CadXRecordTemplate template)
479
                {
17,474✔
480
                        this._reader.ReadNext();
17,474✔
481

482
                        while (this._reader.DxfCode != DxfCode.Start)
935,644✔
483
                        {
918,170✔
484
                                switch (this._reader.GroupCodeValue)
918,170!
485
                                {
486
                                        case GroupCodeValueType.Handle:
487
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
488
                                                break;
×
489
                                        default:
490
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
918,170✔
491
                                                break;
918,170✔
492
                                }
493

494
                                this._reader.ReadNext();
918,170✔
495
                        }
918,170✔
496
                }
17,474✔
497

498
                private bool readBookColor(CadTemplate template, DxfMap map)
499
                {
1,548✔
500
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,548✔
501
                        BookColor color = tmp.CadObject as BookColor;
1,548✔
502

503
                        switch (this._reader.Code)
1,548✔
504
                        {
505
                                case 430:
506
                                        color.Name = this._reader.ValueAsString;
180✔
507
                                        return true;
180✔
508
                                default:
509
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,368✔
510
                        }
511
                }
1,548✔
512

513
                private bool readDictionary(CadTemplate template, DxfMap map)
514
                {
208,835✔
515
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
208,835✔
516
                        CadDictionary cadDictionary = tmp.CadObject;
208,835✔
517

518
                        switch (this._reader.Code)
208,835✔
519
                        {
520
                                case 280:
521
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,249✔
522
                                        return true;
15,249✔
523
                                case 281:
524
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
22,594✔
525
                                        return true;
22,594✔
526
                                case 3:
527
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
46,834✔
528
                                        return true;
46,834✔
529
                                case 350: // Soft-owner ID/handle to entry object 
530
                                case 360: // Hard-owner ID/handle to entry object
531
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
46,834✔
532
                                        return true;
46,834✔
533
                                default:
534
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
77,324✔
535
                        }
536
                }
208,835✔
537

538
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
539
                {
1,962✔
540
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,962✔
541

542
                        switch (this._reader.Code)
1,962✔
543
                        {
544
                                case 340:
545
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
218✔
546
                                        return true;
218✔
547
                                default:
548
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,744!
549
                                        {
1,744✔
550
                                                return this.readDictionary(template, map);
1,744✔
551
                                        }
552
                                        return true;
×
553
                        }
554
                }
1,962✔
555

556
                private CadTemplate readSortentsTable()
557
                {
648✔
558
                        SortEntitiesTable sortTable = new SortEntitiesTable();
648✔
559
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
648✔
560

561
                        //Jump the 0 marker
562
                        this._reader.ReadNext();
648✔
563

564
                        this.readCommonObjectData(template);
648✔
565

566
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
648✔
567

568
                        //Jump the 100 marker
569
                        this._reader.ReadNext();
648✔
570

571
                        (ulong?, ulong?) pair = (null, null);
648✔
572

573
                        while (this._reader.DxfCode != DxfCode.Start)
4,752✔
574
                        {
4,104✔
575
                                switch (this._reader.Code)
4,104!
576
                                {
577
                                        case 5:
578
                                                pair.Item1 = this._reader.ValueAsHandle;
1,728✔
579
                                                break;
1,728✔
580
                                        case 330:
581
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
648✔
582
                                                break;
648✔
583
                                        case 331:
584
                                                pair.Item2 = this._reader.ValueAsHandle;
1,728✔
585
                                                break;
1,728✔
586
                                        default:
587
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
588
                                                break;
×
589
                                }
590

591
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,104✔
592
                                {
1,728✔
593
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,728✔
594
                                        pair = (null, null);
1,728✔
595
                                }
1,728✔
596

597
                                this._reader.ReadNext();
4,104✔
598
                        }
4,104✔
599

600
                        return template;
648✔
601
                }
648✔
602
        }
603
}
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