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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

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

0.0
/src/ACadSharp/Classes/DxfClassCollection.cs
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using System.Linq;
5

6
namespace ACadSharp.Classes
7
{
8
        public class DxfClassCollection : ICollection<DxfClass>
9
        {
10
                /// <inheritdoc/>
11
                public int Count { get { return this._entries.Count; } }
×
12

13
                /// <inheritdoc/>
14
                public bool IsReadOnly => false;
×
15

16
                public Dictionary<string, DxfClass> _entries = new Dictionary<string, DxfClass>(StringComparer.OrdinalIgnoreCase);
×
17

18
                /// <summary>
19
                /// Adds or updates the classes in a specific document 
20
                /// </summary>
21
                /// <param name="doc"></param>
22
                public static void UpdateDxfClasses(CadDocument doc)
23
                {
×
24
                        //AcDbDictionaryWithDefault
25
                        doc.Classes.AddOrUpdate(new DxfClass
×
26
                        {
×
27
                                CppClassName = "AcDbDictionaryWithDefault",
×
28
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
29
                                DwgVersion = (ACadVersion)22,
×
30
                                DxfName = "ACDBDICTIONARYWDFLT",
×
31
                                ItemClassId = 499,
×
32
                                MaintenanceVersion = 42,
×
33
                                ProxyFlags = ProxyFlags.R13FormatProxy,
×
34
                                WasZombie = false,
×
35
                        });
×
36

37
                        //AcDbPlaceHolder
38
                        doc.Classes.AddOrUpdate(new DxfClass
×
39
                        {
×
40
                                CppClassName = "AcDbPlaceHolder",
×
41
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
42
                                DwgVersion = (ACadVersion)0,
×
43
                                DxfName = "ACDBPLACEHOLDER",
×
44
                                ItemClassId = 499,
×
45
                                MaintenanceVersion = 0,
×
46
                                ProxyFlags = ProxyFlags.None,
×
47
                                WasZombie = false,
×
48
                        });
×
49

50
                        //AcDbLayout
51
                        doc.Classes.AddOrUpdate(new DxfClass
×
52
                        {
×
53
                                CppClassName = "AcDbLayout",
×
54
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
55
                                DwgVersion = (ACadVersion)0,
×
56
                                DxfName = "LAYOUT",
×
57
                                ItemClassId = 499,
×
58
                                MaintenanceVersion = 0,
×
59
                                ProxyFlags = ProxyFlags.None,
×
60
                                WasZombie = false,
×
61
                        });
×
62

63
                        //AcDbDictionaryVar
64
                        doc.Classes.AddOrUpdate(new DxfClass
×
65
                        {
×
66
                                CppClassName = "AcDbDictionaryVar",
×
67
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
68
                                DwgVersion = (ACadVersion)20,
×
69
                                DxfName = "DICTIONARYVAR",
×
70
                                ItemClassId = 499,
×
71
                                MaintenanceVersion = 0,
×
72
                                ProxyFlags = ProxyFlags.None,
×
73
                                WasZombie = false,
×
74
                        });
×
75

76
                        //AcDbTableStyle
77
                        doc.Classes.AddOrUpdate(new DxfClass
×
78
                        {
×
79
                                CppClassName = "AcDbTableStyle",
×
80
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
81
                                DwgVersion = ACadVersion.AC1018,
×
82
                                DxfName = "TABLESTYLE",
×
83
                                ItemClassId = 499,
×
84
                                MaintenanceVersion = 0,
×
85
                                ProxyFlags = (ProxyFlags)4095,
×
86
                                WasZombie = false,
×
87
                        });
×
88

89
                        //AcDbMaterial
90
                        doc.Classes.AddOrUpdate(new DxfClass
×
91
                        {
×
92
                                CppClassName = "AcDbMaterial",
×
93
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
94
                                DwgVersion = 0,
×
95
                                DxfName = "MATERIAL",
×
96
                                ItemClassId = 499,
×
97
                                MaintenanceVersion = 0,
×
98
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
99
                                WasZombie = false,
×
100
                        });
×
101

102
                        //AcDbVisualStyle
103
                        doc.Classes.AddOrUpdate(new DxfClass
×
104
                        {
×
105
                                CppClassName = "AcDbVisualStyle",
×
106
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
107
                                DwgVersion = ACadVersion.AC1021,
×
108
                                DxfName = "VISUALSTYLE",
×
109
                                ItemClassId = 499,
×
110
                                MaintenanceVersion = 0,
×
111
                                ProxyFlags = (ProxyFlags)4095,
×
112
                                WasZombie = false,
×
113
                        });
×
114

115
                        //AcDbScale
116
                        doc.Classes.AddOrUpdate(new DxfClass
×
117
                        {
×
118
                                CppClassName = "AcDbScale",
×
119
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
120
                                DwgVersion = ACadVersion.AC1021,
×
121
                                DxfName = "SCALE",
×
122
                                ItemClassId = 499,
×
123
                                MaintenanceVersion = 1,
×
124
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
125
                                WasZombie = false,
×
126
                        });
×
127

128
                        //AcDbMLeaderStyle
129
                        doc.Classes.AddOrUpdate(new DxfClass
×
130
                        {
×
131
                                CppClassName = "AcDbMLeaderStyle",
×
132
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
133
                                DwgVersion = ACadVersion.AC1021,
×
134
                                DxfName = "MLEADERSTYLE",
×
135
                                ItemClassId = 499,
×
136
                                MaintenanceVersion = 25,
×
137
                                ProxyFlags = (ProxyFlags)4095,
×
138
                                WasZombie = false,
×
139
                        });
×
140

141
                        //AcDbCellStyleMap
142
                        doc.Classes.AddOrUpdate(new DxfClass
×
143
                        {
×
144
                                CppClassName = "AcDbCellStyleMap",
×
145
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
146
                                DwgVersion = ACadVersion.AC1021,
×
147
                                DxfName = "CELLSTYLEMAP",
×
148
                                ItemClassId = 499,
×
149
                                MaintenanceVersion = 25,
×
150
                                ProxyFlags = ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
151
                                WasZombie = false,
×
152
                        });
×
153

154
                        //ExAcXREFPanelObject
155
                        doc.Classes.AddOrUpdate(new DxfClass
×
156
                        {
×
157
                                CppClassName = "ExAcXREFPanelObject",
×
158
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
159
                                DwgVersion = 0,
×
160
                                DxfName = "EXACXREFPANELOBJECT",
×
161
                                ItemClassId = 499,
×
162
                                MaintenanceVersion = 0,
×
163
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
164
                                WasZombie = false,
×
165
                        });
×
166

167
                        //AcDbImpNonPersistentObjectsCollection
168
                        doc.Classes.AddOrUpdate(new DxfClass
×
169
                        {
×
170
                                CppClassName = "AcDbImpNonPersistentObjectsCollection",
×
171
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
172
                                DwgVersion = 0,
×
173
                                DxfName = "NPOCOLLECTION",
×
174
                                ItemClassId = 499,
×
175
                                MaintenanceVersion = 0,
×
176
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
177
                                WasZombie = false,
×
178
                        });
×
179

180
                        //AcDbLayerIndex
181
                        doc.Classes.AddOrUpdate(new DxfClass
×
182
                        {
×
183
                                CppClassName = "AcDbLayerIndex",
×
184
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
185
                                DwgVersion = 0,
×
186
                                DxfName = "LAYER_INDEX",
×
187
                                ItemClassId = 499,
×
188
                                MaintenanceVersion = 0,
×
189
                                ProxyFlags = ProxyFlags.None,
×
190
                                WasZombie = false,
×
191
                        });
×
192

193
                        //AcDbSpatialIndex
194
                        doc.Classes.AddOrUpdate(new DxfClass
×
195
                        {
×
196
                                CppClassName = "AcDbSpatialIndex",
×
197
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
198
                                DwgVersion = 0,
×
199
                                DxfName = "SPATIAL_INDEX",
×
200
                                ItemClassId = 499,
×
201
                                MaintenanceVersion = 0,
×
202
                                ProxyFlags = ProxyFlags.None,
×
203
                                WasZombie = false,
×
204
                        });
×
205

206
                        //AcDbIdBuffer
207
                        doc.Classes.AddOrUpdate(new DxfClass
×
208
                        {
×
209
                                CppClassName = "AcDbIdBuffer",
×
210
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
211
                                DwgVersion = ACadVersion.AC1014,
×
212
                                DxfName = "IDBUFFER",
×
213
                                ItemClassId = 499,
×
214
                                MaintenanceVersion = 0,
×
215
                                ProxyFlags = ProxyFlags.R13FormatProxy,
×
216
                                WasZombie = false,
×
217
                        });
×
218

219
                        //AcDbSectionViewStyle
220
                        doc.Classes.AddOrUpdate(new DxfClass
×
221
                        {
×
222
                                CppClassName = "AcDbSectionViewStyle",
×
223
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
224
                                DwgVersion = 0,
×
225
                                DxfName = "ACDBSECTIONVIEWSTYLE",
×
226
                                ItemClassId = 499,
×
227
                                MaintenanceVersion = 0,
×
228
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
229
                                WasZombie = false,
×
230
                        });
×
231

232
                        //AcDbDetailViewStyle
233
                        doc.Classes.AddOrUpdate(new DxfClass
×
234
                        {
×
235
                                CppClassName = "AcDbDetailViewStyle",
×
236
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
237
                                DwgVersion = 0,
×
238
                                DxfName = "ACDBDETAILVIEWSTYLE",
×
239
                                ItemClassId = 499,
×
240
                                MaintenanceVersion = 0,
×
241
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
242
                                WasZombie = false,
×
243
                        });
×
244

245
                        //AcDbSubDMesh
246
                        doc.Classes.AddOrUpdate(new DxfClass
×
247
                        {
×
248
                                CppClassName = "AcDbSubDMesh",
×
249
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
250
                                DwgVersion = 0,
×
251
                                DxfName = "MESH",
×
252
                                ItemClassId = 498,
×
253
                                MaintenanceVersion = 0,
×
254
                                ProxyFlags = ProxyFlags.None,
×
255
                                WasZombie = false,
×
256
                        });
×
257

258
                        //AcDbSortentsTable
259
                        doc.Classes.AddOrUpdate(new DxfClass
×
260
                        {
×
261
                                CppClassName = "AcDbSortentsTable",
×
262
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
263
                                DwgVersion = ACadVersion.AC1014,
×
264
                                DxfName = "SORTENTSTABLE",
×
265
                                ItemClassId = 499,
×
266
                                MaintenanceVersion = 0,
×
267
                                ProxyFlags = ProxyFlags.None,
×
268
                                WasZombie = false,
×
269
                        });
×
270

271
                        //AcDbTextObjectContextData
272
                        doc.Classes.AddOrUpdate(new DxfClass
×
273
                        {
×
274
                                CppClassName = "AcDbTextObjectContextData",
×
275
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
276
                                DwgVersion = 0,
×
277
                                DxfName = "ACDB_TEXTOBJECTCONTEXTDATA_CLASS",
×
278
                                ItemClassId = 499,
×
279
                                MaintenanceVersion = 0,
×
280
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
281
                                WasZombie = false,
×
282
                        });
×
283

284
                        //AcDbWipeout
285
                        doc.Classes.AddOrUpdate(new DxfClass
×
286
                        {
×
287
                                ApplicationName = "WipeOut",
×
288
                                CppClassName = "AcDbWipeout",
×
289
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
290
                                DwgVersion = ACadVersion.AC1015,
×
291
                                DxfName = "WIPEOUT",
×
292
                                ItemClassId = 498,
×
293
                                MaintenanceVersion = 0,
×
294
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.TransformAllowed | ProxyFlags.ColorChangeAllowed | ProxyFlags.LayerChangeAllowed | ProxyFlags.LinetypeChangeAllowed | ProxyFlags.LinetypeScaleChangeAllowed | ProxyFlags.VisibilityChangeAllowed | ProxyFlags.R13FormatProxy,
×
295
                                WasZombie = false,
×
296
                        });
×
297

298
                        //AcDbWipeoutVariables
299
                        doc.Classes.AddOrUpdate(new DxfClass
×
300
                        {
×
301
                                ApplicationName = "WipeOut",
×
302
                                CppClassName = "AcDbWipeoutVariables",
×
303
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
304
                                DwgVersion = ACadVersion.AC1015,
×
305
                                DxfName = "WIPEOUTVARIABLES",
×
306
                                ItemClassId = 499,
×
307
                                MaintenanceVersion = 0,
×
308
                                ProxyFlags = ProxyFlags.R13FormatProxy,
×
309
                                WasZombie = false,
×
310
                        });
×
311

312
                        //AcDbDimAssoc
313
                        doc.Classes.AddOrUpdate(new DxfClass
×
314
                        {
×
315
                                ApplicationName = "AcDbDimAssoc",
×
316
                                CppClassName = "AcDbDimAssoc",
×
317
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
318
                                DwgVersion = 0,
×
319
                                DxfName = "DIMASSOC",
×
320
                                ItemClassId = 499,
×
321
                                MaintenanceVersion = 0,
×
322
                                ProxyFlags = ProxyFlags.None,
×
323
                                WasZombie = false,
×
324
                        });
×
325

326
                        //AcDbTable
327
                        doc.Classes.AddOrUpdate(new DxfClass
×
328
                        {
×
329
                                CppClassName = "AcDbTable",
×
330
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
331
                                DwgVersion = ACadVersion.AC1018,
×
332
                                DxfName = "ACAD_TABLE",
×
333
                                ItemClassId = 498,
×
334
                                MaintenanceVersion = 0,
×
335
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
336
                                WasZombie = false,
×
337
                        });
×
338

339
                        //AcDbTableContent
340
                        doc.Classes.AddOrUpdate(new DxfClass
×
341
                        {
×
342
                                CppClassName = "AcDbTableContent",
×
343
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
344
                                DwgVersion = ACadVersion.AC1018,
×
345
                                DxfName = "TABLECONTENT",
×
346
                                ItemClassId = 499,
×
347
                                MaintenanceVersion = 21,
×
348
                                ProxyFlags = ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
349
                                WasZombie = false,
×
350
                        });
×
351

352
                        //AcDbTableGeometry
353
                        doc.Classes.AddOrUpdate(new DxfClass
×
354
                        {
×
355
                                CppClassName = "AcDbTableGeometry",
×
356
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
357
                                DwgVersion = 0,
×
358
                                DxfName = "TABLEGEOMETRY",
×
359
                                ItemClassId = 499,
×
360
                                MaintenanceVersion = 0,
×
361
                                ProxyFlags = ProxyFlags.CloningAllowed | ProxyFlags.DisablesProxyWarningDialog,
×
362
                                WasZombie = false,
×
363
                        });
×
364

365
                        //AcDbRasterImage
366
                        doc.Classes.AddOrUpdate(new DxfClass
×
367
                        {
×
368
                                CppClassName = DxfSubclassMarker.RasterImage,
×
369
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
370
                                DwgVersion = ACadVersion.AC1014,
×
371
                                DxfName = DxfFileToken.EntityImage,
×
372
                                ItemClassId = 498,
×
373
                                MaintenanceVersion = 0,
×
374
                                ProxyFlags = ProxyFlags.EraseAllowed | ProxyFlags.TransformAllowed | ProxyFlags.ColorChangeAllowed | ProxyFlags.LayerChangeAllowed | ProxyFlags.LinetypeChangeAllowed | ProxyFlags.LinetypeScaleChangeAllowed | ProxyFlags.VisibilityChangeAllowed | ProxyFlags.R13FormatProxy,
×
375
                        WasZombie = false,
×
376
                        });
×
377

378
                        //AcDbRasterImageDef
379
                        doc.Classes.AddOrUpdate(new DxfClass
×
380
                        {
×
381
                                CppClassName = DxfSubclassMarker.RasterImageDef,
×
382
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
383
                                DwgVersion = ACadVersion.AC1014,
×
384
                                DxfName = DxfFileToken.ObjectImageDefinition,
×
385
                                ItemClassId = 499,
×
386
                                MaintenanceVersion = 0,
×
387
                                ProxyFlags = ProxyFlags.R13FormatProxy,
×
388
                                WasZombie = false,
×
389
                        });
×
390

391
                        //AcDbColor
392
                        doc.Classes.AddOrUpdate(new DxfClass
×
393
                        {
×
394
                                CppClassName = DxfSubclassMarker.DbColor,
×
395
                                ClassNumber = (short)(500 + doc.Classes.Count),
×
396
                                DwgVersion = ACadVersion.AC1015,
×
397
                                DxfName = DxfFileToken.ObjectDBColor,
×
398
                                ItemClassId = 499,
×
399
                                MaintenanceVersion = 14,
×
400
                                ProxyFlags = ProxyFlags.None,
×
401
                                WasZombie = false,
×
402
                        });
×
403
                }
×
404

405
                /// <summary>
406
                /// Add a dxf class to the collection if the <see cref="DxfClass.DxfName"/> is not present
407
                /// </summary>
408
                /// <param name="item"></param>
409
                public void Add(DxfClass item)
410
                {
×
411
                        this._entries.Add(item.DxfName, item);
×
412
                }
×
413

414
                /// <summary>
415
                /// Add a dxf class to the collection or updates the existing one if the <see cref="DxfClass.DxfName"/> is already in the collection
416
                /// </summary>
417
                /// <param name="item"></param>
418
                public void AddOrUpdate(DxfClass item)
419
                {
×
420
                        if (_entries.TryGetValue(item.DxfName, out DxfClass result))
×
421
                        {
×
422
                                result.InstanceCount = item.InstanceCount;
×
423
                        }
×
424
                        else
425
                        {
×
426
                                _entries.Add(item.DxfName, item);
×
427
                        }
×
428
                }
×
429

430
                /// <summary>
431
                /// Gets the dxf class associated with <see cref="DxfClass.DxfName"/>
432
                /// </summary>
433
                /// <param name="dxfname"></param>
434
                /// <returns></returns>
435
                public DxfClass GetByName(string dxfname)
436
                {
×
437
                        if (this._entries.TryGetValue(dxfname, out DxfClass result))
×
438
                        {
×
439
                                return result;
×
440
                        }
441
                        else
442
                        {
×
443
                                return null;
×
444
                        }
445
                }
×
446

447
                /// <summary>
448
                /// Gets the dxf class associated with <see cref="DxfClass.DxfName"/>
449
                /// </summary>
450
                /// <param name="dxfname"></param>
451
                /// <param name="result"></param>
452
                /// <returns>true if the Collection contains an element with the specified key; otherwise, false.</returns>
453
                public bool TryGetByName(string dxfname, out DxfClass result)
454
                {
×
455
                        return this._entries.TryGetValue(dxfname, out result);
×
456
                }
×
457

458
                /// <inheritdoc/>
459
                public void Clear()
460
                {
×
461
                        _entries.Clear();
×
462
                }
×
463

464
                /// <summary>
465
                /// Determines whether the Collection contains a specific <see cref="DxfClass.DxfName"/>
466
                /// </summary>
467
                /// <param name="dxfname"></param>
468
                /// <returns></returns>
469
                public bool Contains(string dxfname)
470
                {
×
471
                        return this._entries.ContainsKey(dxfname);
×
472
                }
×
473

474
                /// <inheritdoc/>
475
                public bool Contains(DxfClass item)
476
                {
×
477
                        return _entries.Values.Contains(item);
×
478
                }
×
479

480
                /// <inheritdoc/>
481
                public void CopyTo(DxfClass[] array, int arrayIndex)
482
                {
×
483
                        throw new NotImplementedException();
×
484
                }
485

486
                /// <inheritdoc/>
487
                public IEnumerator<DxfClass> GetEnumerator()
488
                {
×
489
                        return _entries.Values.GetEnumerator();
×
490
                }
×
491

492
                /// <inheritdoc/>
493
                public bool Remove(DxfClass item)
494
                {
×
495
                        return this._entries.Remove(item.DxfName);
×
496
                }
×
497

498
                /// <inheritdoc/>
499
                IEnumerator IEnumerable.GetEnumerator()
500
                {
×
501
                        return this._entries.Values.GetEnumerator();
×
502
                }
×
503
        }
504
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc