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

DomCR / ACadSharp / 29143042407

11 Jul 2026 06:34AM UTC coverage: 2.912% (-73.0%) from 75.918%
29143042407

push

github

web-flow
Merge pull request #1146 from ilCosmico/acds-read-payload-anchor

Read the AcDs payload area offset from the data segment header

264 of 12999 branches covered (2.03%)

Branch coverage included in aggregate %.

0 of 30 new or added lines in 1 file covered. (0.0%)

31243 existing lines in 465 files now uncovered.

1337 of 41984 relevant lines covered (3.18%)

5.38 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
        {
UNCOV
16
                public CadDocument Document { get { return this.Owner?.Document; } }
×
17

18
                /// <summary>
19
                /// Owner of the Extended Data dictionary.
20
                /// </summary>
UNCOV
21
                public CadObject Owner { get; }
×
22

UNCOV
23
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
×
24

25
                /// <summary>
26
                /// Default constructor.
27
                /// </summary>
28
                /// <param name="owner"></param>
UNCOV
29
                public ExtendedDataDictionary(CadObject owner)
×
UNCOV
30
                {
×
UNCOV
31
                        this.Owner = owner;
×
UNCOV
32
                }
×
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)
UNCOV
58
                {
×
UNCOV
59
                        this.Add(new AppId(appName), extendedData);
×
UNCOV
60
                }
×
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)
UNCOV
68
                {
×
UNCOV
69
                        if (this.Document != null)
×
UNCOV
70
                        {
×
UNCOV
71
                                if (this.Document.AppIds.TryGetValue(app.Name, out AppId existing))
×
UNCOV
72
                                {
×
UNCOV
73
                                        this._data.Add(existing, extendedData);
×
UNCOV
74
                                }
×
75
                                else
UNCOV
76
                                {
×
UNCOV
77
                                        this.Document.AppIds.Add(app);
×
UNCOV
78
                                        this._data.Add(app, extendedData);
×
UNCOV
79
                                }
×
UNCOV
80
                        }
×
81
                        else
UNCOV
82
                        {
×
UNCOV
83
                                this._data.Add(app, extendedData);
×
UNCOV
84
                        }
×
UNCOV
85
                }
×
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)
UNCOV
93
                {
×
UNCOV
94
                        this._data.Add(app, new ExtendedData(records));
×
UNCOV
95
                }
×
96

97
                /// <summary>
98
                /// Clear all Dictionary entries.
99
                /// </summary>
100
                public void Clear()
UNCOV
101
                {
×
UNCOV
102
                        this._data.Clear();
×
UNCOV
103
                }
×
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)
UNCOV
119
                {
×
UNCOV
120
                        return this._data.Keys.Select(k => k.Name).Contains(name);
×
UNCOV
121
                }
×
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)
UNCOV
129
                {
×
UNCOV
130
                        return this.GetExtendedDataByName()[name];
×
UNCOV
131
                }
×
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()
UNCOV
144
                {
×
UNCOV
145
                        return this._data.GetEnumerator();
×
UNCOV
146
                }
×
147

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

154
                /// <summary>
155
                /// Get the different extended data by it's name.
156
                /// </summary>
157
                /// <returns></returns>
158
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
UNCOV
159
                {
×
UNCOV
160
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value, StringComparer.OrdinalIgnoreCase);
×
UNCOV
161
                }
×
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)
UNCOV
175
                {
×
UNCOV
176
                        if (this.TryGet(appName, out ExtendedData existing))
×
177
                        {
×
178
                                return existing;
×
179
                        }
180
                        else
UNCOV
181
                        {
×
UNCOV
182
                                this.Add(appName, extendedData);
×
UNCOV
183
                                return extendedData;
×
184
                        }
UNCOV
185
                }
×
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)
UNCOV
204
                {
×
UNCOV
205
                        return this.GetExtendedDataByName().TryGetValue(name, out value);
×
UNCOV
206
                }
×
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