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

DomCR / ACadSharp / 30620967299

31 Jul 2026 09:43AM UTC coverage: 76.789% (+1.0%) from 75.789%
30620967299

push

github

web-flow
Merge pull request #1151 from DomCR/AcDbEvalGraph

Dynamic parameters

9805 of 13766 branches covered (71.23%)

Branch coverage included in aggregate %.

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

80 existing lines in 13 files now uncovered.

34904 of 44457 relevant lines covered (78.51%)

142257.11 hits per line

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

76.54
/src/ACadSharp/XData/ExtendedDataDictionary.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
        /// <summary>
10
        /// Dictionary containing all the extended data for a giving <see cref="CadObject"/>,
11
        /// each entry is identified with an <see cref="AppId"/> key that identifies the application that
12
        /// has added the collection of Extended Data (XData) into the object.
13
        /// </summary>
14
        public class ExtendedDataDictionary : IEnumerable<KeyValuePair<AppId, ExtendedData>>
15
        {
16
                public CadDocument Document { get { return this.Owner?.Document; } }
14,115!
17

18
                /// <summary>
19
                /// Owner of the Extended Data dictionary.
20
                /// </summary>
21
                public CadObject Owner { get; }
4,705✔
22

23
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
5,671,567✔
24

25
                /// <summary>
26
                /// Default constructor.
27
                /// </summary>
28
                /// <param name="owner"></param>
29
                public ExtendedDataDictionary(CadObject owner)
5,671,567✔
30
                {
5,671,567✔
31
                        this.Owner = owner;
5,671,567✔
32
                }
5,671,567✔
33

34
                /// <summary>
35
                /// Add an empty entry of ExtendedData for a given <see cref="AppId"/>.
36
                /// </summary>
37
                /// <param name="app"></param>
38
                public void Add(AppId app)
39
                {
×
40
                        this.Add(app, new ExtendedData());
×
41
                }
×
42

43
                /// <summary>
44
                /// Adds a new application with the specified name.
45
                /// </summary>
46
                /// <param name="appName">The name of the application to add. Cannot be null or empty.</param>
47
                public void Add(string appName)
48
                {
×
49
                        this.Add(appName, new ExtendedData());
×
50
                }
×
51

52
                /// <summary>
53
                /// Adds an application and its associated extended data to the collection.
54
                /// </summary>
55
                /// <param name="appName">The name of the application to add. Cannot be null or empty.</param>
56
                /// <param name="extendedData">The extended data associated with the application. Cannot be null.</param>
57
                public void Add(string appName, ExtendedData extendedData)
58
                {
9✔
59
                        this.Add(new AppId(appName), extendedData);
9✔
60
                }
9✔
61

62
                /// <summary>
63
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
64
                /// </summary>
65
                /// <param name="app"></param>
66
                /// <param name="extendedData"></param>
67
                public void Add(AppId app, ExtendedData extendedData)
68
                {
2,867✔
69
                        if (this.Document != null)
2,867✔
70
                        {
1,434✔
71
                                if (this.Document.AppIds.TryGetValue(app.Name, out AppId existing))
1,434✔
72
                                {
1,030✔
73
                                        this._data.Add(existing, extendedData);
1,030✔
74
                                }
1,030✔
75
                                else
76
                                {
404✔
77
                                        this.Document.AppIds.Add(app);
404✔
78
                                        this._data.Add(app, extendedData);
404✔
79
                                }
404✔
80
                        }
1,434✔
81
                        else
82
                        {
1,433✔
83
                                this._data.Add(app, extendedData);
1,433✔
84
                        }
1,433✔
85
                }
2,867✔
86

87
                /// <summary>
88
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
89
                /// </summary>
90
                /// <param name="app">The AppId object.</param>
91
                /// <param name="records">The ExtendedData records.</param>
92
                public void Add(AppId app, IEnumerable<ExtendedDataRecord> records)
93
                {
63,137✔
94
                        this._data.Add(app, new ExtendedData(records));
63,137✔
95
                }
63,137✔
96

97
                /// <summary>
98
                /// Clear all Dictionary entries.
99
                /// </summary>
100
                public void Clear()
101
                {
2,060✔
102
                        this._data.Clear();
2,060✔
103
                }
2,060✔
104

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

114
                /// <summary>
115
                /// Check whether a given AppId is in the Dictionary.
116
                /// </summary>
117
                /// <param name="name">The AppId name.</param>
118
                public bool ContainsKeyName(string name)
119
                {
1✔
120
                        return this._data.Keys.Select(k => k.Name).Contains(name);
2✔
121
                }
1✔
122

123
                /// <summary>
124
                /// Get the Extended data for a given <see cref="AppId"/> name.
125
                /// </summary>
126
                /// <param name="name"></param>
127
                /// <returns></returns>
128
                public ExtendedData Get(string name)
129
                {
4✔
130
                        return this.GetExtendedDataByName()[name];
4✔
131
                }
4✔
132

133
                /// <summary>
134
                /// Get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
135
                /// </summary>
136
                /// <param name="app">The AppId object.</param>
137
                public ExtendedData Get(AppId app)
UNCOV
138
                {
×
UNCOV
139
                        return this._data[app];
×
UNCOV
140
                }
×
141

142
                /// <inheritdoc/>
143
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
144
                {
1,150,319✔
145
                        return this._data.GetEnumerator();
1,150,319✔
146
                }
1,150,319✔
147

148
                /// <inheritdoc/>
149
                IEnumerator IEnumerable.GetEnumerator()
150
                {
2✔
151
                        return this._data.GetEnumerator();
2✔
152
                }
2✔
153

154
                /// <summary>
155
                /// Get the different extended data by it's name.
156
                /// </summary>
157
                /// <returns></returns>
158
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
159
                {
605✔
160
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
1,595✔
161
                }
605✔
162

163
                /// <summary>
164
                /// Adds the specified extended data for the given application name if it does not already exist, and returns the
165
                /// stored extended data.
166
                /// </summary>
167
                /// <remarks>If extended data for the specified application name already exists, this method does not
168
                /// overwrite it. Use this method to ensure that only one instance of extended data is associated with each
169
                /// application name.</remarks>
170
                /// <param name="appName">The name of the application to associate with the extended data. Cannot be null.</param>
171
                /// <param name="extendedData">The extended data to add if no data is already associated with the specified application name. Cannot be null.</param>
172
                /// <returns>The existing extended data associated with the specified application name if it was already present; otherwise,
173
                /// the newly added extended data.</returns>
174
                public ExtendedData TryAdd(string appName, ExtendedData extendedData)
175
                {
9✔
176
                        if (this.TryGet(appName, out ExtendedData existing))
9!
177
                        {
×
178
                                return existing;
×
179
                        }
180
                        else
181
                        {
9✔
182
                                this.Add(appName, extendedData);
9✔
183
                                return extendedData;
9✔
184
                        }
185
                }
9✔
186

187
                /// <summary>
188
                /// Try to get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
189
                /// </summary>
190
                /// <param name="app">The AppId object.</param>
191
                /// <param name="value">ExtendedData object.</param>
192
                public bool TryGet(AppId app, out ExtendedData value)
193
                {
×
194
                        return this._data.TryGetValue(app, out value);
×
195
                }
×
196

197
                /// <summary>
198
                /// Try to get ExtendedData for a specific <see cref="AppId"/> name from the Dictionary.
199
                /// </summary>
200
                /// <param name="name">The AppId name.</param>
201
                /// <param name="value">ExtendedData object.</param>
202
                /// <returns>true, if found.</returns>
203
                public bool TryGet(string name, out ExtendedData value)
204
                {
601✔
205
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
601✔
206
                }
601✔
207
        }
208
}
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