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

DomCR / ACadSharp / 30620456288

31 Jul 2026 09:34AM UTC coverage: 76.801% (+1.0%) from 75.789%
30620456288

Pull #1151

github

web-flow
Merge 0ffbbdb89 into 25e85fe17
Pull Request #1151: Dynamic parameters

9806 of 13766 branches covered (71.23%)

Branch coverage included in aggregate %.

2995 of 3452 new or added lines in 70 files covered. (86.76%)

74 existing lines in 12 files now uncovered.

34910 of 44457 relevant lines covered (78.53%)

142256.06 hits per line

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

84.84
/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)
226✔
24
        {
226✔
25
        }
226✔
26

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

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

37
                        try
38
                        {
79,827✔
39
                                template = this.readObject();
79,827✔
40
                        }
79,827✔
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)
79,827✔
53
                                continue;
×
54

55
                        //Add the object and the template to the builder
56
                        this._builder.AddTemplate(template);
79,827✔
57
                }
79,827✔
58
        }
226✔
59

60
        protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
61
                where T : CadObject
62
        {
76,687✔
63
                this._reader.ReadNext();
76,687✔
64

65
                DxfMap map = DxfMap.Create<T>();
76,687✔
66

67
                while (this._reader.DxfCode != DxfCode.Start)
1,153,415✔
68
                {
1,076,728✔
69
                        if (!readObject(template, map))
1,076,728✔
70
                        {
249,935✔
71
                                this.readCommonCodes(template, out bool isExtendedData, map);
249,935✔
72
                                if (isExtendedData)
249,935✔
73
                                        continue;
3,213✔
74
                        }
246,722✔
75

76
                        if (this.lockPointer)
1,073,515✔
77
                        {
2,598✔
78
                                this.lockPointer = false;
2,598✔
79
                                continue;
2,598✔
80
                        }
81

82
                        if (this._reader.DxfCode != DxfCode.Start)
1,070,917✔
83
                        {
1,041,727✔
84
                                this._reader.ReadNext();
1,041,727✔
85
                        }
1,041,727✔
86
                }
1,070,917✔
87

88
                return template;
76,687✔
89
        }
76,687✔
90

91
        private bool readAnnotScaleObjectContextData(CadTemplate template, DxfMap map)
92
        {
×
NEW
93
                var tmp = template as CadAnnotScaleObjectContextDataTemplate;
×
UNCOV
94
                switch (this._reader.Code)
×
95
                {
96
                        case 340:
NEW
97
                                tmp.ScaleHandle = this._reader.ValueAsHandle;
×
UNCOV
98
                                return true;
×
99
                        default:
NEW
100
                                if (string.IsNullOrEmpty(this.currentSubclass))
×
NEW
101
                                {
×
NEW
102
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
103
                                }
104
                                else
NEW
105
                                {
×
NEW
106
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
107
                                }
108
                }
109
        }
×
110

111
        private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
112
        {
4,108✔
113
                CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
4,108✔
114

115
                switch (this._reader.Code)
4,108✔
116
                {
117
                        case 170:
118
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementX);
204✔
119
                                return true;
204✔
120
                        case 171:
121
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementY);
204✔
122
                                return true;
204✔
123
                        default:
124
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
3,700✔
125
                                {
3,078✔
126
                                        return this.readBlockParameter(template, map);
3,078✔
127
                                }
128
                                return true;
622✔
129
                }
130
        }
4,108✔
131

132
        private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
133
        {
6,734✔
134
                var tmp = template as CadBlock2PtParameterTemplate;
6,734✔
135

136
                switch (this._reader.Code)
6,734✔
137
                {
138
                        case 91:
139
                                tmp.Block2PtParameter.GripIds.Add(this._reader.ValueAsLong);
824✔
140
                                return true;
824✔
141
                        case 171:
142
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementX);
206✔
143
                                return true;
206✔
144
                        case 172:
145
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementY);
206✔
146
                                return true;
206✔
147
                        case 173:
148
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementX);
206✔
149
                                return true;
206✔
150
                        case 174:
151
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementY);
206✔
152
                                return true;
206✔
153
                        default:
154
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
5,086✔
155
                                {
2,058✔
156
                                        return this.readBlockParameter(template, map);
2,058✔
157
                                }
158
                                return true;
3,028✔
159
                }
160
        }
6,734✔
161

162
        private bool readBlockAction(CadTemplate template, DxfMap map)
163
        {
3,976✔
164
                CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
3,976✔
165

166
                switch (this._reader.Code)
3,976✔
167
                {
168
                        case 71:
169
                                int nentities = this._reader.ValueAsInt;
210✔
170
                                for (int i = 0; i < nentities; i++)
852✔
171
                                {
216✔
172
                                        this._reader.ReadNext();
216✔
173
                                        tmp.EntityHandles.Add(this._reader.ValueAsHandle);
216✔
174
                                }
216✔
175
                                return true;
210✔
176
                        default:
177
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
3,766✔
178
                                {
2,926✔
179
                                        return this.readBlockElement(template, map);
2,926✔
180
                                }
181
                                return true;
840✔
182
                }
183
        }
3,976✔
184

185
        private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
186
        {
5,880✔
187
                CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
5,880✔
188
                BlockActionBasePt action = tmp.CadObject as BlockActionBasePt;
5,880✔
189

190
                switch (this._reader.Code)
5,880✔
191
                {
192
                        case 92:
193
                                action.UpdateBaseXConnection.Id = this._reader.ValueAsInt;
196✔
194
                                return true;
196✔
195
                        case 93:
196
                                action.UpdateBaseYConnection.Id = this._reader.ValueAsInt;
196✔
197
                                return true;
196✔
198
                        case 301:
199
                                action.UpdateBaseXConnection.Name = this._reader.ValueAsString;
196✔
200
                                return true;
196✔
201
                        case 302:
202
                                action.UpdateBaseYConnection.Name = this._reader.ValueAsString;
196✔
203
                                return true;
196✔
204
                        default:
205
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
5,096✔
206
                                {
3,724✔
207
                                        return this.readBlockAction(template, map);
3,724✔
208
                                }
209
                                return true;
1,372✔
210
                }
211
        }
5,880✔
212

213
        private bool readBlockAlignmentParameter(CadTemplate template, DxfMap map)
214
        {
66✔
215
                switch (this._reader.Code)
66✔
216
                {
217
                        default:
218
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAlignmentParameter]))
66✔
219
                                {
62✔
220
                                        return this.readBlock2PtParameter(template, map);
62✔
221
                                }
222
                                return true;
4✔
223
                }
224
        }
66✔
225

226
        private bool readBlockArrayAction(CadTemplate template, DxfMap map)
227
        {
56✔
228
                CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
56✔
229
                BlockArrayAction action = tmp.CadObject as BlockArrayAction;
56✔
230

231
                switch (this._reader.Code)
56✔
232
                {
233
                        case 92:
234
                                action.BaseConnection.Id = this._reader.ValueAsInt;
2✔
235
                                return true;
2✔
236
                        case 93:
237
                                action.EndConnection.Id = this._reader.ValueAsInt;
2✔
238
                                return true;
2✔
239
                        case 94:
240
                                action.UpdatedBaseConnection.Id = this._reader.ValueAsInt;
2✔
241
                                return true;
2✔
242
                        case 95:
243
                                action.UpdatedEndConnection.Id = this._reader.ValueAsInt;
2✔
244
                                return true;
2✔
245
                        case 301:
246
                                action.BaseConnection.Name = this._reader.ValueAsString;
2✔
247
                                return true;
2✔
248
                        case 302:
249
                                action.EndConnection.Name = this._reader.ValueAsString;
2✔
250
                                return true;
2✔
251
                        case 303:
252
                                action.UpdatedBaseConnection.Name = this._reader.ValueAsString;
2✔
253
                                return true;
2✔
254
                        case 304:
255
                                action.UpdatedEndConnection.Name = this._reader.ValueAsString;
2✔
256
                                return true;
2✔
257
                        default:
258
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockArrayAction]))
40✔
259
                                {
36✔
260
                                        return this.readBlockAction(template, map);
36✔
261
                                }
262
                                return true;
4✔
263
                }
264
        }
56✔
265

266
        private bool readBlockBasePointParameter(CadTemplate template, DxfMap map)
267
        {
56✔
268
                CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
56✔
269

270
                switch (this._reader.Code)
56✔
271
                {
272
                        default:
273
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockBasePointParameter]))
56✔
274
                                {
44✔
275
                                        return this.readBlock1PtParameter(template, map);
44✔
276
                                }
277
                                return true;
12✔
278
                }
279
        }
56✔
280

281
        private bool readBlockElement(CadTemplate template, DxfMap map)
282
        {
12,728✔
283
                CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
12,728✔
284

285
                switch (this._reader.Code)
12,728✔
286
                {
287
                        default:
288
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
12,728✔
289
                                {
11,900✔
290
                                        return this.readEvaluationExpression(template, map);
11,900✔
291
                                }
292
                                return true;
828✔
293
                }
294
        }
12,728✔
295

296
        private bool readBlockFlipAction(CadTemplate template, DxfMap map)
297
        {
52✔
298
                CadBlockFlipActionTemplate tmp = template as CadBlockFlipActionTemplate;
52✔
299
                BlockFlipAction flip = tmp.CadObject as BlockFlipAction;
52✔
300

301
                switch (this._reader.Code)
52✔
302
                {
303
                        case 92:
304
                                flip.FlipConnection.Id = this._reader.ValueAsInt;
2✔
305
                                return true;
2✔
306
                        case 93:
307
                                flip.UpdatedFlipConnection.Id = this._reader.ValueAsInt;
2✔
308
                                return true;
2✔
309
                        case 94:
310
                                flip.UpdatedBaseConnection.Id = this._reader.ValueAsInt;
2✔
311
                                return true;
2✔
312
                        case 95:
313
                                flip.UpdatedEndConnection.Id = this._reader.ValueAsInt;
2✔
314
                                return true;
2✔
315
                        case 301:
316
                                flip.FlipConnection.Name = this._reader.ValueAsString;
2✔
317
                                return true;
2✔
318
                        case 302:
319
                                flip.UpdatedFlipConnection.Name = this._reader.ValueAsString;
2✔
320
                                return true;
2✔
321
                        case 303:
322
                                flip.UpdatedBaseConnection.Name = this._reader.ValueAsString;
2✔
323
                                return true;
2✔
324
                        case 304:
325
                                flip.UpdatedEndConnection.Name = this._reader.ValueAsString;
2✔
326
                                return true;
2✔
327
                        default:
328
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockFlipAction]))
36!
329
                                {
36✔
330
                                        return this.readBlockAction(template, map);
36✔
331
                                }
NEW
332
                                return true;
×
333
                }
334
        }
52✔
335

336
        private bool readBlockFlipParameter(CadTemplate template, DxfMap map)
337
        {
82✔
338
                CadBlockFlipParameterTemplate tmp = template as CadBlockFlipParameterTemplate;
82✔
339
                BlockFlipParameter flip = tmp.CadObject as BlockFlipParameter;
82✔
340

341
                switch (this._reader.Code)
82✔
342
                {
343
                        case 309:
344
                                flip.UpdatedFlipConnection = this.readEvalConnection(true);
2✔
345
                                return true;
2✔
346
                        default:
347
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockFlipParameter]))
80✔
348
                                {
66✔
349
                                        return this.readBlock2PtParameter(template, map);
66✔
350
                                }
351
                                return true;
14✔
352
                }
353
        }
82✔
354

355
        private bool readBlockGrip(CadTemplate template, DxfMap map)
356
        {
4,880✔
357
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
4,880✔
358

359
                switch (this._reader.Code)
4,880✔
360
                {
361
                        default:
362
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
4,880!
363
                                {
4,880✔
364
                                        return this.readBlockElement(template, map);
4,880✔
365
                                }
NEW
366
                                return true;
×
367
                }
368
        }
4,880✔
369

370
        private bool readBlockGripLocationComponent(CadTemplate template, DxfMap map)
371
        {
10,998✔
372
                CadBlockGripLocationComponentTemplate tmp = template as CadBlockGripLocationComponentTemplate;
10,998✔
373
                BlockGripLocationComponent component = tmp.CadObject as BlockGripLocationComponent;
10,998✔
374

375
                switch (this._reader.Code)
10,998✔
376
                {
377
                        case 91:
378
                                component.Connection = this.readEvalConnection();
1,222✔
379
                                return true;
1,222✔
380
                        default:
381
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
9,776!
382
                                {
9,776✔
383
                                        return this.readEvaluationExpression(template, map);
9,776✔
384
                                }
NEW
385
                                return true;
×
386
                }
387
        }
10,998✔
388

389
        private bool readBlockGripSubclass(CadTemplate template, DxfMap map)
390
        {
13,384✔
391
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
13,384✔
392

393
                switch (this._reader.Code)
13,384✔
394
                {
395
                        default:
396
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
13,384✔
397
                                {
4,880✔
398
                                        return this.readBlockGrip(template, map);
4,880✔
399
                                }
400
                                return true;
8,504✔
401
                }
402
        }
13,384✔
403

404
        private bool readBlockLinearParameter(CadTemplate template, DxfMap map)
405
        {
7,252✔
406
                var tmp = template as CadBlockLinearParameterTemplate;
7,252✔
407
                var linearPrameter = tmp.CadObject as BlockLinearParameter;
7,252✔
408

409
                switch (this._reader.Code)
7,252✔
410
                {
411
                        case 307:
412
                                linearPrameter.ValueSet = this.readParameterValueSet();
196✔
413
                                return true;
196✔
414
                        default:
415
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLinearParameter]))
7,056✔
416
                                {
6,468✔
417
                                        return this.readBlock2PtParameter(template, map);
6,468✔
418
                                }
419
                                return true;
588✔
420
                }
421
        }
7,252✔
422

423
        private bool readBlockLookupParameter(CadTemplate template, DxfMap map)
424
        {
104✔
425
                switch (this._reader.Code)
104✔
426
                {
427
                        default:
428
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLookupParameter]))
104✔
429
                                {
92✔
430
                                        return this.readBlock1PtParameter(template, map);
92✔
431
                                }
432
                                return true;
12✔
433
                }
434
        }
104✔
435

436
        private bool readBlockMoveAction(CadTemplate template, DxfMap map)
437
        {
92✔
438
                CadBlockMoveActionTemplate tmp = template as CadBlockMoveActionTemplate;
92✔
439
                BlockMoveAction action = tmp.CadObject as BlockMoveAction;
92✔
440

441
                switch (this._reader.Code)
92✔
442
                {
443
                        case 92:
444
                                action.XDeltaConnection = this.readEvalConnection();
4✔
445
                                return true;
4✔
446
                        case 93:
447
                                action.YDeltaConnection = this.readEvalConnection();
4✔
448
                                return true;
4✔
449
                        default:
450
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockMoveAction]))
84✔
451
                                {
72✔
452
                                        return this.readBlockAction(template, map);
72✔
453
                                }
454
                                return true;
12✔
455
                }
456
        }
92✔
457

458
        private bool readBlockParameter(CadTemplate template, DxfMap map)
459
        {
5,136✔
460
                CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
5,136✔
461

462
                switch (this._reader.Code)
5,136✔
463
                {
464
                        default:
465
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
5,136✔
466
                                {
4,922✔
467
                                        return this.readBlockElement(template, map);
4,922✔
468
                                }
469
                                return true;
214✔
470
                }
471
        }
5,136✔
472

473
        private bool readBlockPointParameter(CadTemplate template, DxfMap map)
474
        {
112✔
475
                CadBlockPointParameterTemplate tmp = template as CadBlockPointParameterTemplate;
112✔
476
                BlockPointParameter action = tmp.CadObject as BlockPointParameter;
112✔
477

478
                switch (this._reader.Code)
112✔
479
                {
480
                        default:
481
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockPointParameter]))
112✔
482
                                {
92✔
483
                                        return this.readBlock1PtParameter(template, map);
92✔
484
                                }
485
                                return true;
20✔
486
                }
487
        }
112✔
488

489
        private bool readBlockPolarParameter(CadTemplate template, DxfMap map)
490
        {
80✔
491
                var tmp = template as CadBlock2PtParameterTemplate;
80✔
492
                BlockPolarParameter polar = tmp.CadObject as BlockPolarParameter;
80✔
493

494
                switch (this._reader.Code)
80✔
495
                {
496
                        case 309:
497
                                polar.DistanceValueSet = this.readParameterValueSet();
2✔
498
                                return true;
2✔
499
                        case 410:
500
                                polar.AngleValueSet = this.readParameterValueSet();
2✔
501
                                return true;
2✔
502
                        default:
503
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
76✔
504
                                {
36✔
505
                                        return this.readBlock2PtParameter(template, map);
36✔
506
                                }
507
                                return true;
40✔
508
                }
509
        }
80✔
510

511
        private bool readBlockPolarStretchAction(CadTemplate template, DxfMap map)
512
        {
62✔
513
                CadPolarStretchActionTemplate tmp = template as CadPolarStretchActionTemplate;
62✔
514
                BlockPolarStretchAction action = tmp.CadObject as BlockPolarStretchAction;
62✔
515

516
                switch (this._reader.Code)
62✔
517
                {
518
                        case 72:
519
                                var n = this._reader.ValueAsInt;
2✔
520

521
                                for (int i = 0; i < n; i++)
4!
NEW
522
                                {
×
NEW
523
                                        this._reader.ReadNext();
×
NEW
524
                                        tmp.SelectionHandles.Add(this._reader.ValueAsHandle);
×
NEW
525
                                }
×
526
                                return true;
2✔
527
                        case 73:
528
                                n = this._reader.ValueAsInt;
2✔
529
                                for (int i = 0; i < n; i++)
12✔
530
                                {
4✔
531
                                        this._reader.ReadNext();
4✔
532
                                        var x = this._reader.ValueAsDouble;
4✔
533
                                        this._reader.ReadNext();
4✔
534
                                        var y = this._reader.ValueAsDouble;
4✔
535

536
                                        action.Boundary.Add(new XY(x, y));
4✔
537
                                }
4✔
538
                                return true;
2✔
539
                        case 74:
540
                                n = this._reader.ValueAsInt;
2✔
541
                                for (int i = 0; i < n; i++)
8✔
542
                                {
2✔
543
                                        this._reader.ReadNext();
2✔
544
                                        var bind = new StretchEntityBind();
2✔
545
                                        tmp.Bindings.Add(this._reader.ValueAsHandle, bind);
2✔
546

547
                                        this._reader.ReadNext();
2✔
548
                                        var nPts = this._reader.ValueAsInt;
2✔
549
                                        for (int j = 0; j < nPts; j++)
8✔
550
                                        {
2✔
551
                                                this._reader.ReadNext();
2✔
552
                                                bind.PointIndexes.Add(this._reader.ValueAsInt);
2✔
553
                                        }
2✔
554
                                }
2✔
555
                                return true;
2✔
556
                        case 77:
557
                                return true;
2✔
558
                        case 78:
559
                                n = this._reader.ValueAsInt;
2✔
560
                                for (int i = 0; i < n; i++)
4!
NEW
561
                                {
×
NEW
562
                                        this._reader.ReadNext();
×
NEW
563
                                        var nodeId = this._reader.ValueAsInt;
×
564

NEW
565
                                        this._reader.ReadNext();
×
NEW
566
                                        var indexes = new List<int>();
×
NEW
567
                                        var nPts = this._reader.ValueAsInt;
×
NEW
568
                                        for (int j = 0; j < nPts; j++)
×
NEW
569
                                        {
×
NEW
570
                                                this._reader.ReadNext();
×
NEW
571
                                                indexes.Add(this._reader.ValueAsInt);
×
NEW
572
                                        }
×
573

NEW
574
                                        var stretchNode = new StretchNode(nodeId, indexes);
×
NEW
575
                                        action.StretchNodes.Add(stretchNode);
×
NEW
576
                                }
×
577
                                return true;
2✔
578
                        case 92:
579
                                action.BaseXDeltaConnection = this.readEvalConnection();
2✔
580
                                return true;
2✔
581
                        case 93:
582
                                action.BaseYDeltaConnection = this.readEvalConnection();
2✔
583
                                return true;
2✔
584
                        case 94:
585
                                action.BaseConnection = this.readEvalConnection();
2✔
586
                                return true;
2✔
587
                        case 95:
588
                                action.EndConnection = this.readEvalConnection();
2✔
589
                                return true;
2✔
590
                        case 96:
591
                                action.UpdatedBaseConnection = this.readEvalConnection();
2✔
592
                                return true;
2✔
593
                        case 97:
594
                                action.UpdatedEndConnection = this.readEvalConnection();
2✔
595
                                return true;
2✔
596
                        default:
597
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockPolarStretchAction]))
40✔
598
                                {
36✔
599
                                        return this.readBlockAction(template, map);
36✔
600
                                }
601
                                return true;
4✔
602
                }
603
        }
62✔
604

605
        private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
606
        {
1,764✔
607
                CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
1,764✔
608

609
                switch (this._reader.Code)
1,764✔
610
                {
611
                        case 340:
612
                                tmp.BlockHandle = this._reader.ValueAsHandle;
294✔
613
                                return true;
294✔
614
                        default:
615
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,470✔
616
                }
617
        }
1,764✔
618

619
        private bool readBlockRotationAction(CadTemplate template, DxfMap map)
620
        {
62✔
621
                CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
62✔
622
                BlockRotationAction action = tmp.CadObject as BlockRotationAction;
62✔
623

624
                switch (this._reader.Code)
62✔
625
                {
626
                        case 94:
627
                                action.AngleDeltaConnection = this.readEvalConnection();
2✔
628
                                return true;
2✔
629
                        default:
630
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
60!
631
                                {
60✔
632
                                        return this.readBlockActionBasePt(template, map);
60✔
633
                                }
NEW
634
                                return true;
×
635
                }
636
        }
62✔
637

638
        private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
639
        {
80✔
640
                var tmp = template as CadBlockRotationParameterTemplate;
80✔
641
                BlockRotationParameter rotationPrameter = tmp.CadObject as BlockRotationParameter;
80✔
642

643
                switch (this._reader.Code)
80✔
644
                {
645
                        case 307:
646
                                rotationPrameter.ValueSet = this.readParameterValueSet();
2✔
647
                                return true;
2✔
648
                        default:
649
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
78✔
650
                                {
36✔
651
                                        return this.readBlock2PtParameter(template, map);
36✔
652
                                }
653
                                return true;
42✔
654
                }
655
        }
80✔
656

657
        private bool readBlockScaleAction(CadTemplate template, DxfMap map)
658
        {
6,984✔
659
                CadBlockScaleActionTemplate tmp = template as CadBlockScaleActionTemplate;
6,984✔
660
                BlockScaleAction action = tmp.CadObject as BlockScaleAction;
6,984✔
661

662
                switch (this._reader.Code)
6,984✔
663
                {
664
                        // Unsorted connections
665
                        case 94:
666
                                action.ScaleConnection.Id = this._reader.ValueAsInt;
194✔
667
                                return true;
194✔
668
                        case 95:
669
                                action.XScaleConnection.Id = this._reader.ValueAsInt;
194✔
670
                                return true;
194✔
671
                        case 96:
672
                                action.YScaleConnection.Id = this._reader.ValueAsInt;
194✔
673
                                return true;
194✔
674
                        case 303:
675
                                action.ScaleConnection.Name = this._reader.ValueAsString;
194✔
676
                                return true;
194✔
677
                        case 304:
678
                                action.XScaleConnection.Name = this._reader.ValueAsString;
194✔
679
                                return true;
194✔
680
                        case 305:
681
                                action.YScaleConnection.Name = this._reader.ValueAsString;
194✔
682
                                return true;
194✔
683
                        default:
684
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockScaleAction]))
5,820!
685
                                {
5,820✔
686
                                        return this.readBlockActionBasePt(template, map);
5,820✔
687
                                }
NEW
688
                                return true;
×
689
                }
690
        }
6,984✔
691

692
        private bool readBlockStretchAction(CadTemplate template, DxfMap map)
693
        {
52✔
694
                CadStretchActionBaseTemplate tmp = template as CadStretchActionBaseTemplate;
52✔
695
                BlockStretchAction action = tmp.CadObject as BlockStretchAction;
52✔
696

697
                switch (this._reader.Code)
52✔
698
                {
699
                        case 72:
700
                                int n = this._reader.ValueAsInt;
2✔
701
                                for (int i = 0; i < n; i++)
12✔
702
                                {
4✔
703
                                        this._reader.ReadNext();
4✔
704
                                        var x = this._reader.ValueAsDouble;
4✔
705
                                        this._reader.ReadNext();
4✔
706
                                        var y = this._reader.ValueAsDouble;
4✔
707

708
                                        action.Boundary.Add(new XY(x, y));
4✔
709
                                }
4✔
710
                                return true;
2✔
711
                        case 73:
712
                                n = this._reader.ValueAsInt;
2✔
713
                                for (int i = 0; i < n; i++)
8✔
714
                                {
2✔
715
                                        this._reader.ReadNext();
2✔
716
                                        var bind = new StretchEntityBind();
2✔
717
                                        tmp.Bindings.Add(this._reader.ValueAsHandle, bind);
2✔
718

719
                                        this._reader.ReadNext();
2✔
720
                                        var nPts = this._reader.ValueAsInt;
2✔
721
                                        for (int j = 0; j < nPts; j++)
12✔
722
                                        {
4✔
723
                                                this._reader.ReadNext();
4✔
724
                                                bind.PointIndexes.Add(this._reader.ValueAsInt);
4✔
725
                                        }
4✔
726
                                }
2✔
727
                                return true;
2✔
728
                        case 75:
729
                                n = this._reader.ValueAsInt;
2✔
730
                                for (int i = 0; i < n; i++)
4!
NEW
731
                                {
×
NEW
732
                                        this._reader.ReadNext();
×
NEW
733
                                        var nodeId = this._reader.ValueAsInt;
×
734

NEW
735
                                        this._reader.ReadNext();
×
NEW
736
                                        var indexes = new List<int>();
×
NEW
737
                                        var nPts = this._reader.ValueAsInt;
×
NEW
738
                                        for (int j = 0; j < nPts; j++)
×
739
                                        {
×
NEW
740
                                                this._reader.ReadNext();
×
NEW
741
                                                indexes.Add(this._reader.ValueAsInt);
×
742
                                        }
×
743

NEW
744
                                        var stretchNode = new StretchNode(nodeId, indexes);
×
NEW
745
                                        action.StretchNodes.Add(stretchNode);
×
NEW
746
                                }
×
747
                                return true;
2✔
748
                        case 92:
749
                                action.EndXDeltaConnection = this.readEvalConnection();
2✔
750
                                return true;
2✔
751
                        case 93:
752
                                action.EndYDeltaConnection = this.readEvalConnection();
2✔
753
                                return true;
2✔
754
                        default:
755
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockStretchAction]))
42✔
756
                                {
36✔
757
                                        return this.readBlockAction(template, map);
36✔
758
                                }
759
                                return true;
6✔
760
                }
761
        }
52✔
762

763
        private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
764
        {
5,432✔
765
                CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
5,432✔
766

767
                switch (this._reader.Code)
5,432✔
768
                {
769
                        case 92:
770
                                var stateCount = this._reader.ValueAsInt;
194✔
771
                                for (int i = 0; i < stateCount; i++)
1,940✔
772
                                {
776✔
773
                                        this._reader.ReadNext();
776✔
774
                                        tmp.StateTemplates.Add(this.readState());
776✔
775
                                }
776✔
776
                                return true;
194✔
777
                        case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
388✔
778
                                var entityCount = this._reader.ValueAsInt;
194✔
779
                                for (int i = 0; i < entityCount; i++)
792✔
780
                                {
202✔
781
                                        this._reader.ReadNext();
202✔
782
                                        tmp.EntityHandles.Add(this._reader.ValueAsHandle);
202✔
783
                                }
202✔
784
                                return true;
194✔
785
                        default:
786
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
5,044✔
787
                                {
3,880✔
788
                                        return this.readBlock1PtParameter(template, map);
3,880✔
789
                                }
790
                                return true;
1,164✔
791
                }
792
        }
5,432✔
793

794
        private bool readBlockXYParameter(CadTemplate template, DxfMap map)
795
        {
82✔
796
                CadBlock2PtParameterTemplate tmp = template as CadBlock2PtParameterTemplate;
82✔
797
                BlockXYParameter parameter = tmp.CadObject as BlockXYParameter;
82✔
798

799
                switch (this._reader.Code)
82✔
800
                {
801
                        case 309:
802
                                parameter.ValueSetY = this.readParameterValueSet();
2✔
803
                                return true;
2✔
804
                        case 410:
805
                                parameter.ValueSetX = this.readParameterValueSet();
2✔
806
                                return true;
2✔
807
                        default:
808
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockXYParameter]))
78✔
809
                                {
66✔
810
                                        return this.readBlock2PtParameter(template, map);
66✔
811
                                }
812
                                return true;
12✔
813
                }
814
        }
82✔
815

816
        private bool readBookColor(CadTemplate template, DxfMap map)
817
        {
1,376✔
818
                CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
819
                BookColor color = tmp.CadObject as BookColor;
1,376✔
820

821
                switch (this._reader.Code)
1,376✔
822
                {
823
                        case 430:
824
                                color.Name = this._reader.ValueAsString;
160✔
825
                                return true;
160✔
826
                        default:
827
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
828
                }
829
        }
1,376✔
830

831
        private TableEntity.Cell readCell()
832
        {
5,376✔
833
                this._reader.ReadNext();
5,376✔
834

835
                TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
836
                CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
837

838
                bool end = false;
5,376✔
839
                while (this._reader.DxfCode != DxfCode.Start)
16,960✔
840
                {
16,832✔
841
                        switch (this._reader.Code)
16,832✔
842
                        {
843
                                case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
844
                                        this.readLinkedTableCell(cell);
5,376✔
845
                                        break;
5,376✔
846
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
847
                                        this.readFormattedTableCell(cell);
5,248✔
848
                                        break;
5,248✔
849
                                case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
850
                                        this.readTableCell(cell);
5,248✔
851
                                        end = true;
5,248✔
852
                                        break;
5,248✔
853
                                default:
854
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
855
                                        break;
960✔
856
                        }
857

858
                        if (end)
16,832✔
859
                        {
5,248✔
860
                                return cell;
5,248✔
861
                        }
862

863
                        this._reader.ReadNext();
11,584✔
864
                }
11,584✔
865

866
                return cell;
128✔
867
        }
5,376✔
868

869
        private void readCellContent(CadTableCellContentTemplate template)
870
        {
4,096✔
871
                TableEntity.CellContent content = template.Content;
4,096✔
872
                var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
873

874
                this._reader.ReadNext();
4,096✔
875

876
                bool end = false;
4,096✔
877
                while (this._reader.DxfCode != DxfCode.Start)
16,384✔
878
                {
16,384✔
879
                        switch (this._reader.Code)
16,384✔
880
                        {
881
                                case 91:
882
                                        break;
4,096✔
883
                                case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
884
                                        var valueTemplate = this.readCadValue(content.CadValue);
3,712✔
885
                                        template.CadValueTemplate = valueTemplate;
3,712✔
886
                                        break;
3,712✔
887
                                case 309:
888
                                        end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
889
                                        break;
4,096✔
890
                                case 340:
891
                                        template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
892
                                        break;
384✔
893
                                default:
894
                                        if (!this.tryAssignCurrentValue(content, map))
4,096!
NEW
895
                                        {
×
NEW
896
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
NEW
897
                                        }
×
898
                                        break;
4,096✔
899
                        }
900

901
                        if (end)
16,384✔
902
                        {
4,096✔
903
                                break;
4,096✔
904
                        }
905

906
                        this._reader.ReadNext();
12,288✔
907
                }
12,288✔
908
        }
4,096✔
909

910
        private void readCellMargin(CadCellStyleTemplate template)
911
        {
2,816✔
912
                var style = template.Format as TableStyle.CellStyle;
2,816✔
913

914
                this._reader.ReadNext();
2,816✔
915

916
                bool end = false;
2,816✔
917
                int i = 0;
2,816✔
918
                while (this._reader.DxfCode != DxfCode.Start)
22,528✔
919
                {
22,528✔
920
                        switch (this._reader.Code)
22,528!
921
                        {
922
                                case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
923
                                        break;
2,816✔
924
                                case 40:
925
                                        switch (i)
16,896✔
926
                                        {
927
                                                case 0:
928
                                                        style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
929
                                                        break;
2,816✔
930
                                                case 1:
931
                                                        style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
932
                                                        break;
2,816✔
933
                                                case 2:
934
                                                        style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
935
                                                        break;
2,816✔
936
                                                case 3:
937
                                                        style.RightMargin = this._reader.ValueAsDouble;
2,816✔
938
                                                        break;
2,816✔
939
                                                case 4:
940
                                                        style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
941
                                                        break;
2,816✔
942
                                                case 5:
943
                                                        style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
944
                                                        break;
2,816✔
945
                                        }
946

947
                                        i++;
16,896✔
948
                                        break;
16,896✔
949
                                case 309:
950
                                        end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
951
                                        break;
2,816✔
952
                                default:
NEW
953
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
954
                                        break;
×
955
                        }
956

957
                        if (end)
22,528✔
958
                        {
2,816✔
959
                                break;
2,816✔
960
                        }
961

962
                        this._reader.ReadNext();
19,712✔
963
                }
19,712✔
964
        }
2,816✔
965

966
        private void readCellStyle(CadCellStyleTemplate template)
UNCOV
967
        {
×
968
                //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
969

UNCOV
970
                this._reader.ReadNext();
×
971

UNCOV
972
                bool end = false;
×
NEW
973
                while (this._reader.Code != 1)
×
UNCOV
974
                {
×
UNCOV
975
                        switch (this._reader.Code)
×
976
                        {
977
                                case 309:
NEW
978
                                        end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
979
                                        break;
×
980
                                default:
981
                                        //if (!this.tryAssignCurrentValue(cell, map))
NEW
982
                                        {
×
NEW
983
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
NEW
984
                                        }
×
UNCOV
985
                                        break;
×
986
                        }
987

UNCOV
988
                        if (end)
×
UNCOV
989
                        {
×
UNCOV
990
                                break;
×
991
                        }
992

UNCOV
993
                        this._reader.ReadNext();
×
UNCOV
994
                }
×
UNCOV
995
        }
×
996

997
        private void readCellTableFormat(TableEntity.Cell cell)
998
        {
5,248✔
999
                var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1000

1001
                this._reader.ReadNext();
5,248✔
1002

1003
                bool end = false;
5,248✔
1004
                while (this._reader.Code == 1)
10,496✔
1005
                {
5,248✔
1006
                        switch (this._reader.Code)
5,248!
1007
                        {
1008
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1009
                                        this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1010
                                        break;
5,248✔
NEW
1011
                                case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
1012
                                        this.readCellStyle(new CadCellStyleTemplate());
×
UNCOV
1013
                                        break;
×
1014
                                default:
NEW
1015
                                        if (!this.tryAssignCurrentValue(cell, map))
×
NEW
1016
                                        {
×
NEW
1017
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
NEW
1018
                                        }
×
UNCOV
1019
                                        break;
×
1020
                        }
1021

1022
                        if (end)
5,248!
UNCOV
1023
                        {
×
UNCOV
1024
                                break;
×
1025
                        }
1026

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

1031
        private void readContentFormat(CellContentFormatTemplate template)
1032
        {
9,600✔
1033
                var format = template.Format;
9,600✔
1034
                var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1035

1036
                this._reader.ReadNext();
9,600✔
1037

1038
                bool end = false;
9,600✔
1039
                while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1040
                {
124,800✔
1041
                        switch (this._reader.Code)
124,800✔
1042
                        {
1043
                                case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1044
                                        break;
9,600✔
1045
                                case 309:
1046
                                        end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1047
                                        break;
9,600✔
1048
                                case 340:
1049
                                        template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1050
                                        break;
9,600✔
1051
                                default:
1052
                                        if (!this.tryAssignCurrentValue(format, map))
96,000!
NEW
1053
                                        {
×
NEW
1054
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
NEW
1055
                                        }
×
1056
                                        break;
96,000✔
1057
                        }
1058

1059
                        if (end)
124,800✔
1060
                        {
9,600✔
1061
                                break;
9,600✔
1062
                        }
1063

1064
                        this._reader.ReadNext();
115,200✔
1065
                }
115,200✔
1066
        }
9,600✔
1067

1068
        private void readCustomData()
1069
        {
8,000✔
1070
                this._reader.ReadNext();
8,000✔
1071

1072
                int ndata = 0;
8,000✔
1073
                bool end = false;
8,000✔
1074
                while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1075
                {
74,304✔
1076
                        switch (this._reader.Code)
74,304✔
1077
                        {
1078
                                case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1079
                                        break;
8,000✔
1080
                                case 90:
1081
                                        ndata = this._reader.ValueAsInt;
8,128✔
1082
                                        break;
8,128✔
1083
                                case 300:
1084
                                        //Name
1085
                                        break;
5,248✔
1086
                                case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1087
                                        this.readDataMapValue();
5,248✔
1088
                                        break;
5,248✔
1089
                                case 309:
1090
                                        end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1091
                                        break;
7,872✔
1092
                                default:
1093
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1094
                                        break;
39,808✔
1095
                        }
1096

1097
                        if (end)
74,304✔
1098
                        {
7,872✔
1099
                                break;
7,872✔
1100
                        }
1101

1102
                        this._reader.ReadNext();
66,432✔
1103
                }
66,432✔
1104
        }
8,000✔
1105

1106
        private void readDataMapValue()
1107
        {
5,248✔
1108
                CadValue value = new();
5,248✔
1109
                var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
5,248✔
1110

1111
                this._reader.ReadNext();
5,248✔
1112

1113
                bool end = false;
5,248✔
1114
                while (this._reader.DxfCode != DxfCode.Start)
305,024✔
1115
                {
304,896✔
1116
                        switch (this._reader.Code)
304,896✔
1117
                        {
1118
                                case 11:
1119
                                case 21:
1120
                                case 31:
1121
                                        //Value as point
1122
                                        break;
384✔
1123
                                case 91:
1124
                                case 92:
1125
                                        //Value as int
1126
                                        break;
38,656✔
1127
                                case 140:
1128
                                        //Value as double
1129
                                        break;
12,736✔
1130
                                case 310:
1131
                                        //Value as byte array
1132
                                        break;
128✔
1133
                                case 304:
1134
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.ValueEnd, StringComparison.InvariantCultureIgnoreCase);
5,120✔
1135
                                        break;
5,120✔
1136
                                default:
1137
                                        if (!this.tryAssignCurrentValue(value, map))
247,872✔
1138
                                        {
140,288✔
1139
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
140,288✔
1140
                                        }
140,288✔
1141
                                        break;
247,872✔
1142
                        }
1143

1144
                        if (end)
304,896✔
1145
                        {
5,120✔
1146
                                break;
5,120✔
1147
                        }
1148

1149
                        this._reader.ReadNext();
299,776✔
1150
                }
299,776✔
1151
        }
5,248✔
1152

1153
        private bool readDictionary(CadTemplate template, DxfMap map)
1154
        {
231,281✔
1155
                CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
231,281✔
1156
                CadDictionary cadDictionary = tmp.CadObject;
231,281✔
1157

1158
                switch (this._reader.Code)
231,281✔
1159
                {
1160
                        case 280:
1161
                                cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,397✔
1162
                                return true;
15,397✔
1163
                        case 281:
1164
                                cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
22,126✔
1165
                                return true;
22,126✔
1166
                        case 3:
1167
                                tmp.Entries.Add(this._reader.ValueAsString, null);
59,356✔
1168
                                return true;
59,356✔
1169
                        case 350: // Soft-owner ID/handle to entry object
1170
                        case 360: // Hard-owner ID/handle to entry object
1171
                                tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
59,356✔
1172
                                return true;
59,356✔
1173
                        default:
1174
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
75,046✔
1175
                }
1176
        }
231,281✔
1177

1178
        private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1179
        {
1,926✔
1180
                CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,926✔
1181

1182
                switch (this._reader.Code)
1,926✔
1183
                {
1184
                        case 340:
1185
                                tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
214✔
1186
                                return true;
214✔
1187
                        default:
1188
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,712!
1189
                                {
1,712✔
1190
                                        return this.readDictionary(template, map);
1,712✔
1191
                                }
NEW
1192
                                return true;
×
1193
                }
1194
        }
1,926✔
1195

1196
        private bool readDimensionAssociation(CadTemplate template, DxfMap map)
1197
        {
5,376✔
1198
                CadDimensionAssociationTemplate tmp = template as CadDimensionAssociationTemplate;
5,376✔
1199
                DimensionAssociation dimassoc = tmp.CadObject;
5,376✔
1200

1201
                switch (this._reader.Code)
5,376✔
1202
                {
1203
                        case 1 when this._reader.ValueAsString.Equals(DimensionAssociation.OsnapPointRefClassName):
768✔
1204
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FirstPointReference)
768✔
1205
                                        && dimassoc.FirstPointRef == null)
768✔
1206
                                {
192✔
1207
                                        dimassoc.FirstPointRef = new DimensionAssociation.OsnapPointRef();
192✔
1208
                                        this.readOsnapPointRef(dimassoc.FirstPointRef);
192✔
1209
                                        this.lockPointer = true;
192✔
1210
                                        return true;
192✔
1211
                                }
1212

1213
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.SecondPointReference)
576!
1214
                                        && dimassoc.SecondPointRef == null)
576✔
1215
                                {
576✔
1216
                                        dimassoc.SecondPointRef = new DimensionAssociation.OsnapPointRef();
576✔
1217
                                        this.readOsnapPointRef(dimassoc.SecondPointRef);
576✔
1218
                                        this.lockPointer = true;
576✔
1219
                                        return true;
576✔
1220
                                }
1221

NEW
1222
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.ThirdPointReference)
×
NEW
1223
                                        && dimassoc.ThirdPointRef == null)
×
NEW
1224
                                {
×
NEW
1225
                                        dimassoc.ThirdPointRef = new DimensionAssociation.OsnapPointRef();
×
NEW
1226
                                        this.readOsnapPointRef(dimassoc.ThirdPointRef);
×
NEW
1227
                                        this.lockPointer = true;
×
NEW
1228
                                        return true;
×
1229
                                }
1230

NEW
1231
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FourthPointReference)
×
NEW
1232
                                        && dimassoc.FourthPointRef == null)
×
NEW
1233
                                {
×
NEW
1234
                                        dimassoc.FourthPointRef = new DimensionAssociation.OsnapPointRef();
×
NEW
1235
                                        this.readOsnapPointRef(dimassoc.FourthPointRef);
×
NEW
1236
                                        this.lockPointer = true;
×
NEW
1237
                                        return true;
×
1238
                                }
1239

NEW
1240
                                return true;
×
1241
                        case 330 when template.OwnerHandle.HasValue:
1,152✔
1242
                                tmp.DimensionHandle = this._reader.ValueAsHandle;
576✔
1243
                                return true;
576✔
1244
                        default:
1245
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
4,032✔
1246
                }
1247
        }
5,376✔
1248

1249
        private EvalConnection readEvalConnection(bool reversed = false)
1250
        {
2,066✔
1251
                EvalConnection connection = new EvalConnection();
2,066✔
1252
                // No dynamic reader for codes 9x and 30x
1253
                if (reversed)
2,066✔
1254
                {
2✔
1255
                        connection.Name = this._reader.ValueAsString;
2✔
1256
                        this._reader.ReadNext();
2✔
1257
                        connection.Id = this._reader.ValueAsInt;
2✔
1258
                }
2✔
1259
                else
1260
                {
2,064✔
1261
                        connection.Id = this._reader.ValueAsInt;
2,064✔
1262
                        this._reader.ReadNext();
2,064✔
1263
                        connection.Name = this._reader.ValueAsString;
2,064✔
1264
                }
2,064✔
1265

1266
                return connection;
2,066✔
1267
        }
2,066✔
1268

1269
        private void readEvalParameterProperty(EvalParameterProperty property)
1270
        {
1,232✔
1271
                short nconnections = this._reader.ValueAsShort;
1,232✔
1272
                for (; nconnections > 0; nconnections--)
2,864✔
1273
                {
816✔
1274
                        this._reader.ReadNext();
816✔
1275
                        property.Connections.Add(this.readEvalConnection());
816✔
1276
                }
816✔
1277
        }
1,232✔
1278

1279
        private bool readEvaluationExpression(CadTemplate template, DxfMap map)
1280
        {
21,676✔
1281
                CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
21,676✔
1282
                EvaluationExpression expression = tmp.CadObject as EvaluationExpression;
21,676✔
1283

1284
                switch (this._reader.Code)
21,676✔
1285
                {
1286
                        case 1:
1287
                                this._reader.ReadNext();
1,222✔
1288
                                var code = (DxfCode)this._reader.ValueAsInt;
1,222✔
1289
                                this._reader.ReadNext();
1,222✔
1290
                                object value = this._reader.Value;
1,222✔
1291

1292
                                expression.EvaluatedValue = new DxfValuePair(code, value);
1,222✔
1293
                                return true;
1,222✔
1294
                        default:
1295
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
20,454✔
1296
                }
1297
        }
21,676✔
1298

1299
        private bool readEvaluationGraph(CadTemplate template, DxfMap map)
1300
        {
3,230✔
1301
                CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,230✔
1302
                EvaluationGraph evGraph = tmp.CadObject;
3,230✔
1303

1304
                switch (this._reader.Code)
3,230✔
1305
                {
1306
                        case 91:
1307
                                while (this._reader.Code == 91)
3,176✔
1308
                                {
2,708✔
1309
                                        EvaluationGraph.Node node = tmp.CadObject.CreateNode();
2,708✔
1310
                                        GraphNodeTemplate nodeTemplate = new GraphNodeTemplate(node);
2,708✔
1311

1312
                                        node.Index = this._reader.ValueAsInt;
2,708✔
1313

1314
                                        this._reader.ExpectedCode(93);
2,708✔
1315
                                        node.Flags = (EvaluationGraph.NodeFlags)this._reader.ValueAsInt;
2,708✔
1316

1317
                                        this._reader.ExpectedCode(95);
2,708✔
1318
                                        node.Id = this._reader.ValueAsInt;
2,708✔
1319

1320
                                        this._reader.ExpectedCode(360);
2,708✔
1321
                                        nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,708✔
1322

1323
                                        this._reader.ExpectedCode(92);
2,708✔
1324
                                        node.Data1 = this._reader.ValueAsInt;
2,708✔
1325
                                        this._reader.ExpectedCode(92);
2,708✔
1326
                                        node.Data2 = this._reader.ValueAsInt;
2,708✔
1327
                                        this._reader.ExpectedCode(92);
2,708✔
1328
                                        node.Data3 = this._reader.ValueAsInt;
2,708✔
1329
                                        this._reader.ExpectedCode(92);
2,708✔
1330
                                        node.Data4 = this._reader.ValueAsInt;
2,708✔
1331

1332
                                        this._reader.ReadNext();
2,708✔
1333

1334
                                        tmp.NodeTemplates.Add(nodeTemplate);
2,708✔
1335
                                }
2,708✔
1336

1337
                                this.lockPointer = true;
468✔
1338
                                return true;
468✔
1339
                        case 92:
1340
                                //Edges
1341
                                while (this._reader.Code == 92)
2,266✔
1342
                                {
2,056✔
1343
                                        EvaluationGraph.Edge edge = new EvaluationGraph.Edge();
2,056✔
1344

1345
                                        edge.Index = this._reader.ValueAsInt;
2,056✔
1346

1347
                                        this._reader.ExpectedCode(93);
2,056✔
1348
                                        edge.Flags = this._reader.ValueAsInt;
2,056✔
1349

1350
                                        this._reader.ExpectedCode(94);
2,056✔
1351
                                        edge.TrackedCount = this._reader.ValueAsInt;
2,056✔
1352

1353
                                        this._reader.ExpectedCode(91);
2,056✔
1354
                                        edge.FromNodeIndex = this._reader.ValueAsInt;
2,056✔
1355
                                        this._reader.ExpectedCode(91);
2,056✔
1356
                                        edge.ToNodeIndex = this._reader.ValueAsInt;
2,056✔
1357

1358
                                        this._reader.ExpectedCode(92);
2,056✔
1359
                                        edge.Data1 = this._reader.ValueAsInt;
2,056✔
1360
                                        this._reader.ExpectedCode(92);
2,056✔
1361
                                        edge.Data2 = this._reader.ValueAsInt;
2,056✔
1362
                                        this._reader.ExpectedCode(92);
2,056✔
1363
                                        edge.Data3 = this._reader.ValueAsInt;
2,056✔
1364
                                        this._reader.ExpectedCode(92);
2,056✔
1365
                                        edge.Data4 = this._reader.ValueAsInt;
2,056✔
1366
                                        this._reader.ExpectedCode(92);
2,056✔
1367
                                        edge.Data5 = this._reader.ValueAsInt;
2,056✔
1368

1369
                                        this._reader.ReadNext();
2,056✔
1370

1371
                                        tmp.CadObject.Edges.Add(edge);
2,056✔
1372
                                }
2,056✔
1373

1374
                                this.lockPointer = true;
210✔
1375
                                return true;
210✔
1376
                        default:
1377
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,552✔
1378
                }
1379
        }
3,230✔
1380

1381
        private bool readField(CadTemplate template, DxfMap map)
NEW
1382
        {
×
NEW
1383
                var tmp = template as CadFieldTemplate;
×
1384

NEW
1385
                switch (this._reader.Code)
×
1386
                {
1387
                        case 3:
NEW
1388
                                tmp.CadObject.FieldCode += this._reader.ValueAsString;
×
NEW
1389
                                return true;
×
1390
                        //98 Length of format string
1391
                        case 98:
NEW
1392
                                return true;
×
1393
                        case 6:
NEW
1394
                                string key = this._reader.ValueAsString;
×
NEW
1395
                                var t = this.readCadValue(new CadValue());
×
NEW
1396
                                tmp.CadObject.Values.Add(key, t.CadValue);
×
NEW
1397
                                tmp.CadValueTemplates.Add(t);
×
NEW
1398
                                return true;
×
1399
                        case 7:
NEW
1400
                                t = this.readCadValue(new CadValue());
×
NEW
1401
                                tmp.CadObject.Value = t.CadValue;
×
NEW
1402
                                tmp.CadValueTemplates.Add(t);
×
NEW
1403
                                return true;
×
1404
                        case 331:
NEW
1405
                                tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
NEW
1406
                                return true;
×
1407
                        case 360:
NEW
1408
                                tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
NEW
1409
                                return true;
×
1410
                        default:
NEW
1411
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
1412
                }
NEW
1413
        }
×
1414

1415
        private bool readFieldList(CadTemplate template, DxfMap map)
NEW
1416
        {
×
NEW
1417
                var tmp = template as CadFieldListTemplate;
×
1418

NEW
1419
                switch (this._reader.Code)
×
1420
                {
NEW
1421
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.IdSet:
×
NEW
1422
                                this.currentSubclass = this._reader.ValueAsString;
×
NEW
1423
                                return true;
×
NEW
1424
                        case 90 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
NEW
1425
                                return true;
×
NEW
1426
                        case 330 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
NEW
1427
                                tmp.OwnedObjectsHandlers.Add(this._reader.ValueAsHandle);
×
NEW
1428
                                return true;
×
1429
                        default:
NEW
1430
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.FieldList]);
×
1431
                }
NEW
1432
        }
×
1433

1434
        private void readFormattedCellContent()
1435
        {
4,096✔
1436
                TableStyle.ContentFormat format = new();
4,096✔
1437
                CellContentFormatTemplate template = new CellContentFormatTemplate(format);
4,096✔
1438
                var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1439

1440
                this._reader.ReadNext();
4,096✔
1441

1442
                bool end = false;
4,096✔
1443
                while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1444
                {
12,288✔
1445
                        switch (this._reader.Code)
12,288✔
1446
                        {
1447
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1448
                                        readContentFormat(template);
4,096✔
1449
                                        break;
4,096✔
1450
                                case 309:
1451
                                        end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1452
                                        break;
4,096✔
1453
                                default:
1454
                                        if (!this.tryAssignCurrentValue(format, map))
4,096!
1455
                                        {
×
NEW
1456
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1457
                                        }
×
1458
                                        break;
4,096✔
1459
                        }
1460

1461
                        if (end)
12,288✔
1462
                        {
4,096✔
1463
                                break;
4,096✔
1464
                        }
1465

1466
                        this._reader.ReadNext();
8,192✔
1467
                }
8,192✔
1468
        }
4,096✔
1469

1470
        private void readFormattedTableCell(TableEntity.Cell cell)
1471
        {
5,248✔
1472
                var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1473

1474
                this._reader.ReadNext();
5,248✔
1475

1476
                bool end = false;
5,248✔
1477
                while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1478
                {
10,496✔
1479
                        switch (this._reader.Code)
10,496!
1480
                        {
1481
                                case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1482
                                        this.readCellTableFormat(cell);
5,248✔
1483
                                        continue;
5,248✔
1484
                                case 309:
1485
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1486
                                        break;
5,248✔
1487
                                default:
NEW
1488
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1489
                                        {
×
NEW
1490
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1491
                                        }
×
1492
                                        break;
×
1493
                        }
1494

1495
                        if (end)
5,248!
1496
                        {
5,248✔
1497
                                break;
5,248✔
1498
                        }
1499

1500
                        this._reader.ReadNext();
×
1501
                }
×
1502
        }
5,248✔
1503

1504
        private void readFormattedTableColumn(TableEntity.Column column)
1505
        {
1,216✔
1506
                this._reader.ReadNext();
1,216✔
1507

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

1526
                        if (end)
3,648✔
1527
                        {
1,216✔
1528
                                break;
1,216✔
1529
                        }
1530

1531
                        this._reader.ReadNext();
2,432✔
1532
                }
2,432✔
1533
        }
1,216✔
1534

1535
        private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
1536
        {
256✔
1537
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
1538
                FormattedTableData formattedTable = tmp.CadObject;
256✔
1539

1540
                this._reader.ReadNext();
256✔
1541

1542
                TableEntity.CellRange cellRange = null;
256✔
1543
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
1544
                {
2,048✔
1545
                        switch (this._reader.Code)
2,048!
1546
                        {
1547
                                case 90:
1548
                                        break;
256✔
1549
                                case 91:
1550
                                        if (cellRange == null)
384✔
1551
                                        {
384✔
1552
                                                cellRange = new();
384✔
1553
                                                formattedTable.MergedCellRanges.Add(cellRange);
384✔
1554
                                        }
384✔
1555
                                        cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
1556
                                        break;
384✔
1557
                                case 92:
1558
                                        if (cellRange == null)
384!
NEW
1559
                                        {
×
NEW
1560
                                                cellRange = new();
×
NEW
1561
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
1562
                                        }
×
1563
                                        cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
1564
                                        break;
384✔
1565
                                case 93:
1566
                                        if (cellRange == null)
384!
NEW
1567
                                        {
×
NEW
1568
                                                cellRange = new();
×
NEW
1569
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
1570
                                        }
×
1571
                                        cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
1572
                                        break;
384✔
1573
                                case 94:
1574
                                        if (cellRange == null)
384!
NEW
1575
                                        {
×
NEW
1576
                                                cellRange = new();
×
NEW
1577
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
1578
                                        }
×
1579
                                        cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
1580
                                        cellRange = null;
384✔
1581
                                        break;
384✔
1582
                                case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
1583
                                        this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
1584
                                        break;
256✔
1585
                                default:
NEW
1586
                                        if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
1587
                                        {
×
NEW
1588
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
1589
                                        }
×
1590
                                        break;
×
1591
                        }
1592

1593
                        this._reader.ReadNext();
2,048✔
1594
                }
2,048✔
1595
        }
256✔
1596

1597
        private void readFormattedTableRow(TableEntity.Row row)
1598
        {
1,408✔
1599
                this._reader.ReadNext();
1,408✔
1600

1601
                bool end = false;
1,408✔
1602
                while (this._reader.DxfCode != DxfCode.Start)
4,224✔
1603
                {
4,224✔
1604
                        switch (this._reader.Code)
4,224!
1605
                        {
1606
                                case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
1607
                                        break;
1,408✔
1608
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
1609
                                        this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
1610
                                        break;
1,408✔
1611
                                case 309:
1612
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
1613
                                        break;
1,408✔
1614
                                default:
NEW
1615
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
1616
                                        break;
×
1617
                        }
1618

1619
                        if (end)
4,224✔
1620
                        {
1,408✔
1621
                                break;
1,408✔
1622
                        }
1623

1624
                        this._reader.ReadNext();
2,816✔
1625
                }
2,816✔
1626
        }
1,408✔
1627

1628
        private bool readGeoData(CadTemplate template, DxfMap map)
1629
        {
102✔
1630
                CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
1631

1632
                switch (this._reader.Code)
102✔
1633
                {
1634
                        case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
1635
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
1636
                                        tmp.CadObject.ReferencePoint.X,
1✔
1637
                                        this._reader.ValueAsDouble,
1✔
1638
                                        tmp.CadObject.ReferencePoint.Z
1✔
1639
                                        );
1✔
1640
                                return true;
1✔
1641
                        case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
1642
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
1643
                                        this._reader.ValueAsDouble,
1✔
1644
                                        tmp.CadObject.ReferencePoint.Y,
1✔
1645
                                        tmp.CadObject.ReferencePoint.Z
1✔
1646
                                        );
1✔
1647
                                return true;
1✔
1648
                        case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
1649
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
1650
                                        tmp.CadObject.ReferencePoint.X,
1✔
1651
                                        tmp.CadObject.ReferencePoint.Y,
1✔
1652
                                        this._reader.ValueAsDouble
1✔
1653
                                        );
1✔
1654
                                return true;
1✔
1655
                        case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
1656
                                tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
1657
                                return true;
1✔
1658
                        case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
1659
                                double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
1660
                                tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
1661
                                return true;
1✔
1662
                        // Number of Geo-Mesh points
1663
                        case 93:
1664
                                var npts = this._reader.ValueAsInt;
3✔
1665
                                for (int i = 0; i < npts; i++)
54✔
1666
                                {
24✔
1667
                                        this._reader.ReadNext();
24✔
1668
                                        double sourceX = this._reader.ValueAsDouble;
24✔
1669
                                        this._reader.ReadNext();
24✔
1670
                                        double sourceY = this._reader.ValueAsDouble;
24✔
1671

1672
                                        this._reader.ReadNext();
24✔
1673
                                        double destX = this._reader.ValueAsDouble;
24✔
1674
                                        this._reader.ReadNext();
24✔
1675
                                        double destY = this._reader.ValueAsDouble;
24✔
1676

1677
                                        tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
1678
                                        {
24✔
1679
                                                Source = new CSMath.XY(sourceX, sourceY),
24✔
1680
                                                Destination = new CSMath.XY(destX, destY)
24✔
1681
                                        });
24✔
1682
                                }
24✔
1683
                                return true;
3✔
1684
                        // Number of Geo-Mesh points
1685
                        case 96:
1686
                                var nfaces = this._reader.ValueAsInt;
2✔
1687
                                for (int i = 0; i < nfaces; i++)
4!
NEW
1688
                                {
×
NEW
1689
                                        this._reader.ReadNext();
×
NEW
1690
                                        Debug.Assert(this._reader.Code == 97);
×
NEW
1691
                                        int index1 = this._reader.ValueAsInt;
×
NEW
1692
                                        this._reader.ReadNext();
×
NEW
1693
                                        Debug.Assert(this._reader.Code == 98);
×
NEW
1694
                                        int index2 = this._reader.ValueAsInt;
×
NEW
1695
                                        this._reader.ReadNext();
×
NEW
1696
                                        Debug.Assert(this._reader.Code == 99);
×
NEW
1697
                                        int index3 = this._reader.ValueAsInt;
×
1698

NEW
1699
                                        tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
NEW
1700
                                        {
×
NEW
1701
                                                Index1 = index1,
×
NEW
1702
                                                Index2 = index2,
×
NEW
1703
                                                Index3 = index3
×
NEW
1704
                                        });
×
NEW
1705
                                }
×
1706
                                return true;
2✔
1707
                        case 303:
1708
                                tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
1709
                                return true;
13✔
1710
                        //Obsolete codes for version GeoDataVersion.R2009
1711
                        case 3:
1712
                        case 4:
1713
                        case 14:
1714
                        case 24:
1715
                        case 15:
1716
                        case 25:
1717
                        case 43:
1718
                        case 44:
1719
                        case 45:
1720
                        case 94:
1721
                        case 293:
1722
                        case 16:
1723
                        case 26:
1724
                        case 17:
1725
                        case 27:
1726
                        case 54:
1727
                        case 140:
1728
                        case 304:
1729
                        case 292:
1730
                                return true;
19✔
1731
                        default:
1732
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
1733
                }
1734
        }
102✔
1735

1736
        private void readGridFormat(CadCellStyleTemplate template, TableStyle.CellBorder border)
1737
        {
11,776✔
1738
                var map = DxfClassMap.Create(border.GetType(), nameof(TableStyle.CellBorder));
11,776✔
1739

1740
                this._reader.ReadNext();
11,776✔
1741

1742
                bool end = false;
11,776✔
1743
                while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1744
                {
105,984✔
1745
                        switch (this._reader.Code)
105,984✔
1746
                        {
1747
                                case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1748
                                        break;
11,776✔
1749
                                case 62:
1750
                                        border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1751
                                        break;
11,776✔
1752
                                case 92:
1753
                                        border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1754
                                        break;
11,776✔
1755
                                case 93:
1756
                                        border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1757
                                        break;
11,776✔
1758
                                case 340:
1759
                                        template.BorderLineTypePairs.Add(new Tuple<TableStyle.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1760
                                        break;
11,776✔
1761
                                case 309:
1762
                                        end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1763
                                        break;
11,776✔
1764
                                default:
1765
                                        if (!this.tryAssignCurrentValue(border, map))
35,328!
1766
                                        {
×
NEW
1767
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1768
                                        }
×
1769
                                        break;
35,328✔
1770
                        }
1771

1772
                        if (end)
105,984✔
1773
                        {
11,776✔
1774
                                break;
11,776✔
1775
                        }
1776

1777
                        this._reader.ReadNext();
94,208✔
1778
                }
94,208✔
1779
        }
11,776✔
1780

1781
        private bool readGroup(CadTemplate template, DxfMap map)
1782
        {
4,992✔
1783
                CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
1784

1785
                switch (this._reader.Code)
4,992✔
1786
                {
1787
                        case 70:
1788
                                return true;
384✔
1789
                        case 340:
1790
                                tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
1791
                                return true;
2,304✔
1792
                        default:
1793
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
1794
                }
1795
        }
4,992✔
1796

1797
        private bool readLayout(CadTemplate template, DxfMap map)
1798
        {
55,226✔
1799
                CadLayoutTemplate tmp = template as CadLayoutTemplate;
55,226✔
1800

1801
                switch (this._reader.Code)
55,226✔
1802
                {
1803
                        case 330 when template.OwnerHandle.HasValue:
1,716✔
1804
                                tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
858✔
1805
                                return true;
858✔
1806
                        case 331:
1807
                                tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
790✔
1808
                                return true;
790✔
1809
                        default:
1810
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
53,578✔
1811
                                {
27,990✔
1812
                                        return this.readPlotSettings(template, map);
27,990✔
1813
                                }
1814
                                return true;
25,588✔
1815
                }
1816
        }
55,226✔
1817

1818
        private void readLinkedData(CadTemplate template, DxfMap map)
1819
        {
320✔
1820
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
1821
                LinkedData linkedData = tmp.CadObject;
320✔
1822

1823
                this._reader.ReadNext();
320✔
1824

1825
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
1826
                {
640✔
1827
                        switch (this._reader.Code)
640✔
1828
                        {
1829
                                default:
1830
                                        if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
NEW
1831
                                        {
×
NEW
1832
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
NEW
1833
                                        }
×
1834
                                        break;
640✔
1835
                        }
1836

1837
                        this._reader.ReadNext();
640✔
1838
                }
640✔
1839
        }
320✔
1840

1841
        private void readLinkedTableCell(TableEntity.Cell cell)
1842
        {
5,376✔
1843
                var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1844

1845
                this._reader.ReadNext();
5,376✔
1846

1847
                bool end = false;
5,376✔
1848
                while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1849
                {
53,760✔
1850
                        switch (this._reader.Code)
53,760✔
1851
                        {
1852
                                case 95:
1853
                                        //BL 95 Number of cell contents
1854
                                        break;
5,248✔
1855
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1856
                                        this.readCustomData();
5,376✔
1857
                                        break;
5,376✔
1858
                                case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1859
                                        var c = this.readLinkedTableCellContent();
4,096✔
1860
                                        break;
4,096✔
1861
                                case 309:
1862
                                        end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1863
                                        break;
5,248✔
1864
                                default:
1865
                                        if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1866
                                        {
11,648✔
1867
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1868
                                        }
11,648✔
1869
                                        break;
33,792✔
1870
                        }
1871

1872
                        if (end)
53,760✔
1873
                        {
5,248✔
1874
                                break;
5,248✔
1875
                        }
1876

1877
                        this._reader.ReadNext();
48,512✔
1878
                }
48,512✔
1879
        }
5,376✔
1880

1881
        private CadTableCellContentTemplate readLinkedTableCellContent()
1882
        {
4,096✔
1883
                TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1884
                CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1885
                var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1886

1887
                this._reader.ReadNext();
4,096✔
1888

1889
                bool end = false;
4,096✔
1890
                while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1891
                {
8,192✔
1892
                        switch (this._reader.Code)
8,192!
1893
                        {
1894
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1895
                                        readFormattedCellContent();
4,096✔
1896
                                        end = true;
4,096✔
1897
                                        break;
4,096✔
1898
                                case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1899
                                        readCellContent(template);
4,096✔
1900
                                        break;
4,096✔
1901
                                default:
NEW
1902
                                        if (!this.tryAssignCurrentValue(content, map))
×
1903
                                        {
×
NEW
1904
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1905
                                        }
×
UNCOV
1906
                                        break;
×
1907
                        }
1908

1909
                        if (end)
8,192✔
1910
                        {
4,096✔
1911
                                break;
4,096✔
1912
                        }
1913

1914
                        this._reader.ReadNext();
4,096✔
1915
                }
4,096✔
1916

1917
                return template;
4,096✔
1918
        }
4,096✔
1919

1920
        private void readLinkedTableColumn(TableEntity.Column column)
1921
        {
1,216✔
1922
                this._reader.ReadNext();
1,216✔
1923

1924
                bool end = false;
1,216✔
1925
                while (this._reader.DxfCode != DxfCode.Start)
4,864✔
1926
                {
4,864✔
1927
                        switch (this._reader.Code)
4,864!
1928
                        {
NEW
1929
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1930
                                        break;
×
1931
                                case 1:
NEW
1932
                                        end = true;
×
NEW
1933
                                        break;
×
1934
                                case 91:
1935
                                        column.CustomData = this._reader.ValueAsInt;
1,216✔
1936
                                        break;
1,216✔
1937
                                case 300:
1938
                                        column.Name = this._reader.ValueAsString;
1,216✔
1939
                                        break;
1,216✔
1940
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
1941
                                        this.readCustomData();
1,216✔
1942
                                        break;
1,216✔
1943
                                case 309:
1944
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1945
                                        break;
1,216✔
1946
                                default:
NEW
1947
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
1948
                                        break;
×
1949
                        }
1950

1951
                        if (end)
4,864✔
1952
                        {
1,216✔
1953
                                break;
1,216✔
1954
                        }
1955

1956
                        this._reader.ReadNext();
3,648✔
1957
                }
3,648✔
1958
        }
1,216✔
1959

1960
        private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
1961
        {
320✔
1962
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
1963
                TableContent tableContent = tmp.CadObject;
320✔
1964

1965
                this._reader.ReadNext();
320✔
1966

1967
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
1968
                {
3,904✔
1969
                        switch (this._reader.Code)
3,904✔
1970
                        {
1971
                                case 90:
1972
                                        //Column count
1973
                                        break;
320✔
1974
                                case 91:
1975
                                        //Row count
1976
                                        break;
320✔
1977
                                //Unknown
1978
                                case 92:
1979
                                        break;
256✔
1980
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
1981
                                        //Read Column
1982
                                        this.readTableColumn();
1,216✔
1983
                                        break;
1,216✔
1984
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
1985
                                        //Read Row
1986
                                        this.readTableRow();
1,472✔
1987
                                        break;
1,472✔
1988
                                default:
1989
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
1990
                                        {
320✔
1991
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
1992
                                        }
320✔
1993
                                        break;
320✔
1994
                        }
1995

1996
                        this._reader.ReadNext();
3,904✔
1997
                }
3,904✔
1998
        }
320✔
1999

2000
        private void readLinkedTableRow(TableEntity.Row row)
2001
        {
1,536✔
2002
                this._reader.ReadNext();
1,536✔
2003

2004
                bool end = false;
1,536✔
2005
                while (this._reader.DxfCode != DxfCode.Start)
12,608✔
2006
                {
12,480✔
2007
                        switch (this._reader.Code)
12,480!
2008
                        {
NEW
2009
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
NEW
2010
                                        break;
×
2011
                                case 90:
2012
                                        break;
1,536✔
2013
                                case 91:
2014
                                        row.CustomData = this._reader.ValueAsInt;
1,408✔
2015
                                        break;
1,408✔
2016
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
2017
                                        this.readCell();
5,376✔
2018
                                        break;
5,376✔
2019
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
2020
                                        this.readCustomData();
1,408✔
2021
                                        break;
1,408✔
2022
                                case 309:
2023
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
2024
                                        break;
1,408✔
2025
                                default:
2026
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
2027
                                        break;
1,344✔
2028
                        }
2029

2030
                        if (end)
12,480✔
2031
                        {
1,408✔
2032
                                break;
1,408✔
2033
                        }
2034

2035
                        this._reader.ReadNext();
11,072✔
2036
                }
11,072✔
2037
        }
1,536✔
2038

2039
        private bool readLookupAction(CadTemplate template, DxfMap map)
2040
        {
84✔
2041
                CadBlockLookupActionTemplate tmp = template as CadBlockLookupActionTemplate;
84✔
2042
                BlockLookupAction action = tmp.CadObject as BlockLookupAction;
84✔
2043

2044
                switch (this._reader.Code)
84✔
2045
                {
2046
                        case 92:
2047
                                tmp.NumberOfRows = this._reader.ValueAsInt;
2✔
2048
                                return true;
2✔
2049
                        case 93:
2050
                                tmp.NumberOfColumns = this._reader.ValueAsInt;
2✔
2051
                                return true;
2✔
2052
                        case 301:
2053
                                return true;
2✔
2054
                        case 302:
2055
                                tmp.RowValues.Add(this._reader.ValueAsString);
30✔
2056
                                return true;
30✔
2057
                        case 303:
2058
                                var col = new BlockLookupAction.ColumnData();
10✔
2059

2060
                                this._reader.ExpectedCode(94);
10✔
2061
                                col.NodeId = this._reader.ValueAsInt;
10✔
2062
                                this._reader.ExpectedCode(95);
10✔
2063
                                col.ValueType = this._reader.ValueAsInt;
10✔
2064
                                this._reader.ExpectedCode(96);
10✔
2065
                                col.Type = this._reader.ValueAsInt;
10✔
2066
                                this._reader.ExpectedCode(282);
10✔
2067
                                col.IsLookupProperty = this._reader.ValueAsShort == 1;
10✔
2068
                                this._reader.ExpectedCode(305);
10✔
2069
                                col.UnmatchedName = this._reader.ValueAsString;
10✔
2070
                                this._reader.ExpectedCode(281);
10✔
2071
                                col.IsReadOnly = this._reader.ValueAsShort == 0;
10✔
2072
                                this._reader.ExpectedCode(304);
10✔
2073
                                col.ConnectionName = this._reader.ValueAsString;
10✔
2074

2075
                                action.Columns.Add(col);
10✔
2076
                                return true;
10✔
2077
                        default:
2078
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLookupAction]))
38✔
2079
                                {
36✔
2080
                                        return this.readBlockAction(template, map);
36✔
2081
                                }
2082
                                return true;
2✔
2083
                }
2084
        }
84✔
2085

2086
        private bool readMaterial(CadTemplate template, DxfMap map)
2087
        {
42,556✔
2088
                CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,556✔
2089
                List<double> arr = null;
42,556✔
2090

2091
                switch (this._reader.Code)
42,556!
2092
                {
2093
                        case 43:
2094
                                arr = new();
1,366✔
2095
                                for (int i = 0; i < 16; i++)
46,444✔
2096
                                {
21,856✔
2097
                                        Debug.Assert(this._reader.Code == 43);
21,856✔
2098

2099
                                        arr.Add(this._reader.ValueAsDouble);
21,856✔
2100

2101
                                        this._reader.ReadNext();
21,856✔
2102
                                }
21,856✔
2103

2104
                                tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,366✔
2105
                                return this.checkObjectEnd(template, map, this.readMaterial);
1,366✔
2106
                        case 47:
NEW
2107
                                arr = new();
×
NEW
2108
                                for (int i = 0; i < 16; i++)
×
UNCOV
2109
                                {
×
NEW
2110
                                        Debug.Assert(this._reader.Code == 47);
×
2111

NEW
2112
                                        arr.Add(this._reader.ValueAsDouble);
×
2113

NEW
2114
                                        this._reader.ReadNext();
×
UNCOV
2115
                                }
×
2116

NEW
2117
                                tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
NEW
2118
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
2119
                        case 49:
2120
                                arr = new();
214✔
2121
                                for (int i = 0; i < 16; i++)
7,276✔
2122
                                {
3,424✔
2123
                                        Debug.Assert(this._reader.Code == 49);
3,424✔
2124

2125
                                        arr.Add(this._reader.ValueAsDouble);
3,424✔
2126

2127
                                        this._reader.ReadNext();
3,424✔
2128
                                }
3,424✔
2129

2130
                                tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
214✔
2131
                                return this.checkObjectEnd(template, map, this.readMaterial);
214✔
2132
                        case 142:
2133
                                arr = new();
214✔
2134
                                for (int i = 0; i < 16; i++)
7,276✔
2135
                                {
3,424✔
2136
                                        Debug.Assert(this._reader.Code == 142);
3,424✔
2137

2138
                                        arr.Add(this._reader.ValueAsDouble);
3,424✔
2139

2140
                                        this._reader.ReadNext();
3,424✔
2141
                                }
3,424✔
2142

2143
                                tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
214✔
2144
                                return this.checkObjectEnd(template, map, this.readMaterial);
214✔
2145
                        case 144:
2146
                                arr = new();
1,174✔
2147
                                for (int i = 0; i < 16; i++)
39,916✔
2148
                                {
18,784✔
2149
                                        Debug.Assert(this._reader.Code == 144);
18,784✔
2150

2151
                                        arr.Add(this._reader.ValueAsDouble);
18,784✔
2152

2153
                                        this._reader.ReadNext();
18,784✔
2154
                                }
18,784✔
2155

2156
                                tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,174✔
2157
                                return this.checkObjectEnd(template, map, this.readMaterial);
1,174✔
2158
                        case 147:
NEW
2159
                                arr = new();
×
NEW
2160
                                for (int i = 0; i < 16; i++)
×
NEW
2161
                                {
×
NEW
2162
                                        Debug.Assert(this._reader.Code == 147);
×
2163

NEW
2164
                                        arr.Add(this._reader.ValueAsDouble);
×
2165

NEW
2166
                                        this._reader.ReadNext();
×
NEW
2167
                                }
×
2168

NEW
2169
                                tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
NEW
2170
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
2171
                        default:
2172
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,588✔
2173
                }
2174
        }
42,556✔
2175

2176
        private bool readMLeaderStyle(CadTemplate template, DxfMap map)
2177
        {
20,268✔
2178
                var tmp = template as CadMLeaderStyleTemplate;
20,268✔
2179

2180
                switch (this._reader.Code)
20,268✔
2181
                {
2182
                        case 179:
2183
                                return true;
246✔
2184
                        case 340:
2185
                                tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
440✔
2186
                                return true;
440✔
2187
                        case 342:
2188
                                tmp.MTextStyleHandle = this._reader.ValueAsHandle;
440✔
2189
                                return true;
440✔
2190
                        default:
2191
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
19,142✔
2192
                }
2193
        }
20,268✔
2194

2195
        private bool readMLineStyle(CadTemplate template, DxfMap map)
2196
        {
3,818✔
2197
                var tmp = template as CadMLineStyleTemplate;
3,818✔
2198
                var mLineStyle = template.CadObject as MLineStyle;
3,818✔
2199

2200
                switch (this._reader.Code)
3,818✔
2201
                {
2202
                        case 6:
2203
                                var t = tmp.ElementTemplates.LastOrDefault();
452✔
2204
                                if (t == null)
452!
NEW
2205
                                {
×
NEW
2206
                                        return true;
×
2207
                                }
2208
                                t.LineTypeName = this._reader.ValueAsString;
452✔
2209
                                return true;
452✔
2210
                        case 49:
2211
                                MLineStyle.Element element = new MLineStyle.Element();
452✔
2212
                                CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
452✔
2213
                                element.Offset = this._reader.ValueAsDouble;
452✔
2214

2215
                                tmp.ElementTemplates.Add(elementTemplate);
452✔
2216
                                mLineStyle.AddElement(element);
452✔
2217
                                return true;
452✔
2218
                        default:
2219
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,914✔
2220
                }
2221
        }
3,818✔
2222

2223
        private CadTemplate readObject()
2224
        {
79,827✔
2225
                this.currentSubclass = string.Empty;
79,827✔
2226
                switch (this._reader.ValueAsString)
79,827!
2227
                {
2228
                        case DxfFileToken.BlkRefObjectContextData:
NEW
2229
                                return this.readObjectCodes<BlockReferenceObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new BlockReferenceObjectContextData()), this.readAnnotScaleObjectContextData);
×
2230
                        case DxfFileToken.MTextAttributeObjectContextData:
NEW
2231
                                return this.readObjectCodes<MTextAttributeObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new MTextAttributeObjectContextData()), this.readAnnotScaleObjectContextData);
×
2232
                        case DxfFileToken.ObjectPlaceholder:
2233
                                return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
214✔
2234
                        case DxfFileToken.ObjectDBColor:
2235
                                return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
192✔
2236
                        case DxfFileToken.ObjectDimensionAssociation:
2237
                                return this.readObjectCodes<DimensionAssociation>(new CadDimensionAssociationTemplate(), this.readDimensionAssociation);
576✔
2238
                        case DxfFileToken.ObjectDictionary:
2239
                                return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
21,912✔
2240
                        case DxfFileToken.ObjectDictionaryWithDefault:
2241
                                return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
214✔
2242
                        case DxfFileToken.ObjectLayout:
2243
                                return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
858✔
2244
                        case DxfFileToken.ObjectPlotSettings:
NEW
2245
                                return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
2246
                        case DxfFileToken.ObjectEvalGraph:
2247
                                return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
468✔
2248
                        case DxfFileToken.ObjectImageDefinition:
2249
                                return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
192✔
2250
                        case DxfFileToken.ObjectDictionaryVar:
2251
                                return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,967✔
2252
                        case DxfFileToken.ObjectPdfDefinition:
2253
                                return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
192✔
2254
                        case DxfFileToken.ObjectSortEntsTable:
2255
                                return this.readSortentsTable();
576✔
2256
                        case DxfFileToken.ObjectImageDefinitionReactor:
2257
                                return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
192✔
2258
                        case DxfFileToken.ObjectProxyObject:
NEW
2259
                                return this.readObjectCodes<ProxyObject>(new CadProxyObjectTemplate(), this.readProxyObject);
×
2260
                        case DxfFileToken.ObjectRasterVariables:
2261
                                return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
192✔
2262
                        case DxfFileToken.ObjectGroup:
2263
                                return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
384✔
2264
                        case DxfFileToken.ObjectGeoData:
2265
                                return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
2266
                        case DxfFileToken.ObjectMaterial:
2267
                                return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,178✔
2268
                        case DxfFileToken.ObjectScale:
2269
                                return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,266✔
2270
                        case DxfFileToken.ObjectTableContent:
2271
                                return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
320✔
2272
                        case DxfFileToken.ObjectVisualStyle:
2273
                                return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,136✔
2274
                        case DxfFileToken.ObjectSpatialFilter:
2275
                                return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
192✔
2276
                        case DxfFileToken.ObjectMLineStyle:
2277
                                return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
226✔
2278
                        case DxfFileToken.ObjectMLeaderStyle:
2279
                                return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
440✔
2280
                        case DxfFileToken.ObjectTableStyle:
2281
                                return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
226✔
2282
                        case DxfFileToken.ObjectXRecord:
2283
                                return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
29,190✔
2284
                        case DxfFileToken.ObjectDynamicBlockPurgePreventer:
2285
                                return this.readObjectCodes<DynamicBlockPurgePreventer>(new CadNonGraphicalObjectTemplate(new DynamicBlockPurgePreventer()), this.readObjectSubclassMap);
212✔
2286
                        case DxfFileToken.ObjectBlockRepresentationData:
2287
                                return this.readObjectCodes<BlockRepresentationData>(new CadBlockRepresentationDataTemplate(), this.readBlockRepresentationData);
294✔
2288
                        case DxfFileToken.ObjectBlockBasePointParameter:
2289
                                return this.readObjectCodes<BlockBasePointParameter>(new CadBlock1PtParameterTemplate(new BlockBasePointParameter()), this.readBlockBasePointParameter);
2✔
2290
                        case DxfFileToken.ObjectBlockGripLocationComponent:
2291
                                return this.readObjectCodes<BlockGripLocationComponent>(new CadBlockGripLocationComponentTemplate(), this.readBlockGripLocationComponent);
1,222✔
2292
                        case DxfFileToken.ObjectBlockVisibilityGrip:
2293
                                return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockGripTemplate(new BlockVisibilityGrip()), this.readBlockGripSubclass);
194✔
2294
                        case DxfFileToken.ObjectBlockXYGrip:
2295
                                return this.readObjectCodes<BlockXYGrip>(new CadBlockGripTemplate(new BlockXYGrip()), this.readBlockGripSubclass);
12✔
2296
                        case DxfFileToken.ObjectBlockVisibilityParameter:
2297
                                return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
194✔
2298
                        case DxfFileToken.ObjectBlockPolarParameter:
2299
                                return this.readObjectCodes<BlockPolarParameter>(new CadBlock2PtParameterTemplate(new BlockPolarParameter()), this.readBlockPolarParameter);
2✔
2300
                        case DxfFileToken.ObjectBlockRotationParameter:
2301
                                return this.readObjectCodes<BlockRotationParameter>(new CadBlockRotationParameterTemplate(), this.readBlockRotationParameter);
2✔
2302
                        case DxfFileToken.ObjectBlockLinearParameter:
2303
                                return this.readObjectCodes<BlockLinearParameter>(new CadBlockLinearParameterTemplate(), this.readBlockLinearParameter);
196✔
2304
                        case DxfFileToken.ObjectBlockLookupParameter:
2305
                                return this.readObjectCodes<BlockLookupParameter>(new CadBlockLookupParameterTemplate(new BlockLookupParameter()), this.readBlockLookupParameter);
4✔
2306
                        case DxfFileToken.ObjectBlockAlignmentParameter:
2307
                                return this.readObjectCodes<BlockAlignmentParameter>(new CadBlock2PtParameterTemplate(new BlockAlignmentParameter()), this.readBlockAlignmentParameter);
2✔
2308
                        case DxfFileToken.ObjectBlockFlipParameter:
2309
                                return this.readObjectCodes<BlockFlipParameter>(new CadBlockFlipParameterTemplate(new BlockFlipParameter()), this.readBlockFlipParameter);
2✔
2310
                        case DxfFileToken.ObjectBlockPointParameter:
2311
                                return this.readObjectCodes<BlockPointParameter>(new CadBlockPointParameterTemplate(), this.readBlockPointParameter);
4✔
2312
                        case DxfFileToken.ObjectBlockXYParameter:
2313
                                return this.readObjectCodes<BlockXYParameter>(new CadBlock2PtParameterTemplate(new BlockXYParameter()), this.readBlockXYParameter);
2✔
2314
                        case DxfFileToken.ObjectBlockFlipGrip:
2315
                                return this.readObjectCodes<BlockFlipGrip>(new CadBlockGripTemplate(new BlockFlipGrip()), this.readBlockGripSubclass);
2✔
2316
                        case DxfFileToken.ObjectBlockLinearGrip:
2317
                                return this.readObjectCodes<BlockLinearGrip>(new CadBlockGripTemplate(new BlockLinearGrip()), this.readBlockGripSubclass);
390✔
2318
                        case DxfFileToken.ObjectBlockLookupGrip:
2319
                                return this.readObjectCodes<BlockLookupGrip>(new CadBlockGripTemplate(new BlockLookupGrip()), this.readBlockGripSubclass);
4✔
2320
                        case DxfFileToken.ObjectBlockRotationGrip:
2321
                                return this.readObjectCodes<BlockRotationGrip>(new CadBlockGripTemplate(new BlockRotationGrip()), this.readBlockGripSubclass);
2✔
2322
                        case DxfFileToken.ObjectBlockPolarGrip:
2323
                                return this.readObjectCodes<BlockPolarGrip>(new CadBlockGripTemplate(new BlockPolarGrip()), this.readBlockGripSubclass);
4✔
2324
                        case DxfFileToken.ObjectBlockAlignmentGrip:
2325
                                return this.readObjectCodes<BlockAlignmentGrip>(new CadBlockGripTemplate(new BlockAlignmentGrip()), this.readBlockGripSubclass);
2✔
2326
                        case DxfFileToken.ObjectBlockLookupAction:
2327
                                return this.readObjectCodes<BlockLookupAction>(new CadBlockLookupActionTemplate(), this.readLookupAction);
2✔
2328
                        case DxfFileToken.ObjectBlockFlipAction:
2329
                                return this.readObjectCodes<BlockFlipAction>(new CadBlockFlipActionTemplate(), this.readBlockFlipAction);
2✔
2330
                        case DxfFileToken.ObjectBlockMoveAction:
2331
                                return this.readObjectCodes<BlockMoveAction>(new CadBlockMoveActionTemplate(), this.readBlockMoveAction);
4✔
2332
                        case DxfFileToken.ObjectBlockScaleAction:
2333
                                return this.readObjectCodes<BlockScaleAction>(new CadBlockScaleActionTemplate(), this.readBlockScaleAction);
194✔
2334
                        case DxfFileToken.ObjectBlockStretchAction:
2335
                                return this.readObjectCodes<BlockStretchAction>(new CadStretchActionBaseTemplate(new BlockStretchAction()), this.readBlockStretchAction);
2✔
2336
                        case DxfFileToken.ObjectBlockPolarStretchAction:
2337
                                return this.readObjectCodes<BlockPolarStretchAction>(new CadPolarStretchActionTemplate(new BlockPolarStretchAction()), this.readBlockPolarStretchAction);
2✔
2338
                        case DxfFileToken.ObjectBlockRotateAction:
2339
                                return this.readObjectCodes<BlockRotationAction>(new CadBlockRotationActionTemplate(), this.readBlockRotationAction);
2✔
2340
                        case DxfFileToken.ObjectBlockArrayAction:
2341
                                return this.readObjectCodes<BlockArrayAction>(new CadBlockActionTemplate(new BlockArrayAction()), this.readBlockArrayAction);
2✔
2342
                        case DxfFileToken.ObjectField:
NEW
2343
                                return this.readObjectCodes<Field>(new CadFieldTemplate(new Field()), this.readField);
×
2344
                        case DxfFileToken.ObjectFieldList:
NEW
2345
                                return this.readObjectCodes<FieldList>(new CadFieldListTemplate(new FieldList()), this.readFieldList);
×
2346
                        default:
2347
                                DxfMap map = DxfMap.Create<CadObject>();
2,564✔
2348
                                CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
2,564✔
2349
                                if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
2,564!
2350
                                {
2,564✔
2351
                                        this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
2,564✔
2352
                                        unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
2,564✔
2353
                                }
2,564✔
2354
                                else
UNCOV
2355
                                {
×
NEW
2356
                                        this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
UNCOV
2357
                                }
×
2358

2359
                                this._reader.ReadNext();
2,564✔
2360

2361
                                do
2362
                                {
219,715✔
2363
                                        if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
219,715!
2364
                                        {
12,864✔
2365
                                                this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
12,864✔
2366
                                                if (isExtendedData)
12,864✔
NEW
2367
                                                        continue;
×
2368
                                        }
12,864✔
2369

2370
                                        this._reader.ReadNext();
219,715✔
2371
                                }
219,715✔
2372
                                while (this._reader.DxfCode != DxfCode.Start);
219,715✔
2373

2374
                                return unknownEntityTemplate;
2,564✔
2375
                }
2376
        }
79,827✔
2377

2378
        private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
2379
        {
25,384✔
2380
                switch (this._reader.Code)
25,384✔
2381
                {
2382
                        default:
2383
                                if (string.IsNullOrEmpty(this.currentSubclass))
25,384✔
2384
                                {
16,166✔
2385
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
16,166✔
2386
                                }
2387
                                else
2388
                                {
9,218✔
2389
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
9,218✔
2390
                                }
2391
                }
2392
        }
25,384✔
2393

2394
        private CadDimensionAssociationTemplate.OsnapPointRefTemplate readOsnapPointRef(DimensionAssociation.OsnapPointRef osnapPoint)
2395
        {
768✔
2396
                var template = new CadDimensionAssociationTemplate.OsnapPointRefTemplate(osnapPoint);
768✔
2397

2398
                this._reader.ReadNext();
768✔
2399

2400
                bool end = false;
768✔
2401
                while (!end)
8,448✔
2402
                {
7,680✔
2403
                        switch (this._reader.Code)
7,680!
2404
                        {
2405
                                case 10:
2406
                                        osnapPoint.OsnapPoint = new XYZ(
768✔
2407
                                                this._reader.ValueAsDouble,
768✔
2408
                                                osnapPoint.OsnapPoint.Y,
768✔
2409
                                                osnapPoint.OsnapPoint.Z
768✔
2410
                                                );
768✔
2411
                                        break;
768✔
2412
                                case 20:
2413
                                        osnapPoint.OsnapPoint = new XYZ(
768✔
2414
                                                osnapPoint.OsnapPoint.X,
768✔
2415
                                                this._reader.ValueAsDouble,
768✔
2416
                                                osnapPoint.OsnapPoint.Z
768✔
2417
                                                );
768✔
2418
                                        break;
768✔
2419
                                case 30:
2420
                                        osnapPoint.OsnapPoint = new XYZ(
768✔
2421
                                        osnapPoint.OsnapPoint.X,
768✔
2422
                                        osnapPoint.OsnapPoint.Y,
768✔
2423
                                        this._reader.ValueAsDouble
768✔
2424
                                        );
768✔
2425
                                        break;
768✔
2426
                                case 40:
2427
                                        osnapPoint.GeometryParameter = this._reader.ValueAsDouble;
768✔
2428
                                        break;
768✔
2429
                                case 72:
2430
                                        osnapPoint.ObjectOsnapType = (ObjectOsnapType)this._reader.ValueAsShort;
768✔
2431
                                        break;
768✔
2432
                                case 73:
2433
                                        osnapPoint.SubentType = (SubentType)this._reader.ValueAsShort;
768✔
2434
                                        break;
768✔
2435
                                case 74:
NEW
2436
                                        osnapPoint.IntersectionSubType = (SubentType)this._reader.ValueAsShort;
×
NEW
2437
                                        break;
×
2438
                                case 75:
2439
                                        osnapPoint.HasLastPointRef = this._reader.ValueAsBool;
768✔
2440
                                        break;
768✔
2441
                                case 91:
2442
                                        osnapPoint.GsMarker = this._reader.ValueAsInt;
768✔
2443
                                        break;
768✔
2444
                                case 92:
NEW
2445
                                        osnapPoint.IntersectionGsMarker = this._reader.ValueAsInt;
×
NEW
2446
                                        break;
×
2447
                                case 331:
2448
                                        template.ObjectHandle = this._reader.ValueAsHandle;
768✔
2449
                                        break;
768✔
2450
                                case 302:
2451
                                case 332:
2452
                                        //What are these?
NEW
2453
                                        break;
×
2454
                                default:
2455
                                        end = true;
768✔
2456
                                        continue;
768✔
2457
                        }
2458

2459
                        this._reader.ReadNext();
6,912✔
2460
                }
6,912✔
2461

2462
                return template;
768✔
2463
        }
768✔
2464

2465
        private ParameterValueSet readParameterValueSet()
2466
        {
206✔
2467
                ParameterValueSet valueSet = new ParameterValueSet();
206✔
2468

2469
                //First 3xx value unknown
2470
                var unknown = this._reader.ValueAsString;
206✔
2471

2472
                this._reader.ReadNext();
206✔
2473
                valueSet.Type = (ParameterValueSetType)this._reader.ValueAsInt;
206✔
2474
                this._reader.ReadNext();
206✔
2475
                valueSet.Minimum = this._reader.ValueAsDouble;
206✔
2476
                this._reader.ReadNext();
206✔
2477
                valueSet.Maximum = this._reader.ValueAsDouble;
206✔
2478
                this._reader.ReadNext();
206✔
2479
                valueSet.Increment = this._reader.ValueAsDouble;
206✔
2480

2481
                this._reader.ReadNext();
206✔
2482
                int n = this._reader.ValueAsInt;
206✔
2483
                for (int i = 0; i < n; i++)
412!
UNCOV
2484
                {
×
NEW
2485
                        this._reader.ReadNext();
×
NEW
2486
                        valueSet.AllowedValues.Add(this._reader.ValueAsDouble);
×
UNCOV
2487
                }
×
2488

2489
                return valueSet;
206✔
2490
        }
206✔
2491

2492
        private bool readPlotSettings(CadTemplate template, DxfMap map)
2493
        {
27,990✔
2494
                switch (this._reader.Code)
27,990✔
2495
                {
2496
                        default:
2497
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
27,990✔
2498
                }
2499
        }
27,990✔
2500

2501
        private bool readProxyObject(CadTemplate template, DxfMap map)
UNCOV
2502
        {
×
NEW
2503
                CadProxyObjectTemplate tmp = template as CadProxyObjectTemplate;
×
NEW
2504
                ProxyObject proxy = template.CadObject as ProxyObject;
×
2505

UNCOV
2506
                switch (this._reader.Code)
×
2507
                {
2508
                        case 90:
2509
                        case 94:
2510
                        //Undocumented
2511
                        case 97:
2512
                        case 71:
NEW
2513
                                return true;
×
2514
                        case 95:
NEW
2515
                                int format = this._reader.ValueAsInt;
×
NEW
2516
                                proxy.Version = (ACadVersion)(format & 0xFFFF);
×
NEW
2517
                                proxy.MaintenanceVersion = (short)(format >> 16);
×
NEW
2518
                                return true;
×
2519
                        case 91:
NEW
2520
                                var classId = this._reader.ValueAsShort;
×
NEW
2521
                                if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
UNCOV
2522
                                {
×
NEW
2523
                                        proxy.DxfClass = dxfClass;
×
UNCOV
2524
                                }
×
UNCOV
2525
                                return true;
×
2526
                        case 161:
UNCOV
2527
                                return true;
×
2528
                        case 162:
UNCOV
2529
                                return true;
×
2530
                        case 310:
NEW
2531
                                if (proxy.BinaryData == null)
×
NEW
2532
                                {
×
NEW
2533
                                        proxy.BinaryData = new MemoryStream();
×
NEW
2534
                                }
×
NEW
2535
                                proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
UNCOV
2536
                                return true;
×
2537
                        case 311:
NEW
2538
                                if (proxy.Data == null)
×
UNCOV
2539
                                {
×
NEW
2540
                                        proxy.Data = new MemoryStream();
×
UNCOV
2541
                                }
×
NEW
2542
                                proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
NEW
2543
                                return true;
×
2544
                        case 330:
2545
                        case 340:
2546
                        case 350:
2547
                        case 360:
NEW
2548
                                tmp.Entries.Add(this._reader.ValueAsHandle);
×
UNCOV
2549
                                return true;
×
2550
                        default:
NEW
2551
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
2552
                }
UNCOV
2553
        }
×
2554

2555
        private bool readScale(CadTemplate template, DxfMap map)
2556
        {
65,190✔
2557
                switch (this._reader.Code)
65,190✔
2558
                {
2559
                        // Undocumented codes
2560
                        case 70:
2561
                                //Always 0
2562
                                return true;
7,266✔
2563
                        default:
2564
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
57,924✔
2565
                }
2566
        }
65,190✔
2567

2568
        private CadTemplate readSortentsTable()
2569
        {
576✔
2570
                SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
2571
                CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
2572

2573
                //Jump the 0 marker
2574
                this._reader.ReadNext();
576✔
2575

2576
                this.readCommonObjectData(template);
576✔
2577

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

2580
                //Jump the 100 marker
2581
                this._reader.ReadNext();
576✔
2582

2583
                (ulong?, ulong?) pair = (null, null);
576✔
2584

2585
                while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2586
                {
3,648✔
2587
                        switch (this._reader.Code)
3,648!
2588
                        {
2589
                                case 5:
2590
                                        pair.Item1 = this._reader.ValueAsHandle;
1,536✔
2591
                                        break;
1,536✔
2592
                                case 330:
2593
                                        template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
2594
                                        break;
576✔
2595
                                case 331:
2596
                                        pair.Item2 = this._reader.ValueAsHandle;
1,536✔
2597
                                        break;
1,536✔
2598
                                default:
NEW
2599
                                        this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
NEW
2600
                                        break;
×
2601
                        }
2602

2603
                        if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
2604
                        {
1,536✔
2605
                                template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
2606
                                pair = (null, null);
1,536✔
2607
                        }
1,536✔
2608

2609
                        this._reader.ReadNext();
3,648✔
2610
                }
3,648✔
2611

2612
                return template;
576✔
2613
        }
576✔
2614

2615
        private bool readSpatialFilter(CadTemplate template, DxfMap map)
2616
        {
4,032✔
2617
                CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
2618
                SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
2619

2620
                switch (this._reader.Code)
4,032✔
2621
                {
2622
                        case 10:
2623
                                filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
2624
                                return true;
384✔
2625
                        case 20:
2626
                                var pt = filter.BoundaryPoints.LastOrDefault();
384✔
2627
                                filter.BoundaryPoints[filter.BoundaryPoints.Count - 1] = new CSMath.XY(pt.X, this._reader.ValueAsDouble);
384✔
2628
                                return true;
384✔
2629
                        case 40:
2630
                                if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
UNCOV
2631
                                {
×
NEW
2632
                                        filter.FrontDistance = this._reader.ValueAsDouble;
×
NEW
2633
                                        tmp.HasFrontPlane = true;
×
NEW
2634
                                        return true;
×
2635
                                }
2636

2637
                                double[] array = new double[16]
384✔
2638
                                {
384✔
2639
                                        0.0, 0.0, 0.0, 0.0,
384✔
2640
                                        0.0, 0.0, 0.0, 0.0,
384✔
2641
                                        0.0, 0.0, 0.0, 0.0,
384✔
2642
                                        0.0, 0.0, 0.0, 1.0
384✔
2643
                                };
384✔
2644

2645
                                for (int i = 0; i < 12; i++)
9,984✔
2646
                                {
4,608✔
2647
                                        array[i] = this._reader.ValueAsDouble;
4,608✔
2648

2649
                                        if (i < 11)
4,608✔
2650
                                        {
4,224✔
2651
                                                this._reader.ReadNext();
4,224✔
2652
                                        }
4,224✔
2653
                                }
4,608✔
2654

2655
                                if (tmp.InsertTransformRead)
384!
UNCOV
2656
                                {
×
NEW
2657
                                        filter.InsertTransform = new Matrix4(array);
×
NEW
2658
                                        tmp.InsertTransformRead = true;
×
UNCOV
2659
                                }
×
2660
                                else
2661
                                {
384✔
2662
                                        filter.InverseInsertTransform = new Matrix4(array);
384✔
2663
                                }
384✔
2664

2665
                                return true;
384✔
2666
                        case 73:
2667
                        default:
2668
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
2669
                }
2670
        }
4,032✔
2671

2672
        private CadBlockVisibilityParameterTemplate.StateTemplate readState()
2673
        {
776✔
2674
                var state = new BlockVisibilityParameter.State();
776✔
2675
                var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
776✔
2676

2677
                List<int> expectedCodes = new List<int>();
776✔
2678
                expectedCodes.Add(303);
776✔
2679
                expectedCodes.Add(94);
776✔
2680
                expectedCodes.Add(95);
776✔
2681

2682
                while (this._reader.DxfCode != DxfCode.Start)
2,328✔
2683
                {
2,328✔
2684
                        expectedCodes.Remove(this._reader.Code);
2,328✔
2685

2686
                        switch (this._reader.Code)
2,328!
2687
                        {
2688
                                case 303:
2689
                                        state.Name = this._reader.ValueAsString;
776✔
2690
                                        break;
776✔
2691
                                case 94:
2692
                                        var count = this._reader.ValueAsInt;
776✔
2693
                                        for (int i = 0; i < count; i++)
2,752✔
2694
                                        {
600✔
2695
                                                this._reader.ReadNext();
600✔
2696
                                                template.EntityHandles.Add(this._reader.ValueAsHandle);
600✔
2697
                                        }
600✔
2698
                                        break;
776✔
2699
                                case 95:
2700
                                        count = this._reader.ValueAsInt;
776✔
2701
                                        for (int i = 0; i < count; i++)
6,160✔
2702
                                        {
2,304✔
2703
                                                this._reader.ReadNext();
2,304✔
2704
                                                template.ExpressionHandles.Add(this._reader.ValueAsHandle);
2,304✔
2705
                                        }
2,304✔
2706
                                        break;
776✔
2707
                                default:
NEW
2708
                                        return template;
×
2709
                        }
2710

2711
                        if (!expectedCodes.Any())
2,328✔
2712
                        {
776✔
2713
                                break;
776✔
2714
                        }
2715

2716
                        this._reader.ReadNext();
1,552✔
2717
                }
1,552✔
2718

2719
                return template;
776✔
2720
        }
776✔
2721

2722
        private void readStyleOverride(CadCellStyleTemplate template)
2723
        {
8,128✔
2724
                var style = template.Format as TableStyle.CellStyle;
8,128✔
2725
                var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
2726
                var mapformat = DxfClassMap.Create(typeof(TableStyle.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
2727

2728
                this._reader.ReadNext();
8,128✔
2729

2730
                bool end = false;
8,128✔
2731
                var currBorder = TableStyle.CellEdgeFlags.Unknown;
8,128✔
2732
                while (this._reader.DxfCode != DxfCode.Start)
89,536✔
2733
                {
89,536✔
2734
                        switch (this._reader.Code)
89,536✔
2735
                        {
2736
                                case 95:
2737
                                        currBorder = (TableStyle.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
2738
                                        break;
11,776✔
2739
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
2740
                                        break;
256✔
2741
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
2742
                                        readContentFormat(new CellContentFormatTemplate(new TableStyle.ContentFormat()));
5,504✔
2743
                                        break;
5,504✔
2744
                                case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
2745
                                        this.readCellMargin(template);
2,816✔
2746
                                        break;
2,816✔
2747
                                case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
2748
                                        TableStyle.CellBorder border = new TableStyle.CellBorder(currBorder);
11,776✔
2749
                                        this.readGridFormat(template, border);
11,776✔
2750
                                        break;
11,776✔
2751
                                case 309:
2752
                                        end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
2753
                                        break;
8,128✔
2754
                                default:
2755
                                        if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
NEW
2756
                                        {
×
NEW
2757
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
NEW
2758
                                        }
×
2759
                                        break;
49,280✔
2760
                        }
2761

2762
                        if (end)
89,536✔
2763
                        {
8,128✔
2764
                                break;
8,128✔
2765
                        }
2766

2767
                        this._reader.ReadNext();
81,408✔
2768
                }
81,408✔
2769
        }
8,128✔
2770

2771
        private void readTableCell(TableEntity.Cell cell)
2772
        {
5,248✔
2773
                var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
2774

2775
                this._reader.ReadNext();
5,248✔
2776

2777
                bool end = false;
5,248✔
2778
                while (this._reader.DxfCode != DxfCode.Start)
16,384✔
2779
                {
16,384✔
2780
                        switch (this._reader.Code)
16,384✔
2781
                        {
2782
                                //Unknown
2783
                                case 40:
2784
                                case 41:
2785
                                        break;
256✔
2786
                                case 309:
2787
                                        end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
2788
                                        break;
5,248✔
2789
                                case 330:
2790
                                        //Unknown handle
2791
                                        break;
128✔
2792
                                default:
2793
                                        if (!this.tryAssignCurrentValue(cell, map))
10,752!
UNCOV
2794
                                        {
×
NEW
2795
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
2796
                                        }
×
2797
                                        break;
10,752✔
2798
                        }
2799

2800
                        if (end)
16,384✔
2801
                        {
5,248✔
2802
                                break;
5,248✔
2803
                        }
2804

2805
                        this._reader.ReadNext();
11,136✔
2806
                }
11,136✔
2807
        }
5,248✔
2808

2809
        private TableEntity.Column readTableColumn()
2810
        {
1,216✔
2811
                this._reader.ReadNext();
1,216✔
2812

2813
                TableEntity.Column column = new TableEntity.Column();
1,216✔
2814

2815
                bool end = false;
1,216✔
2816
                while (this._reader.DxfCode != DxfCode.Start)
3,648!
2817
                {
3,648✔
2818
                        switch (this._reader.Code)
3,648!
2819
                        {
2820
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
2821
                                        this.readLinkedTableColumn(column);
1,216✔
2822
                                        break;
1,216✔
2823
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
2824
                                        this.readFormattedTableColumn(column);
1,216✔
2825
                                        break;
1,216✔
2826
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
2827
                                        this.readTableColumn(column);
1,216✔
2828
                                        end = true;
1,216✔
2829
                                        break;
1,216✔
2830
                                default:
NEW
2831
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
2832
                                        break;
×
2833
                        }
2834

2835
                        if (end)
3,648✔
2836
                        {
1,216✔
2837
                                return column;
1,216✔
2838
                        }
2839

2840
                        this._reader.ReadNext();
2,432✔
2841
                }
2,432✔
2842

NEW
2843
                return column;
×
2844
        }
1,216✔
2845

2846
        private void readTableColumn(TableEntity.Column column)
2847
        {
1,216✔
2848
                this._reader.ReadNext();
1,216✔
2849

2850
                bool end = false;
1,216✔
2851
                while (this._reader.DxfCode != DxfCode.Start)
3,648✔
2852
                {
3,648✔
2853
                        switch (this._reader.Code)
3,648!
2854
                        {
NEW
2855
                                case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
2856
                                        break;
×
2857
                                case 1:
NEW
2858
                                        end = true;
×
NEW
2859
                                        break;
×
2860
                                case 40:
2861
                                        column.Width = this._reader.ValueAsDouble;
1,216✔
2862
                                        break;
1,216✔
2863
                                case 90:
2864
                                        //StyleId
2865
                                        break;
1,216✔
2866
                                case 309:
2867
                                        end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
2868
                                        break;
1,216✔
2869
                                default:
NEW
2870
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
2871
                                        break;
×
2872
                        }
2873

2874
                        if (end)
3,648✔
2875
                        {
1,216✔
2876
                                break;
1,216✔
2877
                        }
2878

2879
                        this._reader.ReadNext();
2,432✔
2880
                }
2,432✔
2881
        }
1,216✔
2882

2883
        private bool readTableContent(CadTemplate template, DxfMap map)
2884
        {
2,368✔
2885
                switch (this._reader.Code)
2,368✔
2886
                {
2887
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
2888
                                this.readTableContentSubclass(template, map);
256✔
2889
                                this.lockPointer = true;
256✔
2890
                                return true;
256✔
2891
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
2892
                                this.readFormattedTableDataSubclass(template, map);
256✔
2893
                                this.lockPointer = true;
256✔
2894
                                return true;
256✔
2895
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
2896
                                this.readLinkedTableDataSubclass(template, map);
320✔
2897
                                this.lockPointer = true;
320✔
2898
                                return true;
320✔
2899
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
2900
                                this.readLinkedData(template, map);
320✔
2901
                                this.lockPointer = true;
320✔
2902
                                return true;
320✔
2903
                        default:
2904
                                return false;
1,216✔
2905
                }
2906
        }
2,368✔
2907

2908
        private void readTableContentSubclass(CadTemplate template, DxfMap map)
2909
        {
256✔
2910
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
2911
                TableContent tableContent = tmp.CadObject;
256✔
2912

2913
                this._reader.ReadNext();
256✔
2914

2915
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
2916
                {
256✔
2917
                        switch (this._reader.Code)
256!
2918
                        {
2919
                                case 340:
2920
                                        tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
2921
                                        break;
256✔
2922
                                default:
NEW
2923
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
NEW
2924
                                        {
×
NEW
2925
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
NEW
2926
                                        }
×
UNCOV
2927
                                        break;
×
2928
                        }
2929

2930
                        this._reader.ReadNext();
256✔
2931
                }
256✔
2932
        }
256✔
2933

2934
        private TableEntity.Row readTableRow()
2935
        {
1,472✔
2936
                this._reader.ReadNext();
1,472✔
2937

2938
                TableEntity.Row row = new TableEntity.Row();
1,472✔
2939

2940
                bool end = false;
1,472✔
2941
                while (this._reader.DxfCode != DxfCode.Start)
11,904✔
2942
                {
11,840✔
2943
                        switch (this._reader.Code)
11,840✔
2944
                        {
2945
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
2946
                                        this.readLinkedTableRow(row);
1,536✔
2947
                                        break;
1,536✔
2948
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
2949
                                        this.readFormattedTableRow(row);
1,408✔
2950
                                        break;
1,408✔
2951
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
2952
                                        this.readTableRow(row);
1,408✔
2953
                                        end = true;
1,408✔
2954
                                        break;
1,408✔
2955
                                default:
2956
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
2957
                                        break;
7,488✔
2958
                        }
2959

2960
                        if (end)
11,840✔
2961
                        {
1,408✔
2962
                                return row;
1,408✔
2963
                        }
2964

2965
                        this._reader.ReadNext();
10,432✔
2966
                }
10,432✔
2967

2968
                return row;
64✔
2969
        }
1,472✔
2970

2971
        private void readTableRow(TableEntity.Row row)
2972
        {
1,408✔
2973
                this._reader.ReadNext();
1,408✔
2974

2975
                bool end = false;
1,408✔
2976
                while (this._reader.DxfCode != DxfCode.Start)
4,224✔
2977
                {
4,224✔
2978
                        switch (this._reader.Code)
4,224!
2979
                        {
2980
                                case 40:
2981
                                        row.Height = this._reader.ValueAsDouble;
1,408✔
2982
                                        break;
1,408✔
2983
                                case 90:
2984
                                        //styleID
2985
                                        break;
1,408✔
2986
                                case 309:
2987
                                        end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
2988
                                        break;
1,408✔
2989
                                default:
NEW
2990
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
NEW
2991
                                        break;
×
2992
                        }
2993

2994
                        if (end)
4,224✔
2995
                        {
1,408✔
2996
                                break;
1,408✔
2997
                        }
2998

2999
                        this._reader.ReadNext();
2,816✔
3000
                }
2,816✔
3001
        }
1,408✔
3002

3003
        private bool readTableStyle(CadTemplate template, DxfMap map)
3004
        {
20,487✔
3005
                var tmp = template as CadTableStyleTemplate;
20,487✔
3006
                var style = tmp.CadObject;
20,487✔
3007
                var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
20,487✔
3008

3009
                switch (this._reader.Code)
20,487!
3010
                {
3011
                        case 7:
3012
                                tmp.CreateCurrentCellStyleTemplate();
678✔
3013
                                tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
678✔
3014
                                return true;
678✔
3015
                        case 94:
NEW
3016
                                cellStyle.Alignment = this._reader.ValueAsInt;
×
UNCOV
3017
                                return true;
×
3018
                        case 62:
3019
                                cellStyle.Color = new Color(this._reader.ValueAsShort);
678✔
3020
                                return true;
678✔
3021
                        case 63:
3022
                                cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
678✔
3023
                                return true;
678✔
3024
                        case 140:
3025
                                cellStyle.TextHeight = this._reader.ValueAsDouble;
678✔
3026
                                return true;
678✔
3027
                        case 170:
3028
                                cellStyle.CellAlignment = (TableStyle.CellAlignmentType)this._reader.ValueAsShort;
678✔
3029
                                return true;
678✔
3030
                        case 283:
3031
                                cellStyle.IsFillColorOn = this._reader.ValueAsBool;
678✔
3032
                                return true;
678✔
3033
                        case 90:
3034
                                cellStyle.Type = (TableStyle.CellStyleType)this._reader.ValueAsShort;
486✔
3035
                                return true;
486✔
3036
                        case 91:
3037
                                cellStyle.StyleClass = (TableStyle.CellStyleClass)this._reader.ValueAsShort;
486✔
3038
                                return true;
486✔
3039
                        case 1:
3040
                                //Undocumented
3041
                                return true;
450✔
3042
                        case 274:
3043
                                cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3044
                                return true;
678✔
3045
                        case 275:
3046
                                cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3047
                                return true;
678✔
3048
                        case 276:
3049
                                cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3050
                                return true;
678✔
3051
                        case 277:
3052
                                cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3053
                                return true;
678✔
3054
                        case 278:
3055
                                cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3056
                                return true;
678✔
3057
                        case 279:
3058
                                cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
678✔
3059
                                return true;
678✔
3060
                        case 284:
3061
                                cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3062
                                return true;
678✔
3063
                        case 285:
3064
                                cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3065
                                return true;
678✔
3066
                        case 286:
3067
                                cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3068
                                return true;
678✔
3069
                        case 287:
3070
                                cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3071
                                return true;
678✔
3072
                        case 288:
3073
                                cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3074
                                return true;
678✔
3075
                        case 289:
3076
                                cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
678✔
3077
                                return true;
678✔
3078
                        case 64:
3079
                                cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3080
                                return true;
678✔
3081
                        case 65:
3082
                                cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3083
                                return true;
678✔
3084
                        case 66:
3085
                                cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3086
                                return true;
678✔
3087
                        case 67:
3088
                                cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3089
                                return true;
678✔
3090
                        case 68:
3091
                                cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3092
                                return true;
678✔
3093
                        case 69:
3094
                                cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
678✔
3095
                                return true;
678✔
3096
                        default:
3097
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,793✔
3098
                }
3099
        }
20,487✔
3100

3101
        private bool readVisualStyle(CadTemplate template, DxfMap map)
3102
        {
432,532✔
3103
                switch (this._reader.Code)
432,532✔
3104
                {
3105
                        // Undocumented codes
3106
                        case 176:
3107
                        case 177:
3108
                        case 420:
3109
                                return true;
148,874✔
3110
                        default:
3111
                                //Avoid noise while is not implemented
3112
                                return true;
283,658✔
3113
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
3114
                }
3115
        }
432,532✔
3116

3117
        private bool readXRecord(CadTemplate template, DxfMap map)
3118
        {
114,328✔
3119
                CadXRecordTemplate tmp = template as CadXRecordTemplate;
114,328✔
3120

3121
                switch (this._reader.Code)
114,328✔
3122
                {
3123
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
29,190✔
3124
                                this.readXRecordEntries(tmp);
29,190✔
3125
                                return true;
29,190✔
3126
                        default:
3127
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
85,138✔
3128
                }
3129
        }
114,328✔
3130

3131
        private void readXRecordEntries(CadXRecordTemplate template)
3132
        {
29,190✔
3133
                this._reader.ReadNext();
29,190✔
3134

3135
                while (this._reader.DxfCode != DxfCode.Start)
2,413,094✔
3136
                {
2,383,904✔
3137
                        switch (this._reader.GroupCodeValue)
2,383,904✔
3138
                        {
3139
                                case GroupCodeValueType.Point3D:
3140
                                        var code = this._reader.Code;
3,026✔
3141
                                        var x = this._reader.ValueAsDouble;
3,026✔
3142
                                        this._reader.ReadNext();
3,026✔
3143
                                        var y = this._reader.ValueAsDouble;
3,026✔
3144
                                        this._reader.ReadNext();
3,026✔
3145
                                        var z = this._reader.ValueAsDouble;
3,026✔
3146
                                        XYZ pt = new XYZ(x, y, z);
3,026✔
3147
                                        template.CadObject.CreateEntry(code, pt);
3,026✔
3148
                                        break;
3,026✔
3149
                                case GroupCodeValueType.Handle:
3150
                                case GroupCodeValueType.ObjectId:
3151
                                case GroupCodeValueType.ExtendedDataHandle:
3152
                                        template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,058✔
3153
                                        break;
12,058✔
3154
                                default:
3155
                                        template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,368,820✔
3156
                                        break;
2,368,820✔
3157
                        }
3158

3159
                        this._reader.ReadNext();
2,383,904✔
3160
                }
2,383,904✔
3161
        }
29,190✔
3162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc