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

DomCR / ACadSharp / 12865655172

20 Jan 2025 10:09AM UTC coverage: 75.956% (+0.04%) from 75.915%
12865655172

Pull #537

github

web-flow
Merge e122cb537 into 8b7e44749
Pull Request #537: Issue 534 XData link cad document

5273 of 7666 branches covered (68.78%)

Branch coverage included in aggregate %.

50 of 55 new or added lines in 5 files covered. (90.91%)

11 existing lines in 1 file now uncovered.

21058 of 27000 relevant lines covered (77.99%)

39170.54 hits per line

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

77.46
/src/ACadSharp/XData/ExtendedDataCollection.cs
1
using ACadSharp.Tables;
2
using System;
3
using System.Collections;
4
using System.Collections.Generic;
5
using System.Linq;
6

7
namespace ACadSharp.XData
8
{
9
        public class ExtendedDataDictionary : IEnumerable<KeyValuePair<AppId, ExtendedData>>
10
        {
11
                [Obsolete]
12
                public IEnumerable<KeyValuePair<AppId, ExtendedData>> Entries { get { return this._data; } }
28,917✔
13

14
                public CadObject Owner { get; }
1,590✔
15

16
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
666,774✔
17

18
                public ExtendedDataDictionary(CadObject owner)
666,774✔
19
                {
666,774✔
20
                        this.Owner = owner;
666,774✔
21
                }
666,774✔
22

23
                public void Add(AppId app)
NEW
24
                {
×
NEW
25
                        this.Add(app, new ExtendedData());
×
NEW
26
                }
×
27

28
                public void Add(AppId app, ExtendedData extendedData)
29
                {
966✔
30
                        if (this.Owner.Document != null)
966✔
31
                        {
543✔
32
                                if (this.Owner.Document.AppIds.TryGetValue(app.Name, out AppId existing))
543✔
33
                                {
462✔
34
                                        this._data.Add(existing, extendedData);
462✔
35
                                }
462✔
36
                                else
37
                                {
81✔
38
                                        this.Owner.Document.AppIds.Add(app);
81✔
39
                                        this._data.Add(app, extendedData);
81✔
40
                                }
81✔
41
                        }
543✔
42
                        else
43
                        {
423✔
44
                                this._data.Add(app, extendedData);
423✔
45
                        }
423✔
46
                }
966✔
47

48
                /// <summary>
49
                /// Add ExtendedData for a specific AppId to the Dictionary.
50
                /// </summary>
51
                /// <param name="app">The AppId object.</param>
52
                /// <param name="records">The ExtendedData records.</param>
53
                public void Add(AppId app, IEnumerable<ExtendedDataRecord> records)
54
                {
22,713✔
55
                        this._data.Add(app, new ExtendedData(records));
22,713✔
56
                }
22,713✔
57

58
                /// <summary>
59
                /// Get the different extended data by it's name.
60
                /// </summary>
61
                /// <returns></returns>
62
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
63
                {
2✔
64
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value);
6✔
65
                }
2✔
66

67
                public ExtendedData Get(string name)
68
                {
2✔
69
                        return this.GetExtendedDataByName()[name];
2✔
70
                }
2✔
71

72
                /// <summary>
73
                /// Get ExtendedData for a specific AppId from the Dictionary.
74
                /// </summary>
75
                /// <param name="app">The AppId object.</param>
76
                public ExtendedData Get(AppId app)
77
                {
6✔
78
                        return this._data[app];
6✔
79
                }
6✔
80

81
                /// <summary>
82
                /// Try to get ExtendedData for a specific AppId from the Dictionary.
83
                /// </summary>
84
                /// <param name="app">The AppId object.</param>
85
                /// <param name="value">ExtendedData object.</param>
86
                public bool TryGet(AppId app, out ExtendedData value)
UNCOV
87
                {
×
UNCOV
88
                        return this._data.TryGetValue(app, out value);
×
UNCOV
89
                }
×
90

91
                public bool TryGet(string name, out ExtendedData value)
92
                {
26✔
93
                        AppId app = this._data.Keys.FirstOrDefault(k => k.Name == name);
52✔
94
                        if (app == null)
26!
UNCOV
95
                        {
×
UNCOV
96
                                value = null;
×
UNCOV
97
                                return false;
×
98
                        }
99

100
                        value = this._data[app];
26✔
101
                        return true;
26✔
102
                }
26✔
103

104
                /// <summary>
105
                /// Check whether a AppId is given in the Dictionary.
106
                /// </summary>
107
                /// <param name="app">The AppId object.</param>
108
                public bool ContainsKey(AppId app)
UNCOV
109
                {
×
UNCOV
110
                        return this._data.ContainsKey(app);
×
111
                }
×
112

113
                public bool ContainsKeyName(string name)
UNCOV
114
                {
×
UNCOV
115
                        return this._data.Keys.Select(k => k.Name).Contains(name);
×
UNCOV
116
                }
×
117

118
                /// <summary>
119
                /// Clear all Dictionary entries.
120
                /// </summary>
121
                public void Clear()
122
                {
9,084✔
123
                        this._data.Clear();
9,084✔
124
                }
9,084✔
125

126
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
127
                {
161,627✔
128
                        return this._data.GetEnumerator();
161,627✔
129
                }
161,627✔
130

131
                IEnumerator IEnumerable.GetEnumerator()
132
                {
1✔
133
                        return this._data.GetEnumerator();
1✔
134
                }
1✔
135
        }
136
}
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