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

DomCR / ACadSharp / 17737836230

15 Sep 2025 03:12PM UTC coverage: 2.092% (-76.2%) from 78.245%
17737836230

push

github

web-flow
Merge pull request #790 from DomCR/addflag-refactor

addflag refactor

141 of 9225 branches covered (1.53%)

Branch coverage included in aggregate %.

0 of 93 new or added lines in 10 files covered. (0.0%)

24910 existing lines in 372 files now uncovered.

724 of 32119 relevant lines covered (2.25%)

5.76 hits per line

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

0.0
/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>
UNCOV
19
                public CadObject Owner { get; }
×
20

UNCOV
21
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
×
22

23
                /// <summary>
24
                /// Default constructor.
25
                /// </summary>
26
                /// <param name="owner"></param>
UNCOV
27
                public ExtendedDataDictionary(CadObject owner)
×
UNCOV
28
                {
×
UNCOV
29
                        this.Owner = owner;
×
UNCOV
30
                }
×
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)
37
                {
×
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)
UNCOV
47
                {
×
UNCOV
48
                        if (this.Owner.Document != null)
×
UNCOV
49
                        {
×
UNCOV
50
                                if (this.Owner.Document.AppIds.TryGetValue(app.Name, out AppId existing))
×
UNCOV
51
                                {
×
UNCOV
52
                                        this._data.Add(existing, extendedData);
×
UNCOV
53
                                }
×
54
                                else
UNCOV
55
                                {
×
UNCOV
56
                                        this.Owner.Document.AppIds.Add(app);
×
UNCOV
57
                                        this._data.Add(app, extendedData);
×
UNCOV
58
                                }
×
UNCOV
59
                        }
×
60
                        else
UNCOV
61
                        {
×
UNCOV
62
                                this._data.Add(app, extendedData);
×
UNCOV
63
                        }
×
UNCOV
64
                }
×
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)
UNCOV
72
                {
×
UNCOV
73
                        this._data.Add(app, new ExtendedData(records));
×
UNCOV
74
                }
×
75

76
                /// <summary>
77
                /// Get the different extended data by it's name.
78
                /// </summary>
79
                /// <returns></returns>
80
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
UNCOV
81
                {
×
UNCOV
82
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
×
UNCOV
83
                }
×
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)
UNCOV
91
                {
×
UNCOV
92
                        return this.GetExtendedDataByName()[name];
×
UNCOV
93
                }
×
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)
UNCOV
100
                {
×
UNCOV
101
                        return this._data[app];
×
UNCOV
102
                }
×
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)
110
                {
×
111
                        return this._data.TryGetValue(app, out value);
×
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)
UNCOV
121
                {
×
UNCOV
122
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
×
UNCOV
123
                }
×
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)
130
                {
×
131
                        return this._data.ContainsKey(app);
×
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)
UNCOV
139
                {
×
UNCOV
140
                        return this._data.Keys.Select(k => k.Name).Contains(name);
×
UNCOV
141
                }
×
142

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

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

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

© 2026 Coveralls, Inc