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

DomCR / ACadSharp / 17737836230

15 Sep 2025 03:12PM UTC coverage: 2.092% (-76.2%) from 78.245%
17737836230

push

github

web-flow
Merge pull request #790 from DomCR/addflag-refactor

addflag refactor

141 of 9225 branches covered (1.53%)

Branch coverage included in aggregate %.

0 of 93 new or added lines in 10 files covered. (0.0%)

24910 existing lines in 372 files now uncovered.

724 of 32119 relevant lines covered (2.25%)

5.76 hits per line

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

0.0
/src/ACadSharp/DxfClassMap.cs
1
using ACadSharp.Attributes;
2
using System;
3
using System.Collections.Concurrent;
4
using System.Reflection;
5

6
namespace ACadSharp
7
{
8
        public class DxfClassMap : DxfMapBase
9
        {
10
                /// <summary>
11
                /// Cache of created DXF mapped classes.
12
                /// </summary>
UNCOV
13
                private static readonly ConcurrentDictionary<Type, DxfClassMap> _cache = new ConcurrentDictionary<Type, DxfClassMap>();
×
14

UNCOV
15
                public DxfClassMap() : base() { }
×
16

UNCOV
17
                public DxfClassMap(string name) : base()
×
UNCOV
18
                {
×
UNCOV
19
                        this.Name = name;
×
UNCOV
20
                }
×
21

22
                /// <summary>
23
                /// Creates a DXF map of the passed type.
24
                /// </summary>
25
                /// <remarks>
26
                ///   Will return a cached instance if it exists.  if not, it will be created on call.
27
                /// Use the <see cref="ClearCache"/> method to clear the cache and force a new mapping to be created.
28
                /// </remarks>
29
                /// <typeparam name="T">Type of CadObject to map.</typeparam>
30
                /// <returns>Mapped class</returns>
31
                public static DxfClassMap Create<T>()
32
                        where T : CadObject
UNCOV
33
                {
×
UNCOV
34
                        Type type = typeof(T);
×
35

UNCOV
36
                        if (_cache.TryGetValue(type, out var classMap))
×
UNCOV
37
                        {
×
UNCOV
38
                                return classMap;
×
39
                        }
40

UNCOV
41
                        classMap = new DxfClassMap();
×
42

UNCOV
43
                        var att = type.GetCustomAttribute<DxfSubClassAttribute>();
×
UNCOV
44
                        if (att == null)
×
45
                                throw new ArgumentException($"{type.FullName} is not a dxf subclass");
×
46

UNCOV
47
                        classMap.Name = type.GetCustomAttribute<DxfSubClassAttribute>().ClassName;
×
48

UNCOV
49
                        addClassProperties(classMap, type);
×
50

UNCOV
51
                        DxfSubClassAttribute baseAtt = type.BaseType.GetCustomAttribute<DxfSubClassAttribute>();
×
UNCOV
52
                        if (baseAtt != null && baseAtt.IsEmpty)
×
UNCOV
53
                        {
×
54
                                //Properties in the table seem to be embeded to the hinerit type
UNCOV
55
                                addClassProperties(classMap, type.BaseType);
×
UNCOV
56
                        }
×
57

UNCOV
58
                        _cache.TryAdd(type, classMap);
×
59

UNCOV
60
                        return classMap;
×
UNCOV
61
                }
×
62

63

64
                /// <summary>
65
                /// Clears the map cache.
66
                /// </summary>
67
                public void ClearCache()
68
                {
×
69
                        _cache.Clear();
×
70
                }
×
71

72
                public override string ToString()
73
                {
×
74
                        return $"DxfClassMap:{this.Name}";
×
75
                }
×
76
        }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc