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

DomCR / ACadSharp / 20459304191

23 Dec 2025 11:18AM UTC coverage: 76.82% (-0.3%) from 77.148%
20459304191

Pull #924

github

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

7697 of 10907 branches covered (70.57%)

Branch coverage included in aggregate %.

8 of 148 new or added lines in 8 files covered. (5.41%)

2 existing lines in 2 files now uncovered.

28370 of 36043 relevant lines covered (78.71%)

159070.31 hits per line

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

74.65
/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

NEW
23
                public CadDocument Document { get { return this.Owner?.Document; } }
×
24

25
                /// <summary>
26
                /// Default constructor.
27
                /// </summary>
28
                /// <param name="owner"></param>
29
                public ExtendedDataDictionary(CadObject owner)
4,156,407✔
30
                {
4,156,407✔
31
                        this.Owner = owner;
4,156,407✔
32
                }
4,156,407✔
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
                public void Add(string appName)
NEW
44
                {
×
NEW
45
                        this.Add(appName, new ExtendedData());
×
NEW
46
                }
×
47

48
                public void Add(string appName, ExtendedData extendedData)
NEW
49
                {
×
NEW
50
                        this.Add(new AppId(appName), extendedData);
×
NEW
51
                }
×
52

53
                /// <summary>
54
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
55
                /// </summary>
56
                /// <param name="app"></param>
57
                /// <param name="extendedData"></param>
58
                public void Add(AppId app, ExtendedData extendedData)
59
                {
3,667✔
60
                        if (this.Owner.Document != null)
3,667✔
61
                        {
1,838✔
62
                                if (this.Owner.Document.AppIds.TryGetValue(app.Name, out AppId existing))
1,838✔
63
                                {
1,304✔
64
                                        this._data.Add(existing, extendedData);
1,304✔
65
                                }
1,304✔
66
                                else
67
                                {
534✔
68
                                        this.Owner.Document.AppIds.Add(app);
534✔
69
                                        this._data.Add(app, extendedData);
534✔
70
                                }
534✔
71
                        }
1,838✔
72
                        else
73
                        {
1,829✔
74
                                this._data.Add(app, extendedData);
1,829✔
75
                        }
1,829✔
76
                }
3,667✔
77

78
                /// <summary>
79
                /// Add ExtendedData for a specific <see cref="AppId"/> to the Dictionary.
80
                /// </summary>
81
                /// <param name="app">The AppId object.</param>
82
                /// <param name="records">The ExtendedData records.</param>
83
                public void Add(AppId app, IEnumerable<ExtendedDataRecord> records)
84
                {
65,139✔
85
                        this._data.Add(app, new ExtendedData(records));
65,139✔
86
                }
65,139✔
87

88
                /// <summary>
89
                /// Get the different extended data by it's name.
90
                /// </summary>
91
                /// <returns></returns>
92
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
93
                {
277✔
94
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
831✔
95
                }
277✔
96

97
                /// <summary>
98
                /// Get the Extended data for a given <see cref="AppId"/> name.
99
                /// </summary>
100
                /// <param name="name"></param>
101
                /// <returns></returns>
102
                public ExtendedData Get(string name)
103
                {
4✔
104
                        return this.GetExtendedDataByName()[name];
4✔
105
                }
4✔
106

107
                /// <summary>
108
                /// Get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
109
                /// </summary>
110
                /// <param name="app">The AppId object.</param>
111
                public ExtendedData Get(AppId app)
112
                {
39✔
113
                        return this._data[app];
39✔
114
                }
39✔
115

116
                /// <summary>
117
                /// Try to get ExtendedData for a specific <see cref="AppId"/> from the Dictionary.
118
                /// </summary>
119
                /// <param name="app">The AppId object.</param>
120
                /// <param name="value">ExtendedData object.</param>
121
                public bool TryGet(AppId app, out ExtendedData value)
122
                {
×
123
                        return this._data.TryGetValue(app, out value);
×
124
                }
×
125

126
                /// <summary>
127
                /// Try to get ExtendedData for a specific <see cref="AppId"/> name from the Dictionary.
128
                /// </summary>
129
                /// <param name="name">The AppId name.</param>
130
                /// <param name="value">ExtendedData object.</param>
131
                /// <returns>true, if found.</returns>
132
                public bool TryGet(string name, out ExtendedData value)
133
                {
273✔
134
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
273✔
135
                }
273✔
136

137
                /// <summary>
138
                /// Check whether a given AppId is in the Dictionary.
139
                /// </summary>
140
                /// <param name="app">The AppId object.</param>
141
                public bool ContainsKey(AppId app)
142
                {
×
143
                        return this._data.ContainsKey(app);
×
144
                }
×
145

146
                /// <summary>
147
                /// Check whether a given AppId is in the Dictionary.
148
                /// </summary>
149
                /// <param name="name">The AppId name.</param>
150
                public bool ContainsKeyName(string name)
151
                {
1✔
152
                        return this._data.Keys.Select(k => k.Name).Contains(name);
2✔
153
                }
1✔
154

155
                /// <summary>
156
                /// Clear all Dictionary entries.
157
                /// </summary>
158
                public void Clear()
159
                {
2,641✔
160
                        this._data.Clear();
2,641✔
161
                }
2,641✔
162

163
                /// <inheritdoc/>
164
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
165
                {
1,122,530✔
166
                        return this._data.GetEnumerator();
1,122,530✔
167
                }
1,122,530✔
168

169
                /// <inheritdoc/>
170
                IEnumerator IEnumerable.GetEnumerator()
171
                {
2✔
172
                        return this._data.GetEnumerator();
2✔
173
                }
2✔
174
        }
175
}
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