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

DomCR / ACadSharp / 29367200743

14 Jul 2026 08:49PM UTC coverage: 76.439% (+0.5%) from 75.954%
29367200743

Pull #1151

github

web-flow
Merge 20f42abbc into d44113e43
Pull Request #1151: DxfWriter - Dynamic parameters

9314 of 13143 branches covered (70.87%)

Branch coverage included in aggregate %.

645 of 736 new or added lines in 27 files covered. (87.64%)

17 existing lines in 6 files now uncovered.

33200 of 42475 relevant lines covered (78.16%)

154427.35 hits per line

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

84.01
/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

16
namespace ACadSharp.IO.DXF.DxfStreamReader;
17

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

194
                while (this._reader.DxfCode != DxfCode.Start)
1,172,418✔
195
                {
1,092,532✔
196
                        if (!readObject(template, map))
1,092,532✔
197
                        {
260,417✔
198
                                this.readCommonCodes(template, out bool isExtendedData, map);
260,417✔
199
                                if (isExtendedData)
260,417✔
200
                                        continue;
3,391✔
201
                        }
257,026✔
202

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

876

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1278
                this._reader.ReadNext();
×
1279

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1802
                                double[] array = new double[16]
408✔
1803
                                {
408✔
1804
                                        0.0, 0.0, 0.0, 0.0,
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, 1.0
408✔
1808
                                };
408✔
1809

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2187
        private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
2188
        {
6,068✔
2189
                var tmp = template as CadBlock2PtParameterTemplate;
6,068✔
2190

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

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

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

2240
                return connection;
840✔
2241
        }
840✔
2242

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

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

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

2279
                switch (this._reader.Code)
6,864✔
2280
                {
2281
                        case 307:
2282
                                linearPrameter.ValueSet = this.readParameterValueSet();
208✔
2283
                                return true;
208✔
2284
                        default:
2285
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLinearParameter]))
6,656✔
2286
                                {
6,032✔
2287
                                        return this.readBlock2PtParameter(template, map);
6,032✔
2288
                                }
2289
                                return true;
624✔
2290
                }
2291
        }
6,864✔
2292

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

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

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

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

2317
                return valueSet;
208✔
2318
        }
208✔
2319

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

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

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

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

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

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

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

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

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

2395
                return template;
824✔
2396
        }
824✔
2397

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2639
                return template;
816✔
2640
        }
816✔
2641

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

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

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

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

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

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

2693
                this.readCommonObjectData(template);
612✔
2694

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

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

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

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

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

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

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