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

DomCR / ACadSharp / 29350739879

14 Jul 2026 04:42PM UTC coverage: 76.459% (+0.5%) from 75.931%
29350739879

Pull #1151

github

web-flow
Merge 1222155e8 into 8f9e76381
Pull Request #1151: DxfWriter - Dynamic parameters

9316 of 13143 branches covered (70.88%)

Branch coverage included in aggregate %.

644 of 735 new or added lines in 27 files covered. (87.62%)

7 existing lines in 4 files now uncovered.

33209 of 42475 relevant lines covered (78.18%)

154426.77 hits per line

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

83.94
/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
using static ACadSharp.IO.Templates.CadTableStyleTemplate;
15
using static System.Collections.Specialized.BitVector32;
16

17
namespace ACadSharp.IO.DXF.DxfStreamReader;
18

19
internal class DxfObjectsSectionReader : DxfSectionReaderBase
20
{
21
        public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
22

23
        public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
24
                : base(reader, builder)
228✔
25
        {
228✔
26
        }
228✔
27

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

33
                //Loop until the section ends
34
                while (this._reader.ValueAsString != DxfFileToken.EndSection)
83,422✔
35
                {
83,194✔
36
                        CadTemplate template = null;
83,194✔
37

38
                        try
39
                        {
83,194✔
40
                                template = this.readObject();
83,194✔
41
                        }
83,194✔
42
                        catch (Exception ex)
×
43
                        {
×
44
                                if (!this._builder.Configuration.Failsafe)
×
45
                                        throw;
×
46

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

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

53
                        if (template == null)
83,194✔
54
                                continue;
×
55

56
                        //Add the object and the template to the builder
57
                        this._builder.AddTemplate(template);
83,194✔
58
                }
83,194✔
59
        }
228✔
60

61
        private CadTemplate readObject()
62
        {
83,194✔
63
                this.currentSubclass = string.Empty;
83,194✔
64
                switch (this._reader.ValueAsString)
83,194!
65
                {
66
                        case DxfFileToken.BlkRefObjectContextData:
67
                                return this.readObjectCodes<BlockReferenceObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new BlockReferenceObjectContextData()), this.readAnnotScaleObjectContextData);
×
68
                        case DxfFileToken.MTextAttributeObjectContextData:
69
                                return this.readObjectCodes<MTextAttributeObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new MTextAttributeObjectContextData()), this.readAnnotScaleObjectContextData);
×
70
                        case DxfFileToken.ObjectPlaceholder:
71
                                return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
216✔
72
                        case DxfFileToken.ObjectDBColor:
73
                                return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
204✔
74
                        case DxfFileToken.ObjectDimensionAssociation:
75
                                return this.readObjectCodes<DimensionAssociation>(new CadDimensionAssociationTemplate(), this.readDimensionAssociation);
612✔
76
                        case DxfFileToken.ObjectDictionary:
77
                                return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
22,900✔
78
                        case DxfFileToken.ObjectDictionaryWithDefault:
79
                                return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
216✔
80
                        case DxfFileToken.ObjectLayout:
81
                                return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
876✔
82
                        case DxfFileToken.ObjectPlotSettings:
83
                                return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
84
                        case DxfFileToken.ObjectEvalGraph:
85
                                return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
486✔
86
                        case DxfFileToken.ObjectImageDefinition:
87
                                return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
204✔
88
                        case DxfFileToken.ObjectDictionaryVar:
89
                                return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
3,048✔
90
                        case DxfFileToken.ObjectPdfDefinition:
91
                                return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
204✔
92
                        case DxfFileToken.ObjectSortEntsTable:
93
                                return this.readSortentsTable();
612✔
94
                        case DxfFileToken.ObjectImageDefinitionReactor:
95
                                return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
204✔
96
                        case DxfFileToken.ObjectProxyObject:
97
                                return this.readObjectCodes<ProxyObject>(new CadProxyObjectTemplate(), this.readProxyObject);
×
98
                        case DxfFileToken.ObjectRasterVariables:
99
                                return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
204✔
100
                        case DxfFileToken.ObjectGroup:
101
                                return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
408✔
102
                        case DxfFileToken.ObjectGeoData:
103
                                return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
104
                        case DxfFileToken.ObjectMaterial:
105
                                return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,280✔
106
                        case DxfFileToken.ObjectScale:
107
                                return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,332✔
108
                        case DxfFileToken.ObjectTableContent:
109
                                return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
340✔
110
                        case DxfFileToken.ObjectVisualStyle:
111
                                return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,184✔
112
                        case DxfFileToken.ObjectSpatialFilter:
113
                                return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
204✔
114
                        case DxfFileToken.ObjectMLineStyle:
115
                                return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
228✔
116
                        case DxfFileToken.ObjectMLeaderStyle:
117
                                return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
444✔
118
                        case DxfFileToken.ObjectTableStyle:
119
                                return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
228✔
120
                        case DxfFileToken.ObjectXRecord:
121
                                return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
30,842✔
122
                        case DxfFileToken.ObjectDynamicBlockPurgePreventer:
123
                                return this.readObjectCodes<DynamicBlockPurgePreventer>(new CadNonGraphicalObjectTemplate(new DynamicBlockPurgePreventer()), this.readObjectSubclassMap);
214✔
124
                        case DxfFileToken.ObjectBlockRepresentationData:
125
                                return this.readObjectCodes<BlockRepresentationData>(new CadBlockRepresentationDataTemplate(), this.readBlockRepresentationData);
300✔
126
                        case DxfFileToken.ObjectBlockGripLocationComponent:
127
                                return this.readObjectCodes<BlockGripExpression>(new CadBlockGripExpressionTemplate(), this.readBlockGripExpression);
1,252✔
128
                        case DxfFileToken.ObjectBlockVisibilityGrip:
129
                                return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockGripTemplate(new BlockVisibilityGrip()), this.readBlockGripSubclass);
206✔
130
                        case DxfFileToken.ObjectBlockXYGrip:
131
                                return this.readObjectCodes<BlockXYGrip>(new CadBlockGripTemplate(new BlockXYGrip()), this.readBlockGripSubclass);
2✔
132
                        case DxfFileToken.ObjectBlockVisibilityParameter:
133
                                return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
206✔
134
                        case DxfFileToken.ObjectBlockRotationParameter:
135
                                return this.readObjectCodes<BlockRotationParameter>(new CadBlockRotationParameterTemplate(), this.readBlockRotationParameter);
2✔
136
                        case DxfFileToken.ObjectBlockLinearParameter:
137
                                return this.readObjectCodes<BlockLinearParameter>(new CadBlockLinearParameterTemplate(), this.readBlockLinearParameter);
208✔
138
                        case DxfFileToken.ObjectBlockLookupParameter:
139
                                return this.readObjectCodes<BlockLookupParameter>(new CadBlockLookupParameterTemplate(new BlockLookupParameter()), this.readBlockLookupParameter);
2✔
140
                        case DxfFileToken.ObjectBlockLinearGrip:
141
                                return this.readObjectCodes<BlockLinearGrip>(new CadBlockGripTemplate(new BlockLinearGrip()), this.readBlockGripSubclass);
414✔
142
                        case DxfFileToken.ObjectBlockRotationGrip:
143
                                return this.readObjectCodes<BlockRotationGrip>(new CadBlockGripTemplate(new BlockRotationGrip()), this.readBlockGripSubclass);
2✔
144
                        case DxfFileToken.ObjectBlockMoveAction:
145
                                return this.readObjectCodes<BlockMoveAction>(new CadBlockMoveActionTemplate(), this.readBlockMoveAction);
2✔
146
                        case DxfFileToken.ObjectBlockScaleAction:
147
                                return this.readObjectCodes<BlockScaleAction>(new CadBlockScaleActionTemplate(), this.readBlockScaleAction);
206✔
148
                        case DxfFileToken.ObjectBlockRotateAction:
149
                                return this.readObjectCodes<BlockRotationAction>(new CadBlockRotationActionTemplate(), this.readBlockRotationAction);
2✔
150
                        case DxfFileToken.ObjectBlockPointParameter:
151
                                return this.readObjectCodes<BlockPointParameter>(new CadBlockPointParameterTemplate(), this.readBlockPointParameter);
2✔
152
                        case DxfFileToken.ObjectField:
153
                                return this.readObjectCodes<Field>(new CadFieldTemplate(new Field()), this.readField);
×
154
                        case DxfFileToken.ObjectFieldList:
155
                                return this.readObjectCodes<FieldList>(new CadFieldListTemplate(new FieldList()), this.readFieldList);
×
156
                        default:
157
                                DxfMap map = DxfMap.Create<CadObject>();
2,696✔
158
                                CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
2,696✔
159
                                if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
2,696!
160
                                {
2,696✔
161
                                        this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
2,696✔
162
                                        unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
2,696✔
163
                                }
2,696✔
164
                                else
165
                                {
×
166
                                        this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
167
                                }
×
168

169
                                this._reader.ReadNext();
2,696✔
170

171
                                do
172
                                {
228,501✔
173
                                        if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
228,501!
174
                                        {
25,728✔
175
                                                this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
25,728✔
176
                                                if (isExtendedData)
25,728✔
177
                                                        continue;
×
178
                                        }
25,728✔
179

180
                                        this._reader.ReadNext();
228,501✔
181
                                }
228,501✔
182
                                while (this._reader.DxfCode != DxfCode.Start);
228,501✔
183

184
                                return unknownEntityTemplate;
2,696✔
185
                }
186
        }
83,194✔
187

188
        protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
189
                where T : CadObject
190
        {
79,886✔
191
                this._reader.ReadNext();
79,886✔
192

193
                DxfMap map = DxfMap.Create<T>();
79,886✔
194

195
                while (this._reader.DxfCode != DxfCode.Start)
1,172,410✔
196
                {
1,092,524✔
197
                        if (!readObject(template, map))
1,092,524✔
198
                        {
260,409✔
199
                                this.readCommonCodes(template, out bool isExtendedData, map);
260,409✔
200
                                if (isExtendedData)
260,409✔
201
                                        continue;
3,391✔
202
                        }
257,018✔
203

204
                        if (this.lockPointer)
1,089,133✔
205
                        {
2,740✔
206
                                this.lockPointer = false;
2,740✔
207
                                continue;
2,740✔
208
                        }
209

210
                        if (this._reader.DxfCode != DxfCode.Start)
1,086,393✔
211
                        {
1,055,551✔
212
                                this._reader.ReadNext();
1,055,551✔
213
                        }
1,055,551✔
214
                }
1,086,393✔
215

216
                return template;
79,886✔
217
        }
79,886✔
218

219
        private bool readFieldList(CadTemplate template, DxfMap map)
220
        {
×
221
                var tmp = template as CadFieldListTemplate;
×
222

223
                switch (this._reader.Code)
×
224
                {
225
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.IdSet:
×
226
                                this.currentSubclass = this._reader.ValueAsString;
×
227
                                return true;
×
228
                        case 90 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
229
                                return true;
×
230
                        case 330 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
231
                                tmp.OwnedObjectsHandlers.Add(this._reader.ValueAsHandle);
×
232
                                return true;
×
233
                        default:
234
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.FieldList]);
×
235
                }
236
        }
×
237

238
        private bool readField(CadTemplate template, DxfMap map)
239
        {
×
240
                var tmp = template as CadFieldTemplate;
×
241

242
                switch (this._reader.Code)
×
243
                {
244
                        case 3:
245
                                tmp.CadObject.FieldCode += this._reader.ValueAsString;
×
246
                                return true;
×
247
                        //98 Length of format string
248
                        case 98:
249
                                return true;
×
250
                        case 6:
251
                                string key = this._reader.ValueAsString;
×
252
                                var t = this.readCadValue(new CadValue());
×
253
                                tmp.CadObject.Values.Add(key, t.CadValue);
×
254
                                tmp.CadValueTemplates.Add(t);
×
255
                                return true;
×
256
                        case 7:
257
                                t = this.readCadValue(new CadValue());
×
258
                                tmp.CadObject.Value = t.CadValue;
×
259
                                tmp.CadValueTemplates.Add(t);
×
260
                                return true;
×
261
                        case 331:
262
                                tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
263
                                return true;
×
264
                        case 360:
265
                                tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
266
                                return true;
×
267
                        default:
268
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
269
                }
270
        }
×
271

272
        private bool readProxyObject(CadTemplate template, DxfMap map)
273
        {
×
274
                CadProxyObjectTemplate tmp = template as CadProxyObjectTemplate;
×
275
                ProxyObject proxy = template.CadObject as ProxyObject;
×
276

277
                switch (this._reader.Code)
×
278
                {
279
                        case 90:
280
                        case 94:
281
                        //Undocumented
282
                        case 97:
283
                        case 71:
284
                                return true;
×
285
                        case 95:
286
                                int format = this._reader.ValueAsInt;
×
287
                                proxy.Version = (ACadVersion)(format & 0xFFFF);
×
288
                                proxy.MaintenanceVersion = (short)(format >> 16);
×
289
                                return true;
×
290
                        case 91:
291
                                var classId = this._reader.ValueAsShort;
×
292
                                if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
293
                                {
×
294
                                        proxy.DxfClass = dxfClass;
×
295
                                }
×
296
                                return true;
×
297
                        case 161:
298
                                return true;
×
299
                        case 162:
300
                                return true;
×
301
                        case 310:
302
                                if (proxy.BinaryData == null)
×
303
                                {
×
304
                                        proxy.BinaryData = new MemoryStream();
×
305
                                }
×
306
                                proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
307
                                return true;
×
308
                        case 311:
309
                                if (proxy.Data == null)
×
310
                                {
×
311
                                        proxy.Data = new MemoryStream();
×
312
                                }
×
313
                                proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
314
                                return true;
×
315
                        case 330:
316
                        case 340:
317
                        case 350:
318
                        case 360:
319
                                tmp.Entries.Add(this._reader.ValueAsHandle);
×
320
                                return true;
×
321
                        default:
322
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
323
                }
324
        }
×
325

326
        private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
327
        {
26,258✔
328
                switch (this._reader.Code)
26,258✔
329
                {
330
                        default:
331
                                if (string.IsNullOrEmpty(this.currentSubclass))
26,258✔
332
                                {
16,684✔
333
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
16,684✔
334
                                }
335
                                else
336
                                {
9,574✔
337
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
9,574✔
338
                                }
339
                }
340
        }
26,258✔
341

342
        private bool readAnnotScaleObjectContextData(CadTemplate template, DxfMap map)
343
        {
×
344
                var tmp = template as CadAnnotScaleObjectContextDataTemplate;
×
345
                switch (this._reader.Code)
×
346
                {
347
                        case 340:
348
                                tmp.ScaleHandle = this._reader.ValueAsHandle;
×
349
                                return true;
×
350
                        default:
351
                                if (string.IsNullOrEmpty(this.currentSubclass))
×
352
                                {
×
353
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
354
                                }
355
                                else
356
                                {
×
357
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
358
                                }
359
                }
360
        }
×
361

362
        private bool readPlotSettings(CadTemplate template, DxfMap map)
363
        {
28,594✔
364
                switch (this._reader.Code)
28,594✔
365
                {
366
                        default:
367
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
28,594✔
368
                }
369
        }
28,594✔
370

371
        private bool readEvaluationGraph(CadTemplate template, DxfMap map)
372
        {
3,344✔
373
                CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,344✔
374
                EvaluationGraph evGraph = tmp.CadObject;
3,344✔
375

376
                switch (this._reader.Code)
3,344✔
377
                {
378
                        case 91:
379
                                while (this._reader.Code == 91)
3,270✔
380
                                {
2,784✔
381
                                        EvaluationGraph.Node node = tmp.CadObject.CreateNode();
2,784✔
382
                                        GraphNodeTemplate nodeTemplate = new GraphNodeTemplate(node);
2,784✔
383

384
                                        node.Index = this._reader.ValueAsInt;
2,784✔
385

386
                                        this._reader.ExpectedCode(93);
2,784✔
387
                                        node.Flags = (EvaluationGraph.NodeFlags)this._reader.ValueAsInt;
2,784✔
388

389
                                        this._reader.ExpectedCode(95);
2,784✔
390
                                        node.Id = this._reader.ValueAsInt;
2,784✔
391

392
                                        this._reader.ExpectedCode(360);
2,784✔
393
                                        nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,784✔
394

395
                                        this._reader.ExpectedCode(92);
2,784✔
396
                                        node.Data1 = this._reader.ValueAsInt;
2,784✔
397
                                        this._reader.ExpectedCode(92);
2,784✔
398
                                        node.Data2 = this._reader.ValueAsInt;
2,784✔
399
                                        this._reader.ExpectedCode(92);
2,784✔
400
                                        node.Data3 = this._reader.ValueAsInt;
2,784✔
401
                                        this._reader.ExpectedCode(92);
2,784✔
402
                                        node.Data4 = this._reader.ValueAsInt;
2,784✔
403

404
                                        this._reader.ReadNext();
2,784✔
405

406
                                        tmp.NodeTemplates.Add(nodeTemplate);
2,784✔
407
                                }
2,784✔
408

409
                                this.lockPointer = true;
486✔
410
                                return true;
486✔
411
                        case 92:
412
                                //Edges
413
                                while (this._reader.Code == 92)
2,312✔
414
                                {
2,098✔
415
                                        EvaluationGraph.Edge edge = new EvaluationGraph.Edge();
2,098✔
416

417
                                        edge.Index = this._reader.ValueAsInt;
2,098✔
418

419
                                        this._reader.ExpectedCode(93);
2,098✔
420
                                        edge.Flags = this._reader.ValueAsInt;
2,098✔
421

422
                                        this._reader.ExpectedCode(94);
2,098✔
423
                                        edge.TrackedCount = this._reader.ValueAsInt;
2,098✔
424

425
                                        this._reader.ExpectedCode(91);
2,098✔
426
                                        edge.FromNodeIndex = this._reader.ValueAsInt;
2,098✔
427
                                        this._reader.ExpectedCode(91);
2,098✔
428
                                        edge.ToNodeIndex = this._reader.ValueAsInt;
2,098✔
429

430
                                        this._reader.ExpectedCode(92);
2,098✔
431
                                        edge.Data1 = this._reader.ValueAsInt;
2,098✔
432
                                        this._reader.ExpectedCode(92);
2,098✔
433
                                        edge.Data2 = this._reader.ValueAsInt;
2,098✔
434
                                        this._reader.ExpectedCode(92);
2,098✔
435
                                        edge.Data3 = this._reader.ValueAsInt;
2,098✔
436
                                        this._reader.ExpectedCode(92);
2,098✔
437
                                        edge.Data4 = this._reader.ValueAsInt;
2,098✔
438
                                        this._reader.ExpectedCode(92);
2,098✔
439
                                        edge.Data5 = this._reader.ValueAsInt;
2,098✔
440

441
                                        this._reader.ReadNext();
2,098✔
442

443
                                        tmp.CadObject.Edges.Add(edge);
2,098✔
444
                                }
2,098✔
445

446
                                this.lockPointer = true;
214✔
447
                                return true;
214✔
448
                        default:
449
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,644✔
450
                }
451
        }
3,344✔
452

453
        private bool readLayout(CadTemplate template, DxfMap map)
454
        {
56,418✔
455
                CadLayoutTemplate tmp = template as CadLayoutTemplate;
56,418✔
456

457
                switch (this._reader.Code)
56,418✔
458
                {
459
                        case 330 when template.OwnerHandle.HasValue:
1,752✔
460
                                tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
876✔
461
                                return true;
876✔
462
                        case 331:
463
                                tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
828✔
464
                                return true;
828✔
465
                        default:
466
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
54,714✔
467
                                {
28,594✔
468
                                        return this.readPlotSettings(template, map);
28,594✔
469
                                }
470
                                return true;
26,120✔
471
                }
472
        }
56,418✔
473

474
        private bool readGroup(CadTemplate template, DxfMap map)
475
        {
5,304✔
476
                CadGroupTemplate tmp = template as CadGroupTemplate;
5,304✔
477

478
                switch (this._reader.Code)
5,304✔
479
                {
480
                        case 70:
481
                                return true;
408✔
482
                        case 340:
483
                                tmp.Handles.Add(this._reader.ValueAsHandle);
2,448✔
484
                                return true;
2,448✔
485
                        default:
486
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,448✔
487
                }
488
        }
5,304✔
489

490
        private bool readGeoData(CadTemplate template, DxfMap map)
491
        {
102✔
492
                CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
493

494
                switch (this._reader.Code)
102✔
495
                {
496
                        case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
497
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
498
                                        tmp.CadObject.ReferencePoint.X,
1✔
499
                                        this._reader.ValueAsDouble,
1✔
500
                                        tmp.CadObject.ReferencePoint.Z
1✔
501
                                        );
1✔
502
                                return true;
1✔
503
                        case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
504
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
505
                                        this._reader.ValueAsDouble,
1✔
506
                                        tmp.CadObject.ReferencePoint.Y,
1✔
507
                                        tmp.CadObject.ReferencePoint.Z
1✔
508
                                        );
1✔
509
                                return true;
1✔
510
                        case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
511
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
512
                                        tmp.CadObject.ReferencePoint.X,
1✔
513
                                        tmp.CadObject.ReferencePoint.Y,
1✔
514
                                        this._reader.ValueAsDouble
1✔
515
                                        );
1✔
516
                                return true;
1✔
517
                        case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
518
                                tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
519
                                return true;
1✔
520
                        case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
521
                                double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
522
                                tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
523
                                return true;
1✔
524
                        // Number of Geo-Mesh points
525
                        case 93:
526
                                var npts = this._reader.ValueAsInt;
3✔
527
                                for (int i = 0; i < npts; i++)
54✔
528
                                {
24✔
529
                                        this._reader.ReadNext();
24✔
530
                                        double sourceX = this._reader.ValueAsDouble;
24✔
531
                                        this._reader.ReadNext();
24✔
532
                                        double sourceY = this._reader.ValueAsDouble;
24✔
533

534
                                        this._reader.ReadNext();
24✔
535
                                        double destX = this._reader.ValueAsDouble;
24✔
536
                                        this._reader.ReadNext();
24✔
537
                                        double destY = this._reader.ValueAsDouble;
24✔
538

539
                                        tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
540
                                        {
24✔
541
                                                Source = new CSMath.XY(sourceX, sourceY),
24✔
542
                                                Destination = new CSMath.XY(destX, destY)
24✔
543
                                        });
24✔
544
                                }
24✔
545
                                return true;
3✔
546
                        // Number of Geo-Mesh points
547
                        case 96:
548
                                var nfaces = this._reader.ValueAsInt;
2✔
549
                                for (int i = 0; i < nfaces; i++)
4!
550
                                {
×
551
                                        this._reader.ReadNext();
×
552
                                        Debug.Assert(this._reader.Code == 97);
×
553
                                        int index1 = this._reader.ValueAsInt;
×
554
                                        this._reader.ReadNext();
×
555
                                        Debug.Assert(this._reader.Code == 98);
×
556
                                        int index2 = this._reader.ValueAsInt;
×
557
                                        this._reader.ReadNext();
×
558
                                        Debug.Assert(this._reader.Code == 99);
×
559
                                        int index3 = this._reader.ValueAsInt;
×
560

561
                                        tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
562
                                        {
×
563
                                                Index1 = index1,
×
564
                                                Index2 = index2,
×
565
                                                Index3 = index3
×
566
                                        });
×
567
                                }
×
568
                                return true;
2✔
569
                        case 303:
570
                                tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
571
                                return true;
13✔
572
                        //Obsolete codes for version GeoDataVersion.R2009
573
                        case 3:
574
                        case 4:
575
                        case 14:
576
                        case 24:
577
                        case 15:
578
                        case 25:
579
                        case 43:
580
                        case 44:
581
                        case 45:
582
                        case 94:
583
                        case 293:
584
                        case 16:
585
                        case 26:
586
                        case 17:
587
                        case 27:
588
                        case 54:
589
                        case 140:
590
                        case 304:
591
                        case 292:
592
                                return true;
19✔
593
                        default:
594
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
595
                }
596
        }
102✔
597

598
        private bool readMaterial(CadTemplate template, DxfMap map)
599
        {
44,920✔
600
                CadMaterialTemplate tmp = template as CadMaterialTemplate;
44,920✔
601
                List<double> arr = null;
44,920✔
602

603
                switch (this._reader.Code)
44,920!
604
                {
605
                        case 43:
606
                                arr = new();
1,440✔
607
                                for (int i = 0; i < 16; i++)
48,960✔
608
                                {
23,040✔
609
                                        Debug.Assert(this._reader.Code == 43);
23,040✔
610

611
                                        arr.Add(this._reader.ValueAsDouble);
23,040✔
612

613
                                        this._reader.ReadNext();
23,040✔
614
                                }
23,040✔
615

616
                                tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,440✔
617
                                return this.checkObjectEnd(template, map, this.readMaterial);
1,440✔
618
                        case 47:
619
                                arr = new();
×
620
                                for (int i = 0; i < 16; i++)
×
621
                                {
×
622
                                        Debug.Assert(this._reader.Code == 47);
×
623

624
                                        arr.Add(this._reader.ValueAsDouble);
×
625

626
                                        this._reader.ReadNext();
×
627
                                }
×
628

629
                                tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
630
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
631
                        case 49:
632
                                arr = new();
216✔
633
                                for (int i = 0; i < 16; i++)
7,344✔
634
                                {
3,456✔
635
                                        Debug.Assert(this._reader.Code == 49);
3,456✔
636

637
                                        arr.Add(this._reader.ValueAsDouble);
3,456✔
638

639
                                        this._reader.ReadNext();
3,456✔
640
                                }
3,456✔
641

642
                                tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
216✔
643
                                return this.checkObjectEnd(template, map, this.readMaterial);
216✔
644
                        case 142:
645
                                arr = new();
216✔
646
                                for (int i = 0; i < 16; i++)
7,344✔
647
                                {
3,456✔
648
                                        Debug.Assert(this._reader.Code == 142);
3,456✔
649

650
                                        arr.Add(this._reader.ValueAsDouble);
3,456✔
651

652
                                        this._reader.ReadNext();
3,456✔
653
                                }
3,456✔
654

655
                                tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
216✔
656
                                return this.checkObjectEnd(template, map, this.readMaterial);
216✔
657
                        case 144:
658
                                arr = new();
1,236✔
659
                                for (int i = 0; i < 16; i++)
42,024✔
660
                                {
19,776✔
661
                                        Debug.Assert(this._reader.Code == 144);
19,776✔
662

663
                                        arr.Add(this._reader.ValueAsDouble);
19,776✔
664

665
                                        this._reader.ReadNext();
19,776✔
666
                                }
19,776✔
667

668
                                tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,236✔
669
                                return this.checkObjectEnd(template, map, this.readMaterial);
1,236✔
670
                        case 147:
671
                                arr = new();
×
672
                                for (int i = 0; i < 16; i++)
×
673
                                {
×
674
                                        Debug.Assert(this._reader.Code == 147);
×
675

676
                                        arr.Add(this._reader.ValueAsDouble);
×
677

678
                                        this._reader.ReadNext();
×
679
                                }
×
680

681
                                tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
682
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
683
                        default:
684
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
41,812✔
685
                }
686
        }
44,920✔
687

688
        private bool readScale(CadTemplate template, DxfMap map)
689
        {
65,784✔
690
                switch (this._reader.Code)
65,784✔
691
                {
692
                        // Undocumented codes
693
                        case 70:
694
                                //Always 0
695
                                return true;
7,332✔
696
                        default:
697
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
58,452✔
698
                }
699
        }
65,784✔
700

701
        private void readLinkedData(CadTemplate template, DxfMap map)
702
        {
340✔
703
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
340✔
704
                LinkedData linkedData = tmp.CadObject;
340✔
705

706
                this._reader.ReadNext();
340✔
707

708
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
1,020!
709
                {
680✔
710
                        switch (this._reader.Code)
680✔
711
                        {
712
                                default:
713
                                        if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
680!
714
                                        {
×
715
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
716
                                        }
×
717
                                        break;
680✔
718
                        }
719

720
                        this._reader.ReadNext();
680✔
721
                }
680✔
722
        }
340✔
723

724
        private bool readTableContent(CadTemplate template, DxfMap map)
725
        {
2,516✔
726
                switch (this._reader.Code)
2,516✔
727
                {
728
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,292✔
729
                                this.readTableContentSubclass(template, map);
272✔
730
                                this.lockPointer = true;
272✔
731
                                return true;
272✔
732
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
1,020✔
733
                                this.readFormattedTableDataSubclass(template, map);
272✔
734
                                this.lockPointer = true;
272✔
735
                                return true;
272✔
736
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
748✔
737
                                this.readLinkedTableDataSubclass(template, map);
340✔
738
                                this.lockPointer = true;
340✔
739
                                return true;
340✔
740
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
408✔
741
                                this.readLinkedData(template, map);
340✔
742
                                this.lockPointer = true;
340✔
743
                                return true;
340✔
744
                        default:
745
                                return false;
1,292✔
746
                }
747
        }
2,516✔
748

749
        private void readTableContentSubclass(CadTemplate template, DxfMap map)
750
        {
272✔
751
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
272✔
752
                TableContent tableContent = tmp.CadObject;
272✔
753

754
                this._reader.ReadNext();
272✔
755

756
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
544✔
757
                {
272✔
758
                        switch (this._reader.Code)
272!
759
                        {
760
                                case 340:
761
                                        tmp.SytleHandle = this._reader.ValueAsHandle;
272✔
762
                                        break;
272✔
763
                                default:
764
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
765
                                        {
×
766
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
767
                                        }
×
768
                                        break;
×
769
                        }
770

771
                        this._reader.ReadNext();
272✔
772
                }
272✔
773
        }
272✔
774

775
        private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
776
        {
272✔
777
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
272✔
778
                FormattedTableData formattedTable = tmp.CadObject;
272✔
779

780
                this._reader.ReadNext();
272✔
781

782
                TableEntity.CellRange cellRange = null;
272✔
783
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,448!
784
                {
2,176✔
785
                        switch (this._reader.Code)
2,176!
786
                        {
787
                                case 90:
788
                                        break;
272✔
789
                                case 91:
790
                                        if (cellRange == null)
408✔
791
                                        {
408✔
792
                                                cellRange = new();
408✔
793
                                                formattedTable.MergedCellRanges.Add(cellRange);
408✔
794
                                        }
408✔
795
                                        cellRange.TopRowIndex = this._reader.ValueAsInt;
408✔
796
                                        break;
408✔
797
                                case 92:
798
                                        if (cellRange == null)
408!
799
                                        {
×
800
                                                cellRange = new();
×
801
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
802
                                        }
×
803
                                        cellRange.LeftColumnIndex = this._reader.ValueAsInt;
408✔
804
                                        break;
408✔
805
                                case 93:
806
                                        if (cellRange == null)
408!
807
                                        {
×
808
                                                cellRange = new();
×
809
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
810
                                        }
×
811
                                        cellRange.BottomRowIndex = this._reader.ValueAsInt;
408✔
812
                                        break;
408✔
813
                                case 94:
814
                                        if (cellRange == null)
408!
815
                                        {
×
816
                                                cellRange = new();
×
817
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
818
                                        }
×
819
                                        cellRange.RightColumnIndex = this._reader.ValueAsInt;
408✔
820
                                        cellRange = null;
408✔
821
                                        break;
408✔
822
                                case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
272!
823
                                        this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
272✔
824
                                        break;
272✔
825
                                default:
826
                                        if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
827
                                        {
×
828
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
829
                                        }
×
830
                                        break;
×
831
                        }
832

833
                        this._reader.ReadNext();
2,176✔
834
                }
2,176✔
835
        }
272✔
836

837
        private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
838
        {
340✔
839
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
340✔
840
                TableContent tableContent = tmp.CadObject;
340✔
841

842
                this._reader.ReadNext();
340✔
843

844
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,488!
845
                {
4,148✔
846
                        switch (this._reader.Code)
4,148✔
847
                        {
848
                                case 90:
849
                                        //Column count
850
                                        break;
340✔
851
                                case 91:
852
                                        //Row count
853
                                        break;
340✔
854
                                //Unknown
855
                                case 92:
856
                                        break;
272✔
857
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,292✔
858
                                        //Read Column
859
                                        this.readTableColumn();
1,292✔
860
                                        break;
1,292✔
861
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,564✔
862
                                        //Read Row
863
                                        this.readTableRow();
1,564✔
864
                                        break;
1,564✔
865
                                default:
866
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
340✔
867
                                        {
340✔
868
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
340✔
869
                                        }
340✔
870
                                        break;
340✔
871
                        }
872

873
                        this._reader.ReadNext();
4,148✔
874
                }
4,148✔
875
        }
340✔
876

877

878
        private TableEntity.Column readTableColumn()
879
        {
1,292✔
880
                this._reader.ReadNext();
1,292✔
881

882
                TableEntity.Column column = new TableEntity.Column();
1,292✔
883

884
                bool end = false;
1,292✔
885
                while (this._reader.DxfCode != DxfCode.Start)
3,876!
886
                {
3,876✔
887
                        switch (this._reader.Code)
3,876!
888
                        {
889
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,876✔
890
                                        this.readLinkedTableColumn(column);
1,292✔
891
                                        break;
1,292✔
892
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,584✔
893
                                        this.readFormattedTableColumn(column);
1,292✔
894
                                        break;
1,292✔
895
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,292!
896
                                        this.readTableColumn(column);
1,292✔
897
                                        end = true;
1,292✔
898
                                        break;
1,292✔
899
                                default:
900
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
901
                                        break;
×
902
                        }
903

904
                        if (end)
3,876✔
905
                        {
1,292✔
906
                                return column;
1,292✔
907
                        }
908

909
                        this._reader.ReadNext();
2,584✔
910
                }
2,584✔
911

912
                return column;
×
913
        }
1,292✔
914

915
        private TableEntity.Row readTableRow()
916
        {
1,564✔
917
                this._reader.ReadNext();
1,564✔
918

919
                TableEntity.Row row = new TableEntity.Row();
1,564✔
920

921
                bool end = false;
1,564✔
922
                while (this._reader.DxfCode != DxfCode.Start)
12,648✔
923
                {
12,580✔
924
                        switch (this._reader.Code)
12,580✔
925
                        {
926
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,392✔
927
                                        this.readLinkedTableRow(row);
1,632✔
928
                                        break;
1,632✔
929
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,760✔
930
                                        this.readFormattedTableRow(row);
1,496✔
931
                                        break;
1,496✔
932
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,264✔
933
                                        this.readTableRow(row);
1,496✔
934
                                        end = true;
1,496✔
935
                                        break;
1,496✔
936
                                default:
937
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,956✔
938
                                        break;
7,956✔
939
                        }
940

941
                        if (end)
12,580✔
942
                        {
1,496✔
943
                                return row;
1,496✔
944
                        }
945

946
                        this._reader.ReadNext();
11,084✔
947
                }
11,084✔
948

949
                return row;
68✔
950
        }
1,564✔
951

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

956
                bool end = false;
1,496✔
957
                while (this._reader.DxfCode != DxfCode.Start)
4,488✔
958
                {
4,488✔
959
                        switch (this._reader.Code)
4,488!
960
                        {
961
                                case 40:
962
                                        row.Height = this._reader.ValueAsDouble;
1,496✔
963
                                        break;
1,496✔
964
                                case 90:
965
                                        //styleID
966
                                        break;
1,496✔
967
                                case 309:
968
                                        end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,496✔
969
                                        break;
1,496✔
970
                                default:
971
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
972
                                        break;
×
973
                        }
974

975
                        if (end)
4,488✔
976
                        {
1,496✔
977
                                break;
1,496✔
978
                        }
979

980
                        this._reader.ReadNext();
2,992✔
981
                }
2,992✔
982
        }
1,496✔
983

984
        private void readFormattedTableRow(TableEntity.Row row)
985
        {
1,496✔
986
                this._reader.ReadNext();
1,496✔
987

988
                bool end = false;
1,496✔
989
                while (this._reader.DxfCode != DxfCode.Start)
4,488✔
990
                {
4,488✔
991
                        switch (this._reader.Code)
4,488!
992
                        {
993
                                case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,496!
994
                                        break;
1,496✔
995
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,496!
996
                                        this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,496✔
997
                                        break;
1,496✔
998
                                case 309:
999
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,496✔
1000
                                        break;
1,496✔
1001
                                default:
1002
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
1003
                                        break;
×
1004
                        }
1005

1006
                        if (end)
4,488✔
1007
                        {
1,496✔
1008
                                break;
1,496✔
1009
                        }
1010

1011
                        this._reader.ReadNext();
2,992✔
1012
                }
2,992✔
1013
        }
1,496✔
1014

1015
        private void readTableColumn(TableEntity.Column column)
1016
        {
1,292✔
1017
                this._reader.ReadNext();
1,292✔
1018

1019
                bool end = false;
1,292✔
1020
                while (this._reader.DxfCode != DxfCode.Start)
3,876✔
1021
                {
3,876✔
1022
                        switch (this._reader.Code)
3,876!
1023
                        {
1024
                                case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1025
                                        break;
×
1026
                                case 1:
1027
                                        end = true;
×
1028
                                        break;
×
1029
                                case 40:
1030
                                        column.Width = this._reader.ValueAsDouble;
1,292✔
1031
                                        break;
1,292✔
1032
                                case 90:
1033
                                        //StyleId
1034
                                        break;
1,292✔
1035
                                case 309:
1036
                                        end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,292✔
1037
                                        break;
1,292✔
1038
                                default:
1039
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
1040
                                        break;
×
1041
                        }
1042

1043
                        if (end)
3,876✔
1044
                        {
1,292✔
1045
                                break;
1,292✔
1046
                        }
1047

1048
                        this._reader.ReadNext();
2,584✔
1049
                }
2,584✔
1050
        }
1,292✔
1051

1052
        private void readLinkedTableColumn(TableEntity.Column column)
1053
        {
1,292✔
1054
                this._reader.ReadNext();
1,292✔
1055

1056
                bool end = false;
1,292✔
1057
                while (this._reader.DxfCode != DxfCode.Start)
5,168✔
1058
                {
5,168✔
1059
                        switch (this._reader.Code)
5,168!
1060
                        {
1061
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
1062
                                        break;
×
1063
                                case 1:
1064
                                        end = true;
×
1065
                                        break;
×
1066
                                case 91:
1067
                                        column.CustomData = this._reader.ValueAsInt;
1,292✔
1068
                                        break;
1,292✔
1069
                                case 300:
1070
                                        column.Name = this._reader.ValueAsString;
1,292✔
1071
                                        break;
1,292✔
1072
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,292!
1073
                                        this.readCustomData();
1,292✔
1074
                                        break;
1,292✔
1075
                                case 309:
1076
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,292✔
1077
                                        break;
1,292✔
1078
                                default:
1079
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
1080
                                        break;
×
1081
                        }
1082

1083
                        if (end)
5,168✔
1084
                        {
1,292✔
1085
                                break;
1,292✔
1086
                        }
1087

1088
                        this._reader.ReadNext();
3,876✔
1089
                }
3,876✔
1090
        }
1,292✔
1091

1092
        private void readLinkedTableRow(TableEntity.Row row)
1093
        {
1,632✔
1094
                this._reader.ReadNext();
1,632✔
1095

1096
                bool end = false;
1,632✔
1097
                while (this._reader.DxfCode != DxfCode.Start)
13,396✔
1098
                {
13,260✔
1099
                        switch (this._reader.Code)
13,260!
1100
                        {
1101
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
1102
                                        break;
×
1103
                                case 90:
1104
                                        break;
1,632✔
1105
                                case 91:
1106
                                        row.CustomData = this._reader.ValueAsInt;
1,496✔
1107
                                        break;
1,496✔
1108
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,712✔
1109
                                        this.readCell();
5,712✔
1110
                                        break;
5,712✔
1111
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,496✔
1112
                                        this.readCustomData();
1,496✔
1113
                                        break;
1,496✔
1114
                                case 309:
1115
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,496✔
1116
                                        break;
1,496✔
1117
                                default:
1118
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,428✔
1119
                                        break;
1,428✔
1120
                        }
1121

1122
                        if (end)
13,260✔
1123
                        {
1,496✔
1124
                                break;
1,496✔
1125
                        }
1126

1127
                        this._reader.ReadNext();
11,764✔
1128
                }
11,764✔
1129
        }
1,632✔
1130

1131
        private TableEntity.Cell readCell()
1132
        {
5,712✔
1133
                this._reader.ReadNext();
5,712✔
1134

1135
                TableEntity.Cell cell = new TableEntity.Cell();
5,712✔
1136
                CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,712✔
1137

1138
                bool end = false;
5,712✔
1139
                while (this._reader.DxfCode != DxfCode.Start)
18,020✔
1140
                {
17,884✔
1141
                        switch (this._reader.Code)
17,884✔
1142
                        {
1143
                                case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
16,864✔
1144
                                        this.readLinkedTableCell(cell);
5,712✔
1145
                                        break;
5,712✔
1146
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,152✔
1147
                                        this.readFormattedTableCell(cell);
5,576✔
1148
                                        break;
5,576✔
1149
                                case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,576✔
1150
                                        this.readTableCell(cell);
5,576✔
1151
                                        end = true;
5,576✔
1152
                                        break;
5,576✔
1153
                                default:
1154
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
1,020✔
1155
                                        break;
1,020✔
1156
                        }
1157

1158
                        if (end)
17,884✔
1159
                        {
5,576✔
1160
                                return cell;
5,576✔
1161
                        }
1162

1163
                        this._reader.ReadNext();
12,308✔
1164
                }
12,308✔
1165

1166
                return cell;
136✔
1167
        }
5,712✔
1168

1169
        private void readTableCell(TableEntity.Cell cell)
1170
        {
5,576✔
1171
                var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,576✔
1172

1173
                this._reader.ReadNext();
5,576✔
1174

1175
                bool end = false;
5,576✔
1176
                while (this._reader.DxfCode != DxfCode.Start)
17,408✔
1177
                {
17,408✔
1178
                        switch (this._reader.Code)
17,408✔
1179
                        {
1180
                                //Unknown
1181
                                case 40:
1182
                                case 41:
1183
                                        break;
272✔
1184
                                case 309:
1185
                                        end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,576✔
1186
                                        break;
5,576✔
1187
                                case 330:
1188
                                        //Unknown handle
1189
                                        break;
136✔
1190
                                default:
1191
                                        if (!this.tryAssignCurrentValue(cell, map))
11,424!
1192
                                        {
×
1193
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1194
                                        }
×
1195
                                        break;
11,424✔
1196
                        }
1197

1198
                        if (end)
17,408✔
1199
                        {
5,576✔
1200
                                break;
5,576✔
1201
                        }
1202

1203
                        this._reader.ReadNext();
11,832✔
1204
                }
11,832✔
1205
        }
5,576✔
1206

1207
        private void readFormattedTableCell(TableEntity.Cell cell)
1208
        {
5,576✔
1209
                var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,576✔
1210

1211
                this._reader.ReadNext();
5,576✔
1212

1213
                bool end = false;
5,576✔
1214
                while (this._reader.DxfCode != DxfCode.Start)
11,152✔
1215
                {
11,152✔
1216
                        switch (this._reader.Code)
11,152!
1217
                        {
1218
                                case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,576!
1219
                                        this.readCellTableFormat(cell);
5,576✔
1220
                                        continue;
5,576✔
1221
                                case 309:
1222
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,576✔
1223
                                        break;
5,576✔
1224
                                default:
1225
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1226
                                        {
×
1227
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1228
                                        }
×
1229
                                        break;
×
1230
                        }
1231

1232
                        if (end)
5,576!
1233
                        {
5,576✔
1234
                                break;
5,576✔
1235
                        }
1236

1237
                        this._reader.ReadNext();
×
1238
                }
×
1239
        }
5,576✔
1240

1241
        private void readCellTableFormat(TableEntity.Cell cell)
1242
        {
5,576✔
1243
                var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,576✔
1244

1245
                this._reader.ReadNext();
5,576✔
1246

1247
                bool end = false;
5,576✔
1248
                while (this._reader.Code == 1)
11,152✔
1249
                {
5,576✔
1250
                        switch (this._reader.Code)
5,576!
1251
                        {
1252
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,576!
1253
                                        this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,576✔
1254
                                        break;
5,576✔
1255
                                case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1256
                                        this.readCellStyle(new CadCellStyleTemplate());
×
1257
                                        break;
×
1258
                                default:
1259
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1260
                                        {
×
1261
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1262
                                        }
×
1263
                                        break;
×
1264
                        }
1265

1266
                        if (end)
5,576!
1267
                        {
×
1268
                                break;
×
1269
                        }
1270

1271
                        this._reader.ReadNext();
5,576✔
1272
                }
5,576✔
1273
        }
5,576✔
1274

1275
        private void readCellStyle(CadCellStyleTemplate template)
1276
        {
×
1277
                //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1278

1279
                this._reader.ReadNext();
×
1280

1281
                bool end = false;
×
1282
                while (this._reader.Code != 1)
×
1283
                {
×
1284
                        switch (this._reader.Code)
×
1285
                        {
1286
                                case 309:
1287
                                        end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1288
                                        break;
×
1289
                                default:
1290
                                        //if (!this.tryAssignCurrentValue(cell, map))
1291
                                        {
×
1292
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1293
                                        }
×
1294
                                        break;
×
1295
                        }
1296

1297
                        if (end)
×
1298
                        {
×
1299
                                break;
×
1300
                        }
1301

1302
                        this._reader.ReadNext();
×
1303
                }
×
1304
        }
×
1305

1306
        private void readLinkedTableCell(TableEntity.Cell cell)
1307
        {
5,712✔
1308
                var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,712✔
1309

1310
                this._reader.ReadNext();
5,712✔
1311

1312
                bool end = false;
5,712✔
1313
                while (this._reader.DxfCode != DxfCode.Start)
57,256✔
1314
                {
57,120✔
1315
                        switch (this._reader.Code)
57,120✔
1316
                        {
1317
                                case 95:
1318
                                        //BL 95 Number of cell contents
1319
                                        break;
5,576✔
1320
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,712✔
1321
                                        this.readCustomData();
5,712✔
1322
                                        break;
5,712✔
1323
                                case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,352✔
1324
                                        var c = this.readLinkedTableCellContent();
4,352✔
1325
                                        break;
4,352✔
1326
                                case 309:
1327
                                        end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,576✔
1328
                                        break;
5,576✔
1329
                                default:
1330
                                        if (!this.tryAssignCurrentValue(cell, map))
35,904✔
1331
                                        {
12,376✔
1332
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
12,376✔
1333
                                        }
12,376✔
1334
                                        break;
35,904✔
1335
                        }
1336

1337
                        if (end)
57,120✔
1338
                        {
5,576✔
1339
                                break;
5,576✔
1340
                        }
1341

1342
                        this._reader.ReadNext();
51,544✔
1343
                }
51,544✔
1344
        }
5,712✔
1345

1346
        private CadTableCellContentTemplate readLinkedTableCellContent()
1347
        {
4,352✔
1348
                TableEntity.CellContent content = new TableEntity.CellContent();
4,352✔
1349
                CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,352✔
1350
                var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,352✔
1351

1352
                this._reader.ReadNext();
4,352✔
1353

1354
                bool end = false;
4,352✔
1355
                while (this._reader.DxfCode != DxfCode.Start)
8,704✔
1356
                {
8,704✔
1357
                        switch (this._reader.Code)
8,704!
1358
                        {
1359
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,704✔
1360
                                        readFormattedCellContent();
4,352✔
1361
                                        end = true;
4,352✔
1362
                                        break;
4,352✔
1363
                                case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,352!
1364
                                        readCellContent(template);
4,352✔
1365
                                        break;
4,352✔
1366
                                default:
1367
                                        if (!this.tryAssignCurrentValue(content, map))
×
1368
                                        {
×
1369
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1370
                                        }
×
1371
                                        break;
×
1372
                        }
1373

1374
                        if (end)
8,704✔
1375
                        {
4,352✔
1376
                                break;
4,352✔
1377
                        }
1378

1379
                        this._reader.ReadNext();
4,352✔
1380
                }
4,352✔
1381

1382
                return template;
4,352✔
1383
        }
4,352✔
1384

1385
        private void readCellContent(CadTableCellContentTemplate template)
1386
        {
4,352✔
1387
                TableEntity.CellContent content = template.Content;
4,352✔
1388
                var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,352✔
1389

1390
                this._reader.ReadNext();
4,352✔
1391

1392
                bool end = false;
4,352✔
1393
                while (this._reader.DxfCode != DxfCode.Start)
17,408✔
1394
                {
17,408✔
1395
                        switch (this._reader.Code)
17,408✔
1396
                        {
1397
                                case 91:
1398
                                        break;
4,352✔
1399
                                case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,944✔
1400
                                        var valueTemplate = this.readCadValue(content.CadValue);
3,944✔
1401
                                        template.CadValueTemplate = valueTemplate;
3,944✔
1402
                                        break;
3,944✔
1403
                                case 309:
1404
                                        end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,352✔
1405
                                        break;
4,352✔
1406
                                case 340:
1407
                                        template.BlockRecordHandle = this._reader.ValueAsHandle;
408✔
1408
                                        break;
408✔
1409
                                default:
1410
                                        if (!this.tryAssignCurrentValue(content, map))
4,352!
1411
                                        {
×
1412
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1413
                                        }
×
1414
                                        break;
4,352✔
1415
                        }
1416

1417
                        if (end)
17,408✔
1418
                        {
4,352✔
1419
                                break;
4,352✔
1420
                        }
1421

1422
                        this._reader.ReadNext();
13,056✔
1423
                }
13,056✔
1424
        }
4,352✔
1425

1426
        private void readFormattedCellContent()
1427
        {
4,352✔
1428
                TableStyle.ContentFormat format = new();
4,352✔
1429
                CellContentFormatTemplate template = new CellContentFormatTemplate(format);
4,352✔
1430
                var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,352✔
1431

1432
                this._reader.ReadNext();
4,352✔
1433

1434
                bool end = false;
4,352✔
1435
                while (this._reader.DxfCode != DxfCode.Start)
13,056✔
1436
                {
13,056✔
1437
                        switch (this._reader.Code)
13,056✔
1438
                        {
1439
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,352✔
1440
                                        readContentFormat(template);
4,352✔
1441
                                        break;
4,352✔
1442
                                case 309:
1443
                                        end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,352✔
1444
                                        break;
4,352✔
1445
                                default:
1446
                                        if (!this.tryAssignCurrentValue(format, map))
4,352!
1447
                                        {
×
1448
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1449
                                        }
×
1450
                                        break;
4,352✔
1451
                        }
1452

1453
                        if (end)
13,056✔
1454
                        {
4,352✔
1455
                                break;
4,352✔
1456
                        }
1457

1458
                        this._reader.ReadNext();
8,704✔
1459
                }
8,704✔
1460
        }
4,352✔
1461

1462
        private void readContentFormat(CellContentFormatTemplate template)
1463
        {
10,200✔
1464
                var format = template.Format;
10,200✔
1465
                var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
10,200✔
1466

1467
                this._reader.ReadNext();
10,200✔
1468

1469
                bool end = false;
10,200✔
1470
                while (this._reader.DxfCode != DxfCode.Start)
132,600✔
1471
                {
132,600✔
1472
                        switch (this._reader.Code)
132,600✔
1473
                        {
1474
                                case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,200✔
1475
                                        break;
10,200✔
1476
                                case 309:
1477
                                        end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
10,200✔
1478
                                        break;
10,200✔
1479
                                case 340:
1480
                                        template.TextStyleHandle = this._reader.ValueAsHandle;
10,200✔
1481
                                        break;
10,200✔
1482
                                default:
1483
                                        if (!this.tryAssignCurrentValue(format, map))
102,000!
1484
                                        {
×
1485
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1486
                                        }
×
1487
                                        break;
102,000✔
1488
                        }
1489

1490
                        if (end)
132,600✔
1491
                        {
10,200✔
1492
                                break;
10,200✔
1493
                        }
1494

1495
                        this._reader.ReadNext();
122,400✔
1496
                }
122,400✔
1497
        }
10,200✔
1498

1499
        private void readFormattedTableColumn(TableEntity.Column column)
1500
        {
1,292✔
1501
                this._reader.ReadNext();
1,292✔
1502

1503
                bool end = false;
1,292✔
1504
                while (this._reader.DxfCode != DxfCode.Start)
3,876✔
1505
                {
3,876✔
1506
                        switch (this._reader.Code)
3,876!
1507
                        {
1508
                                case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,292!
1509
                                        break;
1,292✔
1510
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,292!
1511
                                        this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,292✔
1512
                                        break;
1,292✔
1513
                                case 309:
1514
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,292✔
1515
                                        break;
1,292✔
1516
                                default:
1517
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1518
                                        break;
×
1519
                        }
1520

1521
                        if (end)
3,876✔
1522
                        {
1,292✔
1523
                                break;
1,292✔
1524
                        }
1525

1526
                        this._reader.ReadNext();
2,584✔
1527
                }
2,584✔
1528
        }
1,292✔
1529

1530
        private void readStyleOverride(CadCellStyleTemplate template)
1531
        {
8,636✔
1532
                var style = template.Format as TableStyle.CellStyle;
8,636✔
1533
                var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,636✔
1534
                var mapformat = DxfClassMap.Create(typeof(TableStyle.ContentFormat), "TABLEFORMAT_BEGIN");
8,636✔
1535

1536
                this._reader.ReadNext();
8,636✔
1537

1538
                bool end = false;
8,636✔
1539
                var currBorder = TableStyle.CellEdgeFlags.Unknown;
8,636✔
1540
                while (this._reader.DxfCode != DxfCode.Start)
95,132✔
1541
                {
95,132✔
1542
                        switch (this._reader.Code)
95,132✔
1543
                        {
1544
                                case 95:
1545
                                        currBorder = (TableStyle.CellEdgeFlags)this._reader.ValueAsInt;
12,512✔
1546
                                        break;
12,512✔
1547
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
272✔
1548
                                        break;
272✔
1549
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,848✔
1550
                                        readContentFormat(new CellContentFormatTemplate(new TableStyle.ContentFormat()));
5,848✔
1551
                                        break;
5,848✔
1552
                                case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,992✔
1553
                                        this.readCellMargin(template);
2,992✔
1554
                                        break;
2,992✔
1555
                                case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
12,512✔
1556
                                        TableStyle.CellBorder border = new TableStyle.CellBorder(currBorder);
12,512✔
1557
                                        this.readGridFormat(template, border);
12,512✔
1558
                                        break;
12,512✔
1559
                                case 309:
1560
                                        end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,636✔
1561
                                        break;
8,636✔
1562
                                default:
1563
                                        if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
52,360!
1564
                                        {
×
1565
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1566
                                        }
×
1567
                                        break;
52,360✔
1568
                        }
1569

1570
                        if (end)
95,132✔
1571
                        {
8,636✔
1572
                                break;
8,636✔
1573
                        }
1574

1575
                        this._reader.ReadNext();
86,496✔
1576
                }
86,496✔
1577
        }
8,636✔
1578

1579
        private void readGridFormat(CadCellStyleTemplate template, TableStyle.CellBorder border)
1580
        {
12,512✔
1581
                var map = DxfClassMap.Create(border.GetType(), nameof(TableStyle.CellBorder));
12,512✔
1582

1583
                this._reader.ReadNext();
12,512✔
1584

1585
                bool end = false;
12,512✔
1586
                while (this._reader.DxfCode != DxfCode.Start)
112,608✔
1587
                {
112,608✔
1588
                        switch (this._reader.Code)
112,608✔
1589
                        {
1590
                                case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
12,512✔
1591
                                        break;
12,512✔
1592
                                case 62:
1593
                                        border.Color = new Color(this._reader.ValueAsShort);
12,512✔
1594
                                        break;
12,512✔
1595
                                case 92:
1596
                                        border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
12,512✔
1597
                                        break;
12,512✔
1598
                                case 93:
1599
                                        border.IsInvisible = this._reader.ValueAsBool;
12,512✔
1600
                                        break;
12,512✔
1601
                                case 340:
1602
                                        template.BorderLineTypePairs.Add(new Tuple<TableStyle.CellBorder, ulong>(border, this._reader.ValueAsHandle));
12,512✔
1603
                                        break;
12,512✔
1604
                                case 309:
1605
                                        end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
12,512✔
1606
                                        break;
12,512✔
1607
                                default:
1608
                                        if (!this.tryAssignCurrentValue(border, map))
37,536!
1609
                                        {
×
1610
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1611
                                        }
×
1612
                                        break;
37,536✔
1613
                        }
1614

1615
                        if (end)
112,608✔
1616
                        {
12,512✔
1617
                                break;
12,512✔
1618
                        }
1619

1620
                        this._reader.ReadNext();
100,096✔
1621
                }
100,096✔
1622
        }
12,512✔
1623

1624
        private void readCellMargin(CadCellStyleTemplate template)
1625
        {
2,992✔
1626
                var style = template.Format as TableStyle.CellStyle;
2,992✔
1627

1628
                this._reader.ReadNext();
2,992✔
1629

1630
                bool end = false;
2,992✔
1631
                int i = 0;
2,992✔
1632
                while (this._reader.DxfCode != DxfCode.Start)
23,936✔
1633
                {
23,936✔
1634
                        switch (this._reader.Code)
23,936!
1635
                        {
1636
                                case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,992!
1637
                                        break;
2,992✔
1638
                                case 40:
1639
                                        switch (i)
17,952✔
1640
                                        {
1641
                                                case 0:
1642
                                                        style.VerticalMargin = this._reader.ValueAsDouble;
2,992✔
1643
                                                        break;
2,992✔
1644
                                                case 1:
1645
                                                        style.HorizontalMargin = this._reader.ValueAsDouble;
2,992✔
1646
                                                        break;
2,992✔
1647
                                                case 2:
1648
                                                        style.BottomMargin = this._reader.ValueAsDouble;
2,992✔
1649
                                                        break;
2,992✔
1650
                                                case 3:
1651
                                                        style.RightMargin = this._reader.ValueAsDouble;
2,992✔
1652
                                                        break;
2,992✔
1653
                                                case 4:
1654
                                                        style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,992✔
1655
                                                        break;
2,992✔
1656
                                                case 5:
1657
                                                        style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,992✔
1658
                                                        break;
2,992✔
1659
                                        }
1660

1661
                                        i++;
17,952✔
1662
                                        break;
17,952✔
1663
                                case 309:
1664
                                        end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,992✔
1665
                                        break;
2,992✔
1666
                                default:
1667
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1668
                                        break;
×
1669
                        }
1670

1671
                        if (end)
23,936✔
1672
                        {
2,992✔
1673
                                break;
2,992✔
1674
                        }
1675

1676
                        this._reader.ReadNext();
20,944✔
1677
                }
20,944✔
1678
        }
2,992✔
1679

1680
        private void readCustomData()
1681
        {
8,500✔
1682
                this._reader.ReadNext();
8,500✔
1683

1684
                int ndata = 0;
8,500✔
1685
                bool end = false;
8,500✔
1686
                while (this._reader.DxfCode != DxfCode.Start)
79,084✔
1687
                {
78,948✔
1688
                        switch (this._reader.Code)
78,948✔
1689
                        {
1690
                                case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,500✔
1691
                                        break;
8,500✔
1692
                                case 90:
1693
                                        ndata = this._reader.ValueAsInt;
8,636✔
1694
                                        break;
8,636✔
1695
                                case 300:
1696
                                        //Name
1697
                                        break;
5,576✔
1698
                                case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,576✔
1699
                                        this.readDataMapValue();
5,576✔
1700
                                        break;
5,576✔
1701
                                case 309:
1702
                                        end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
8,364✔
1703
                                        break;
8,364✔
1704
                                default:
1705
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
42,296✔
1706
                                        break;
42,296✔
1707
                        }
1708

1709
                        if (end)
78,948✔
1710
                        {
8,364✔
1711
                                break;
8,364✔
1712
                        }
1713

1714
                        this._reader.ReadNext();
70,584✔
1715
                }
70,584✔
1716
        }
8,500✔
1717

1718
        private void readDataMapValue()
1719
        {
5,576✔
1720
                CadValue value = new();
5,576✔
1721
                var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
5,576✔
1722

1723
                this._reader.ReadNext();
5,576✔
1724

1725
                bool end = false;
5,576✔
1726
                while (this._reader.DxfCode != DxfCode.Start)
324,088✔
1727
                {
323,952✔
1728
                        switch (this._reader.Code)
323,952✔
1729
                        {
1730
                                case 11:
1731
                                case 21:
1732
                                case 31:
1733
                                        //Value as point
1734
                                        break;
408✔
1735
                                case 91:
1736
                                case 92:
1737
                                        //Value as int
1738
                                        break;
41,072✔
1739
                                case 140:
1740
                                        //Value as double
1741
                                        break;
13,532✔
1742
                                case 310:
1743
                                        //Value as byte array
1744
                                        break;
136✔
1745
                                case 304:
1746
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.ValueEnd, StringComparison.InvariantCultureIgnoreCase);
5,440✔
1747
                                        break;
5,440✔
1748
                                default:
1749
                                        if (!this.tryAssignCurrentValue(value, map))
263,364✔
1750
                                        {
149,056✔
1751
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
149,056✔
1752
                                        }
149,056✔
1753
                                        break;
263,364✔
1754
                        }
1755

1756
                        if (end)
323,952✔
1757
                        {
5,440✔
1758
                                break;
5,440✔
1759
                        }
1760

1761
                        this._reader.ReadNext();
318,512✔
1762
                }
318,512✔
1763
        }
5,576✔
1764

1765
        private bool readVisualStyle(CadTemplate template, DxfMap map)
1766
        {
424,228✔
1767
                switch (this._reader.Code)
424,228✔
1768
                {
1769
                        // Undocumented codes
1770
                        case 176:
1771
                        case 177:
1772
                        case 420:
1773
                                return true;
141,374✔
1774
                        default:
1775
                                //Avoid noise while is not implemented
1776
                                return true;
282,854✔
1777
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1778
                }
1779
        }
424,228✔
1780

1781
        private bool readSpatialFilter(CadTemplate template, DxfMap map)
1782
        {
4,284✔
1783
                CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,284✔
1784
                SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,284✔
1785

1786
                switch (this._reader.Code)
4,284✔
1787
                {
1788
                        case 10:
1789
                                filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
408✔
1790
                                return true;
408✔
1791
                        case 20:
1792
                                var pt = filter.BoundaryPoints.LastOrDefault();
408✔
1793
                                filter.BoundaryPoints[filter.BoundaryPoints.Count - 1] = new CSMath.XY(pt.X, this._reader.ValueAsDouble);
408✔
1794
                                return true;
408✔
1795
                        case 40:
1796
                                if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
408!
1797
                                {
×
1798
                                        filter.FrontDistance = this._reader.ValueAsDouble;
×
1799
                                        tmp.HasFrontPlane = true;
×
1800
                                        return true;
×
1801
                                }
1802

1803
                                double[] array = new double[16]
408✔
1804
                                {
408✔
1805
                                        0.0, 0.0, 0.0, 0.0,
408✔
1806
                                        0.0, 0.0, 0.0, 0.0,
408✔
1807
                                        0.0, 0.0, 0.0, 0.0,
408✔
1808
                                        0.0, 0.0, 0.0, 1.0
408✔
1809
                                };
408✔
1810

1811
                                for (int i = 0; i < 12; i++)
10,608✔
1812
                                {
4,896✔
1813
                                        array[i] = this._reader.ValueAsDouble;
4,896✔
1814

1815
                                        if (i < 11)
4,896✔
1816
                                        {
4,488✔
1817
                                                this._reader.ReadNext();
4,488✔
1818
                                        }
4,488✔
1819
                                }
4,896✔
1820

1821
                                if (tmp.InsertTransformRead)
408!
1822
                                {
×
1823
                                        filter.InsertTransform = new Matrix4(array);
×
1824
                                        tmp.InsertTransformRead = true;
×
1825
                                }
×
1826
                                else
1827
                                {
408✔
1828
                                        filter.InverseInsertTransform = new Matrix4(array);
408✔
1829
                                }
408✔
1830

1831
                                return true;
408✔
1832
                        case 73:
1833
                        default:
1834
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,060✔
1835
                }
1836
        }
4,284✔
1837

1838
        private bool readMLineStyle(CadTemplate template, DxfMap map)
1839
        {
3,852✔
1840
                var tmp = template as CadMLineStyleTemplate;
3,852✔
1841
                var mLineStyle = template.CadObject as MLineStyle;
3,852✔
1842

1843
                switch (this._reader.Code)
3,852✔
1844
                {
1845
                        case 6:
1846
                                var t = tmp.ElementTemplates.LastOrDefault();
456✔
1847
                                if (t == null)
456!
1848
                                {
×
1849
                                        return true;
×
1850
                                }
1851
                                t.LineTypeName = this._reader.ValueAsString;
456✔
1852
                                return true;
456✔
1853
                        case 49:
1854
                                MLineStyle.Element element = new MLineStyle.Element();
456✔
1855
                                CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
456✔
1856
                                element.Offset = this._reader.ValueAsDouble;
456✔
1857

1858
                                tmp.ElementTemplates.Add(elementTemplate);
456✔
1859
                                mLineStyle.AddElement(element);
456✔
1860
                                return true;
456✔
1861
                        default:
1862
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,940✔
1863
                }
1864
        }
3,852✔
1865

1866
        private bool readTableStyle(CadTemplate template, DxfMap map)
1867
        {
20,633✔
1868
                var tmp = template as CadTableStyleTemplate;
20,633✔
1869
                var style = tmp.CadObject;
20,633✔
1870
                var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
20,633✔
1871

1872
                switch (this._reader.Code)
20,633!
1873
                {
1874
                        case 7:
1875
                                tmp.CreateCurrentCellStyleTemplate();
684✔
1876
                                tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
684✔
1877
                                return true;
684✔
1878
                        case 94:
1879
                                cellStyle.Alignment = this._reader.ValueAsInt;
×
1880
                                return true;
×
1881
                        case 62:
1882
                                cellStyle.Color = new Color(this._reader.ValueAsShort);
684✔
1883
                                return true;
684✔
1884
                        case 63:
1885
                                cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
684✔
1886
                                return true;
684✔
1887
                        case 140:
1888
                                cellStyle.TextHeight = this._reader.ValueAsDouble;
684✔
1889
                                return true;
684✔
1890
                        case 170:
1891
                                cellStyle.CellAlignment = (TableStyle.CellAlignmentType)this._reader.ValueAsShort;
684✔
1892
                                return true;
684✔
1893
                        case 283:
1894
                                cellStyle.IsFillColorOn = this._reader.ValueAsBool;
684✔
1895
                                return true;
684✔
1896
                        case 90:
1897
                                cellStyle.Type = (TableStyle.CellStyleType)this._reader.ValueAsShort;
480✔
1898
                                return true;
480✔
1899
                        case 91:
1900
                                cellStyle.StyleClass = (TableStyle.CellStyleClass)this._reader.ValueAsShort;
480✔
1901
                                return true;
480✔
1902
                        case 1:
1903
                                //Undocumented
1904
                                return true;
444✔
1905
                        case 274:
1906
                                cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1907
                                return true;
684✔
1908
                        case 275:
1909
                                cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1910
                                return true;
684✔
1911
                        case 276:
1912
                                cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1913
                                return true;
684✔
1914
                        case 277:
1915
                                cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1916
                                return true;
684✔
1917
                        case 278:
1918
                                cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1919
                                return true;
684✔
1920
                        case 279:
1921
                                cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
684✔
1922
                                return true;
684✔
1923
                        case 284:
1924
                                cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1925
                                return true;
684✔
1926
                        case 285:
1927
                                cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1928
                                return true;
684✔
1929
                        case 286:
1930
                                cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1931
                                return true;
684✔
1932
                        case 287:
1933
                                cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1934
                                return true;
684✔
1935
                        case 288:
1936
                                cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1937
                                return true;
684✔
1938
                        case 289:
1939
                                cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
684✔
1940
                                return true;
684✔
1941
                        case 64:
1942
                                cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1943
                                return true;
684✔
1944
                        case 65:
1945
                                cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1946
                                return true;
684✔
1947
                        case 66:
1948
                                cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1949
                                return true;
684✔
1950
                        case 67:
1951
                                cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1952
                                return true;
684✔
1953
                        case 68:
1954
                                cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1955
                                return true;
684✔
1956
                        case 69:
1957
                                cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
684✔
1958
                                return true;
684✔
1959
                        default:
1960
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,813✔
1961
                }
1962
        }
20,633✔
1963

1964
        private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1965
        {
20,408✔
1966
                var tmp = template as CadMLeaderStyleTemplate;
20,408✔
1967

1968
                switch (this._reader.Code)
20,408✔
1969
                {
1970
                        case 179:
1971
                                return true;
238✔
1972
                        case 340:
1973
                                tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
444✔
1974
                                return true;
444✔
1975
                        case 342:
1976
                                tmp.MTextStyleHandle = this._reader.ValueAsHandle;
444✔
1977
                                return true;
444✔
1978
                        default:
1979
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
19,282✔
1980
                }
1981
        }
20,408✔
1982

1983
        private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1984
        {
24,022✔
1985
                CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
24,022✔
1986

1987
                switch (this._reader.Code)
24,022✔
1988
                {
1989
                        case 1:
1990
                                this._reader.ExpectedCode(70);
1,252✔
1991
                                this._reader.ExpectedCode(140);
1,252✔
1992
                                return true;
1,252✔
1993
                        default:
1994
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
22,770✔
1995
                }
1996
        }
24,022✔
1997

1998
        private bool readBlockElement(CadTemplate template, DxfMap map)
1999
        {
16,094✔
2000
                CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
16,094✔
2001

2002
                switch (this._reader.Code)
16,094✔
2003
                {
2004
                        default:
2005
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
16,094✔
2006
                                {
14,006✔
2007
                                        return this.readEvaluationExpression(template, map);
14,006✔
2008
                                }
2009
                                return true;
2,088✔
2010
                }
2011
        }
16,094✔
2012

2013
        private bool readBlockAction(CadTemplate template, DxfMap map)
2014
        {
3,988✔
2015
                CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
3,988✔
2016

2017
                switch (this._reader.Code)
3,988✔
2018
                {
2019
                        case 71:
2020
                int nentities = this._reader.ValueAsInt;
210✔
2021
                                for (int i = 0; i < nentities; i++)
848✔
2022
                                {
214✔
2023
                                        this._reader.ReadNext();
214✔
2024
                                        tmp.EntityHandles.Add(this._reader.ValueAsHandle);
214✔
2025
                                }
214✔
2026
                                return true;
210✔
2027
                        default:
2028
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
3,778✔
2029
                                {
2,938✔
2030
                                        return this.readBlockElement(template, map);
2,938✔
2031
                                }
2032
                                return true;
840✔
2033
                }
2034
        }
3,988✔
2035

2036
        private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
2037
        {
6,240✔
2038
                CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
6,240✔
2039
                BlockActionBasePt action = tmp.CadObject as BlockActionBasePt;
6,240✔
2040

2041
                switch (this._reader.Code)
6,240✔
2042
                {
2043
                        case 92:
2044
                                action.UpdateBaseX.Id = this._reader.ValueAsInt;
208✔
2045
                                return true;
208✔
2046
                        case 93:
2047
                                action.UpdateBaseY.Id = this._reader.ValueAsInt;
208✔
2048
                                return true;
208✔
2049
                        case 301:
2050
                                action.UpdateBaseX.Name = this._reader.ValueAsString;
208✔
2051
                                return true;
208✔
2052
                        case 302:
2053
                                action.UpdateBaseY.Name = this._reader.ValueAsString;
208✔
2054
                                return true;
208✔
2055
                        default:
2056
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
5,408✔
2057
                                {
3,952✔
2058
                                        return this.readBlockAction(template, map);
3,952✔
2059
                                }
2060
                                return true;
1,456✔
2061
                }
2062
        }
6,240✔
2063

2064
        private bool readBlockPointParameter(CadTemplate template, DxfMap map)
2065
        {
56✔
2066
                CadBlockPointParameterTemplate tmp = template as CadBlockPointParameterTemplate;
56✔
2067
                BlockPointParameter action = tmp.CadObject as BlockPointParameter;
56✔
2068

2069
                switch (this._reader.Code)
56✔
2070
                {
2071
                        default:
2072
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockPointParameter]))
56✔
2073
                                {
46✔
2074
                                        return this.readBlock1PtParameter(template, map);
46✔
2075
                                }
2076
                                return true;
10✔
2077
                }
2078
        }
56✔
2079

2080
        private bool readBlockScaleAction(CadTemplate template, DxfMap map)
2081
        {
7,416✔
2082
                CadBlockScaleActionTemplate tmp = template as CadBlockScaleActionTemplate;
7,416✔
2083
                BlockScaleAction action = tmp.CadObject as BlockScaleAction;
7,416✔
2084

2085
                switch (this._reader.Code)
7,416✔
2086
                {
2087
                        // Unsorted connections
2088
                        case 94:
2089
                                action.ScaleConnection.Id = this._reader.ValueAsInt;
206✔
2090
                                return true;
206✔
2091
                        case 95:
2092
                                action.XScaleConnection.Id = this._reader.ValueAsInt;
206✔
2093
                                return true;
206✔
2094
                        case 96:
2095
                                action.YScaleConnection.Id = this._reader.ValueAsInt;
206✔
2096
                                return true;
206✔
2097
                        case 303:
2098
                                action.ScaleConnection.Name = this._reader.ValueAsString;
206✔
2099
                                return true;
206✔
2100
                        case 304:
2101
                                action.XScaleConnection.Name = this._reader.ValueAsString;
206✔
2102
                                return true;
206✔
2103
                        case 305:
2104
                                action.YScaleConnection.Name = this._reader.ValueAsString;
206✔
2105
                                return true;
206✔
2106
                        default:
2107
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockScaleAction]))
6,180!
2108
                                {
6,180✔
2109
                                        return this.readBlockActionBasePt(template, map);
6,180✔
2110
                                }
NEW
2111
                                return true;
×
2112
                }
2113
        }
7,416✔
2114

2115
        private bool readBlockMoveAction(CadTemplate template, DxfMap map)
2116
        {
46✔
2117
                CadBlockMoveActionTemplate tmp = template as CadBlockMoveActionTemplate;
46✔
2118
                BlockMoveAction action = tmp.CadObject as BlockMoveAction;
46✔
2119

2120
                switch (this._reader.Code)
46✔
2121
                {
2122
                        case 92:
2123
                                action.XDelta = this.readEvalConnection();
2✔
2124
                                return true;
2✔
2125
                        case 93:
2126
                                action.YDelta = this.readEvalConnection();
2✔
2127
                                return true;
2✔
2128
                        default:
2129
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockMoveAction]))
42✔
2130
                                {
36✔
2131
                                        return this.readBlockAction(template, map);
36✔
2132
                                }
2133
                                return true;
6✔
2134
                }
2135
        }
46✔
2136

2137
        private bool readBlockRotationAction(CadTemplate template, DxfMap map)
2138
        {
64✔
2139
                CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
64✔
2140

2141
                switch (this._reader.Code)
64✔
2142
                {
2143
                        default:
2144
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
64✔
2145
                                {
60✔
2146
                                        return this.readBlockActionBasePt(template, map);
60✔
2147
                                }
2148
                                return true;
4✔
2149
                }
2150
        }
64✔
2151

2152
        private bool readBlockParameter(CadTemplate template, DxfMap map)
2153
        {
5,258✔
2154
                CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
5,258✔
2155

2156
                switch (this._reader.Code)
5,258✔
2157
                {
2158
                        default:
2159
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
5,258✔
2160
                                {
5,044✔
2161
                                        return this.readBlockElement(template, map);
5,044✔
2162
                                }
2163
                                return true;
214✔
2164
                }
2165
        }
5,258✔
2166

2167
        private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
2168
        {
4,212✔
2169
                CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,212✔
2170

2171
                switch (this._reader.Code)
4,212✔
2172
                {
2173
                        case 170:
2174
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementX);
210✔
2175
                                return true;
210✔
2176
                        case 171:
2177
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementY);
210✔
2178
                                return true;
210✔
2179
                        default:
2180
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
3,792✔
2181
                                {
3,158✔
2182
                                        return this.readBlockParameter(template, map);
3,158✔
2183
                                }
2184
                                return true;
634✔
2185
                }
2186
        }
4,212✔
2187

2188
        private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
2189
        {
3,150✔
2190
                var tmp = template as CadBlock2PtParameterTemplate;
3,150✔
2191

2192
                switch (this._reader.Code)
3,150✔
2193
                {
2194
                        case 170:
2195
                                short n = this._reader.ValueAsShort;
210✔
2196
                                for (int i = 0; i < n; i++)
2,100✔
2197
                                {
840✔
2198
                                        this._reader.ReadNext();
840✔
2199
                                        tmp.Block2PtParameter.GripIds[i] = this._reader.ValueAsShort;
840✔
2200
                                }
840✔
2201
                                return true;
210✔
2202
                        case 171:
2203
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementX);
210✔
2204
                                return true;
210✔
2205
                        case 172:
2206
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementY);
210✔
2207
                                return true;
210✔
2208
                        case 173:
2209
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementX);
210✔
2210
                                return true;
210✔
2211
                        case 174:
2212
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementY);
210✔
2213
                                return true;
210✔
2214
                        default:
2215
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
2,100!
2216
                                {
2,100✔
2217
                                        return this.readBlockParameter(template, map);
2,100✔
2218
                                }
2219
                                return true;
×
2220
                }
2221
        }
3,150✔
2222

2223
        private void readEvalParameterProperty(EvalParameterProperty property)
2224
        {
1,260✔
2225
                short nconnections = this._reader.ValueAsShort;
1,260✔
2226
                for (; nconnections > 0; nconnections--)
2,932✔
2227
                {
836✔
2228
                        this._reader.ReadNext();
836✔
2229
                        property.Connections.Add(this.readEvalConnection());
836✔
2230
                }
836✔
2231
        }
1,260✔
2232

2233
        private EvalConnection readEvalConnection()
2234
        {
840✔
2235
                EvalConnection connection = new EvalConnection();
840✔
2236
                // No dynamic reader for codes 9x and 30x
2237
                connection.Id = this._reader.ValueAsLong;
840✔
2238
                this._reader.ReadNext();
840✔
2239
                connection.Name = this._reader.ValueAsString;
840✔
2240

2241
                return connection;
840✔
2242
        }
840✔
2243

2244
        private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
2245
        {
5,768✔
2246
                CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,768✔
2247

2248
                switch (this._reader.Code)
5,768✔
2249
                {
2250
                        case 92:
2251
                                var stateCount = this._reader.ValueAsInt;
206✔
2252
                                for (int i = 0; i < stateCount; i++)
2,060✔
2253
                                {
824✔
2254
                                        this._reader.ReadNext();
824✔
2255
                                        tmp.StateTemplates.Add(this.readState());
824✔
2256
                                }
824✔
2257
                                return true;
206✔
2258
                        case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
412✔
2259
                                var entityCount = this._reader.ValueAsInt;
206✔
2260
                                for (int i = 0; i < entityCount; i++)
840✔
2261
                                {
214✔
2262
                                        this._reader.ReadNext();
214✔
2263
                                        tmp.EntityHandles.Add(this._reader.ValueAsHandle);
214✔
2264
                                }
214✔
2265
                                return true;
206✔
2266
                        default:
2267
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,356✔
2268
                                {
4,120✔
2269
                                        return this.readBlock1PtParameter(template, map);
4,120✔
2270
                                }
2271
                                return true;
1,236✔
2272
                }
2273
        }
5,768✔
2274

2275
        private bool readBlockLinearParameter(CadTemplate template, DxfMap map)
2276
        {
6,864✔
2277
                var tmp = template as CadBlockLinearParameterTemplate;
6,864✔
2278
                var linearPrameter = tmp.CadObject as BlockLinearParameter;
6,864✔
2279

2280
                switch (this._reader.Code)
6,864✔
2281
                {
2282
                        case 307:
2283
                                linearPrameter.ValueSet = this.readParameterValueSet();
208✔
2284
                                return true;
208✔
2285
                        default:
2286
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
6,656✔
2287
                                {
3,120✔
2288
                                        return this.readBlock2PtParameter(template, map);
3,120✔
2289
                                }
2290
                                return true;
3,536✔
2291
                }
2292
        }
6,864✔
2293

2294
        private ParameterValueSet readParameterValueSet()
2295
        {
208✔
2296
                ParameterValueSet valueSet = new ParameterValueSet();
208✔
2297

2298
                //First 3xx value unknown
2299
                var unknown = this._reader.ValueAsString;
208✔
2300

2301
                this._reader.ReadNext();
208✔
2302
                valueSet.Type = (ParameterValueSetType)this._reader.ValueAsInt;
208✔
2303
                this._reader.ReadNext();
208✔
2304
                valueSet.Minimum = this._reader.ValueAsDouble;
208✔
2305
                this._reader.ReadNext();
208✔
2306
                valueSet.Maximum = this._reader.ValueAsDouble;
208✔
2307
                this._reader.ReadNext();
208✔
2308
                valueSet.Increment = this._reader.ValueAsDouble;
208✔
2309

2310
                this._reader.ReadNext();
208✔
2311
                int n = this._reader.ValueAsInt;
208✔
2312
                for (int i = 0; i < n; i++)
416!
NEW
2313
                {
×
NEW
2314
                        this._reader.ReadNext();
×
NEW
2315
                        valueSet.AllowedValues.Add(this._reader.ValueAsDouble);
×
NEW
2316
                }
×
2317

2318
                return valueSet;
208✔
2319
        }
208✔
2320

2321
        private bool readBlockLookupParameter(CadTemplate template, DxfMap map)
2322
        {
52✔
2323
                switch (this._reader.Code)
52✔
2324
                {
2325
                        default:
2326
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLookupParameter]))
52✔
2327
                                {
46✔
2328
                                        return this.readBlock1PtParameter(template, map);
46✔
2329
                                }
2330
                                return true;
6✔
2331
                }
2332
        }
52✔
2333

2334
        private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
2335
        {
82✔
2336
                var tmp = template as CadBlockRotationParameterTemplate;
82✔
2337

2338
                switch (this._reader.Code)
82✔
2339
                {
2340
                        default:
2341
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
82✔
2342
                                {
30✔
2343
                                        return this.readBlock2PtParameter(template, map);
30✔
2344
                                }
2345
                                return true;
52✔
2346
                }
2347
        }
82✔
2348

2349
        private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2350
        {
824✔
2351
                var state = new BlockVisibilityParameter.State();
824✔
2352
                var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
824✔
2353

2354
                List<int> expectedCodes = new List<int>();
824✔
2355
                expectedCodes.Add(303);
824✔
2356
                expectedCodes.Add(94);
824✔
2357
                expectedCodes.Add(95);
824✔
2358

2359
                while (this._reader.DxfCode != DxfCode.Start)
2,472✔
2360
                {
2,472✔
2361
                        expectedCodes.Remove(this._reader.Code);
2,472✔
2362

2363
                        switch (this._reader.Code)
2,472!
2364
                        {
2365
                                case 303:
2366
                                        state.Name = this._reader.ValueAsString;
824✔
2367
                                        break;
824✔
2368
                                case 94:
2369
                                        var count = this._reader.ValueAsInt;
824✔
2370
                                        for (int i = 0; i < count; i++)
2,920✔
2371
                                        {
636✔
2372
                                                this._reader.ReadNext();
636✔
2373
                                                template.EntityHandles.Add(this._reader.ValueAsHandle);
636✔
2374
                                        }
636✔
2375
                                        break;
824✔
2376
                                case 95:
2377
                                        count = this._reader.ValueAsInt;
824✔
2378
                                        for (int i = 0; i < count; i++)
6,544✔
2379
                                        {
2,448✔
2380
                                                this._reader.ReadNext();
2,448✔
2381
                                                template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,448✔
2382
                                        }
2,448✔
2383
                                        break;
824✔
2384
                                default:
2385
                                        return template;
×
2386
                        }
2387

2388
                        if (!expectedCodes.Any())
2,472✔
2389
                        {
824✔
2390
                                break;
824✔
2391
                        }
2392

2393
                        this._reader.ReadNext();
1,648✔
2394
                }
1,648✔
2395

2396
                return template;
824✔
2397
        }
824✔
2398

2399
        private bool readBlockGrip(CadTemplate template, DxfMap map)
2400
        {
12,480✔
2401
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
12,480✔
2402

2403
                switch (this._reader.Code)
12,480✔
2404
                {
2405
                        default:
2406
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
12,480✔
2407
                                {
8,112✔
2408
                                        return this.readBlockElement(template, map);
8,112✔
2409
                                }
2410
                                return true;
4,368✔
2411
                }
2412
        }
12,480✔
2413

2414
        private bool readBlockGripSubclass(CadTemplate template, DxfMap map)
2415
        {
13,722✔
2416
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
13,722✔
2417

2418
                switch (this._reader.Code)
13,722✔
2419
                {
2420
                        default:
2421
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]))
13,722✔
2422
                                {
12,480✔
2423
                                        return this.readBlockGrip(template, map);
12,480✔
2424
                                }
2425
                                return true;
1,242✔
2426
                }
2427
        }
13,722✔
2428

2429
        private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
2430
        {
1,800✔
2431
                CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,800✔
2432

2433
                switch (this._reader.Code)
1,800✔
2434
                {
2435
                        case 340:
2436
                                tmp.BlockHandle = this._reader.ValueAsHandle;
300✔
2437
                                return true;
300✔
2438
                        default:
2439
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,500✔
2440
                }
2441
        }
1,800✔
2442

2443
        private bool readBlockGripExpression(CadTemplate template, DxfMap map)
2444
        {
12,520✔
2445
                CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
12,520✔
2446

2447
                switch (this._reader.Code)
12,520✔
2448
                {
2449
                        default:
2450
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
12,520✔
2451
                                {
10,016✔
2452
                                        return this.readEvaluationExpression(template, map);
10,016✔
2453
                                }
2454
                                return true;
2,504✔
2455
                }
2456
        }
12,520✔
2457

2458
        private bool readXRecord(CadTemplate template, DxfMap map)
2459
        {
120,784✔
2460
                CadXRecordTemplate tmp = template as CadXRecordTemplate;
120,784✔
2461

2462
                switch (this._reader.Code)
120,784✔
2463
                {
2464
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
30,842✔
2465
                                this.readXRecordEntries(tmp);
30,842✔
2466
                                return true;
30,842✔
2467
                        default:
2468
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
89,942✔
2469
                }
2470
        }
120,784✔
2471

2472
        private void readXRecordEntries(CadXRecordTemplate template)
2473
        {
30,842✔
2474
                this._reader.ReadNext();
30,842✔
2475

2476
                while (this._reader.DxfCode != DxfCode.Start)
2,561,032✔
2477
                {
2,530,190✔
2478
                        switch (this._reader.GroupCodeValue)
2,530,190✔
2479
                        {
2480
                                case GroupCodeValueType.Point3D:
2481
                                        var code = this._reader.Code;
3,142✔
2482
                                        var x = this._reader.ValueAsDouble;
3,142✔
2483
                                        this._reader.ReadNext();
3,142✔
2484
                                        var y = this._reader.ValueAsDouble;
3,142✔
2485
                                        this._reader.ReadNext();
3,142✔
2486
                                        var z = this._reader.ValueAsDouble;
3,142✔
2487
                                        XYZ pt = new XYZ(x, y, z);
3,142✔
2488
                                        template.CadObject.CreateEntry(code, pt);
3,142✔
2489
                                        break;
3,142✔
2490
                                case GroupCodeValueType.Handle:
2491
                                case GroupCodeValueType.ObjectId:
2492
                                case GroupCodeValueType.ExtendedDataHandle:
2493
                                        template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,800✔
2494
                                        break;
12,800✔
2495
                                default:
2496
                                        template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,514,248✔
2497
                                        break;
2,514,248✔
2498
                        }
2499

2500
                        this._reader.ReadNext();
2,530,190✔
2501
                }
2,530,190✔
2502
        }
30,842✔
2503

2504
        private bool readBookColor(CadTemplate template, DxfMap map)
2505
        {
1,462✔
2506
                CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,462✔
2507
                BookColor color = tmp.CadObject as BookColor;
1,462✔
2508

2509
                switch (this._reader.Code)
1,462✔
2510
                {
2511
                        case 430:
2512
                                color.Name = this._reader.ValueAsString;
170✔
2513
                                return true;
170✔
2514
                        default:
2515
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,292✔
2516
                }
2517
        }
1,462✔
2518

2519
        private bool readDimensionAssociation(CadTemplate template, DxfMap map)
2520
        {
5,712✔
2521
                CadDimensionAssociationTemplate tmp = template as CadDimensionAssociationTemplate;
5,712✔
2522
                DimensionAssociation dimassoc = tmp.CadObject;
5,712✔
2523

2524
                switch (this._reader.Code)
5,712✔
2525
                {
2526
                        case 1 when this._reader.ValueAsString.Equals(DimensionAssociation.OsnapPointRefClassName):
816✔
2527
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FirstPointReference)
816✔
2528
                                        && dimassoc.FirstPointRef == null)
816✔
2529
                                {
204✔
2530
                                        dimassoc.FirstPointRef = new DimensionAssociation.OsnapPointRef();
204✔
2531
                                        this.readOsnapPointRef(dimassoc.FirstPointRef);
204✔
2532
                                        this.lockPointer = true;
204✔
2533
                                        return true;
204✔
2534
                                }
2535

2536
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.SecondPointReference)
612!
2537
                                        && dimassoc.SecondPointRef == null)
612✔
2538
                                {
612✔
2539
                                        dimassoc.SecondPointRef = new DimensionAssociation.OsnapPointRef();
612✔
2540
                                        this.readOsnapPointRef(dimassoc.SecondPointRef);
612✔
2541
                                        this.lockPointer = true;
612✔
2542
                                        return true;
612✔
2543
                                }
2544

2545
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.ThirdPointReference)
×
2546
                                        && dimassoc.ThirdPointRef == null)
×
2547
                                {
×
2548
                                        dimassoc.ThirdPointRef = new DimensionAssociation.OsnapPointRef();
×
2549
                                        this.readOsnapPointRef(dimassoc.ThirdPointRef);
×
2550
                                        this.lockPointer = true;
×
2551
                                        return true;
×
2552
                                }
2553

2554
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FourthPointReference)
×
2555
                                        && dimassoc.FourthPointRef == null)
×
2556
                                {
×
2557
                                        dimassoc.FourthPointRef = new DimensionAssociation.OsnapPointRef();
×
2558
                                        this.readOsnapPointRef(dimassoc.FourthPointRef);
×
2559
                                        this.lockPointer = true;
×
2560
                                        return true;
×
2561
                                }
2562

2563
                                return true;
×
2564
                        case 330 when template.OwnerHandle.HasValue:
1,224✔
2565
                                tmp.DimensionHandle = this._reader.ValueAsHandle;
612✔
2566
                                return true;
612✔
2567
                        default:
2568
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
4,284✔
2569
                }
2570
        }
5,712✔
2571

2572
        private CadDimensionAssociationTemplate.OsnapPointRefTemplate readOsnapPointRef(DimensionAssociation.OsnapPointRef osnapPoint)
2573
        {
816✔
2574
                var template = new CadDimensionAssociationTemplate.OsnapPointRefTemplate(osnapPoint);
816✔
2575

2576
                this._reader.ReadNext();
816✔
2577

2578
                bool end = false;
816✔
2579
                while (!end)
8,976✔
2580
                {
8,160✔
2581
                        switch (this._reader.Code)
8,160!
2582
                        {
2583
                                case 10:
2584
                                        osnapPoint.OsnapPoint = new XYZ(
816✔
2585
                                                this._reader.ValueAsDouble,
816✔
2586
                                                osnapPoint.OsnapPoint.Y,
816✔
2587
                                                osnapPoint.OsnapPoint.Z
816✔
2588
                                                );
816✔
2589
                                        break;
816✔
2590
                                case 20:
2591
                                        osnapPoint.OsnapPoint = new XYZ(
816✔
2592
                                                osnapPoint.OsnapPoint.X,
816✔
2593
                                                this._reader.ValueAsDouble,
816✔
2594
                                                osnapPoint.OsnapPoint.Z
816✔
2595
                                                );
816✔
2596
                                        break;
816✔
2597
                                case 30:
2598
                                        osnapPoint.OsnapPoint = new XYZ(
816✔
2599
                                        osnapPoint.OsnapPoint.X,
816✔
2600
                                        osnapPoint.OsnapPoint.Y,
816✔
2601
                                        this._reader.ValueAsDouble
816✔
2602
                                        );
816✔
2603
                                        break;
816✔
2604
                                case 40:
2605
                                        osnapPoint.GeometryParameter = this._reader.ValueAsDouble;
816✔
2606
                                        break;
816✔
2607
                                case 72:
2608
                                        osnapPoint.ObjectOsnapType = (ObjectOsnapType)this._reader.ValueAsShort;
816✔
2609
                                        break;
816✔
2610
                                case 73:
2611
                                        osnapPoint.SubentType = (SubentType)this._reader.ValueAsShort;
816✔
2612
                                        break;
816✔
2613
                                case 74:
2614
                                        osnapPoint.IntersectionSubType = (SubentType)this._reader.ValueAsShort;
×
2615
                                        break;
×
2616
                                case 75:
2617
                                        osnapPoint.HasLastPointRef = this._reader.ValueAsBool;
816✔
2618
                                        break;
816✔
2619
                                case 91:
2620
                                        osnapPoint.GsMarker = this._reader.ValueAsInt;
816✔
2621
                                        break;
816✔
2622
                                case 92:
2623
                                        osnapPoint.IntersectionGsMarker = this._reader.ValueAsInt;
×
2624
                                        break;
×
2625
                                case 331:
2626
                                        template.ObjectHandle = this._reader.ValueAsHandle;
816✔
2627
                                        break;
816✔
2628
                                case 302:
2629
                                case 332:
2630
                                        //What are these?
2631
                                        break;
×
2632
                                default:
2633
                                        end = true;
816✔
2634
                                        continue;
816✔
2635
                        }
2636

2637
                        this._reader.ReadNext();
7,344✔
2638
                }
7,344✔
2639

2640
                return template;
816✔
2641
        }
816✔
2642

2643
        private bool readDictionary(CadTemplate template, DxfMap map)
2644
        {
241,017✔
2645
                CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
241,017✔
2646
                CadDictionary cadDictionary = tmp.CadObject;
241,017✔
2647

2648
                switch (this._reader.Code)
241,017✔
2649
                {
2650
                        case 280:
2651
                                cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
16,153✔
2652
                                return true;
16,153✔
2653
                        case 281:
2654
                                cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,116✔
2655
                                return true;
23,116✔
2656
                        case 3:
2657
                                tmp.Entries.Add(this._reader.ValueAsString, null);
61,707✔
2658
                                return true;
61,707✔
2659
                        case 350: // Soft-owner ID/handle to entry object 
2660
                        case 360: // Hard-owner ID/handle to entry object
2661
                                tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
61,707✔
2662
                                return true;
61,707✔
2663
                        default:
2664
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
78,334✔
2665
                }
2666
        }
241,017✔
2667

2668
        private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
2669
        {
1,944✔
2670
                CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,944✔
2671

2672
                switch (this._reader.Code)
1,944✔
2673
                {
2674
                        case 340:
2675
                                tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
216✔
2676
                                return true;
216✔
2677
                        default:
2678
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,728!
2679
                                {
1,728✔
2680
                                        return this.readDictionary(template, map);
1,728✔
2681
                                }
2682
                                return true;
×
2683
                }
2684
        }
1,944✔
2685

2686
        private CadTemplate readSortentsTable()
2687
        {
612✔
2688
                SortEntitiesTable sortTable = new SortEntitiesTable();
612✔
2689
                CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
612✔
2690

2691
                //Jump the 0 marker
2692
                this._reader.ReadNext();
612✔
2693

2694
                this.readCommonObjectData(template);
612✔
2695

2696
                System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
612✔
2697

2698
                //Jump the 100 marker
2699
                this._reader.ReadNext();
612✔
2700

2701
                (ulong?, ulong?) pair = (null, null);
612✔
2702

2703
                while (this._reader.DxfCode != DxfCode.Start)
4,488✔
2704
                {
3,876✔
2705
                        switch (this._reader.Code)
3,876!
2706
                        {
2707
                                case 5:
2708
                                        pair.Item1 = this._reader.ValueAsHandle;
1,632✔
2709
                                        break;
1,632✔
2710
                                case 330:
2711
                                        template.BlockOwnerHandle = this._reader.ValueAsHandle;
612✔
2712
                                        break;
612✔
2713
                                case 331:
2714
                                        pair.Item2 = this._reader.ValueAsHandle;
1,632✔
2715
                                        break;
1,632✔
2716
                                default:
2717
                                        this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2718
                                        break;
×
2719
                        }
2720

2721
                        if (pair.Item1.HasValue && pair.Item2.HasValue)
3,876✔
2722
                        {
1,632✔
2723
                                template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,632✔
2724
                                pair = (null, null);
1,632✔
2725
                        }
1,632✔
2726

2727
                        this._reader.ReadNext();
3,876✔
2728
                }
3,876✔
2729

2730
                return template;
612✔
2731
        }
612✔
2732
}
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