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

DomCR / ACadSharp / 20690577669

04 Jan 2026 09:05AM UTC coverage: 77.04% (+0.02%) from 77.022%
20690577669

push

github

web-flow
Merge pull request #924 from DomCR/issue-923_dimstyle-override

issue 923 - dim style override

7788 of 10971 branches covered (70.99%)

Branch coverage included in aggregate %.

156 of 225 new or added lines in 10 files covered. (69.33%)

4 existing lines in 3 files now uncovered.

28530 of 36171 relevant lines covered (78.88%)

158791.55 hits per line

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

80.25
/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; } }
18,120!
17

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

23
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
4,156,420✔
24

25
                /// <summary>
26
                /// Default constructor.
27
                /// </summary>
28
                /// <param name="owner"></param>
29
                public ExtendedDataDictionary(CadObject owner)
4,156,420✔
30
                {
4,156,420✔
31
                        this.Owner = owner;
4,156,420✔
32
                }
4,156,420✔
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)
NEW
48
                {
×
NEW
49
                        this.Add(appName, new ExtendedData());
×
NEW
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
                {
1✔
59
                        this.Add(new AppId(appName), extendedData);
1✔
60
                }
1✔
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
                {
3,668✔
69
                        if (this.Document != null)
3,668✔
70
                        {
1,838✔
71
                                if (this.Document.AppIds.TryGetValue(app.Name, out AppId existing))
1,838✔
72
                                {
1,304✔
73
                                        this._data.Add(existing, extendedData);
1,304✔
74
                                }
1,304✔
75
                                else
76
                                {
534✔
77
                                        this.Document.AppIds.Add(app);
534✔
78
                                        this._data.Add(app, extendedData);
534✔
79
                                }
534✔
80
                        }
1,838✔
81
                        else
82
                        {
1,830✔
83
                                this._data.Add(app, extendedData);
1,830✔
84
                        }
1,830✔
85
                }
3,668✔
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
                {
65,139✔
94
                        this._data.Add(app, new ExtendedData(records));
65,139✔
95
                }
65,139✔
96

97
                /// <summary>
98
                /// Clear all Dictionary entries.
99
                /// </summary>
100
                public void Clear()
101
                {
2,641✔
102
                        this._data.Clear();
2,641✔
103
                }
2,641✔
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)
NEW
110
                {
×
NEW
111
                        return this._data.ContainsKey(app);
×
NEW
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)
138
                {
39✔
139
                        return this._data[app];
39✔
140
                }
39✔
141

142
                /// <inheritdoc/>
143
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
144
                {
1,122,530✔
145
                        return this._data.GetEnumerator();
1,122,530✔
146
                }
1,122,530✔
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
                {
282✔
160
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
842✔
161
                }
282✔
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
                {
1✔
176
                        if (this.TryGet(appName, out ExtendedData existing))
1!
NEW
177
                        {
×
NEW
178
                                return existing;
×
179
                        }
180
                        else
181
                        {
1✔
182
                                this.Add(appName, extendedData);
1✔
183
                                return extendedData;
1✔
184
                        }
185
                }
1✔
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)
UNCOV
193
                {
×
NEW
194
                        return this._data.TryGetValue(app, out value);
×
UNCOV
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
                {
278✔
205
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
278✔
206
                }
278✔
207
        }
208
}
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