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

DomCR / ACadSharp / 20457200384

23 Dec 2025 09:42AM UTC coverage: 76.854% (-0.3%) from 77.148%
20457200384

Pull #924

github

web-flow
Merge fde81b197 into 886606be2
Pull Request #924: issue 923 - dim style override

7696 of 10903 branches covered (70.59%)

Branch coverage included in aggregate %.

49 of 176 new or added lines in 8 files covered. (27.84%)

123 existing lines in 7 files now uncovered.

28361 of 36013 relevant lines covered (78.75%)

159201.5 hits per line

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

85.48
/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
                /// <summary>
17
                /// Owner of the Extended Data dictionary.
18
                /// </summary>
19
                public CadObject Owner { get; }
6,039✔
20

21
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
4,156,407✔
22

23
                /// <summary>
24
                /// Default constructor.
25
                /// </summary>
26
                /// <param name="owner"></param>
27
                public ExtendedDataDictionary(CadObject owner)
4,156,407✔
28
                {
4,156,407✔
29
                        this.Owner = owner;
4,156,407✔
30
                }
4,156,407✔
31

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

41
                /// <summary>
42
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
43
                /// </summary>
44
                /// <param name="app"></param>
45
                /// <param name="extendedData"></param>
46
                public void Add(AppId app, ExtendedData extendedData)
47
                {
3,667✔
48
                        if (this.Owner.Document != null)
3,667✔
49
                        {
1,838✔
50
                                if (this.Owner.Document.AppIds.TryGetValue(app.Name, out AppId existing))
1,838✔
51
                                {
1,304✔
52
                                        this._data.Add(existing, extendedData);
1,304✔
53
                                }
1,304✔
54
                                else
55
                                {
534✔
56
                                        this.Owner.Document.AppIds.Add(app);
534✔
57
                                        this._data.Add(app, extendedData);
534✔
58
                                }
534✔
59
                        }
1,838✔
60
                        else
61
                        {
1,829✔
62
                                this._data.Add(app, extendedData);
1,829✔
63
                        }
1,829✔
64
                }
3,667✔
65

66
                /// <summary>
67
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
68
                /// </summary>
69
                /// <param name="app">The AppId object.</param>
70
                /// <param name="records">The ExtendedData records.</param>
71
                public void Add(AppId app, IEnumerable<ExtendedDataRecord> records)
72
                {
65,139✔
73
                        this._data.Add(app, new ExtendedData(records));
65,139✔
74
                }
65,139✔
75

76
                /// <summary>
77
                /// Get the different extended data by it's name.
78
                /// </summary>
79
                /// <returns></returns>
80
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
81
                {
277✔
82
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
831✔
83
                }
277✔
84

85
                /// <summary>
86
                /// Get the Extended data for a given <see cref="AppId"/> name.
87
                /// </summary>
88
                /// <param name="name"></param>
89
                /// <returns></returns>
90
                public ExtendedData Get(string name)
91
                {
4✔
92
                        return this.GetExtendedDataByName()[name];
4✔
93
                }
4✔
94

95
                /// <summary>
96
                /// Get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
97
                /// </summary>
98
                /// <param name="app">The AppId object.</param>
99
                public ExtendedData Get(AppId app)
100
                {
39✔
101
                        return this._data[app];
39✔
102
                }
39✔
103

104
                /// <summary>
105
                /// Try to get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
106
                /// </summary>
107
                /// <param name="app">The AppId object.</param>
108
                /// <param name="value">ExtendedData object.</param>
109
                public bool TryGet(AppId app, out ExtendedData value)
UNCOV
110
                {
×
UNCOV
111
                        return this._data.TryGetValue(app, out value);
×
UNCOV
112
                }
×
113

114
                /// <summary>
115
                /// Try to get ExtendedData for a specific <see cref="AppId"/> name from the Dictionary.
116
                /// </summary>
117
                /// <param name="name">The AppId name.</param>
118
                /// <param name="value">ExtendedData object.</param>
119
                /// <returns>true, if found.</returns>
120
                public bool TryGet(string name, out ExtendedData value)
121
                {
273✔
122
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
273✔
123
                }
273✔
124

125
                /// <summary>
126
                /// Check whether a given AppId is in the Dictionary.
127
                /// </summary>
128
                /// <param name="app">The AppId object.</param>
129
                public bool ContainsKey(AppId app)
UNCOV
130
                {
×
UNCOV
131
                        return this._data.ContainsKey(app);
×
UNCOV
132
                }
×
133

134
                /// <summary>
135
                /// Check whether a given AppId is in the Dictionary.
136
                /// </summary>
137
                /// <param name="name">The AppId name.</param>
138
                public bool ContainsKeyName(string name)
139
                {
1✔
140
                        return this._data.Keys.Select(k => k.Name).Contains(name);
2✔
141
                }
1✔
142

143
                /// <summary>
144
                /// Clear all Dictionary entries.
145
                /// </summary>
146
                public void Clear()
147
                {
2,641✔
148
                        this._data.Clear();
2,641✔
149
                }
2,641✔
150

151
                /// <inheritdoc/>
152
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
153
                {
1,122,530✔
154
                        return this._data.GetEnumerator();
1,122,530✔
155
                }
1,122,530✔
156

157
                /// <inheritdoc/>
158
                IEnumerator IEnumerable.GetEnumerator()
159
                {
2✔
160
                        return this._data.GetEnumerator();
2✔
161
                }
2✔
162
        }
163
}
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