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

DomCR / ACadSharp / 12865715230

20 Jan 2025 10:12AM UTC coverage: 75.976% (+0.06%) from 75.915%
12865715230

Pull #537

github

web-flow
Merge 47dc2e249 into 8b7e44749
Pull Request #537: Issue 534 XData link cad document

5274 of 7666 branches covered (68.8%)

Branch coverage included in aggregate %.

53 of 57 new or added lines in 5 files covered. (92.98%)

2 existing lines in 1 file now uncovered.

21063 of 26999 relevant lines covered (78.01%)

39172.5 hits per line

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

77.14
/src/ACadSharp/XData/ExtendedDataCollection.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
        public class ExtendedDataDictionary : IEnumerable<KeyValuePair<AppId, ExtendedData>>
10
        {
11
                public CadObject Owner { get; }
1,590✔
12

13
                private Dictionary<AppId, ExtendedData> _data = new Dictionary<AppId, ExtendedData>();
666,774✔
14

15
                public ExtendedDataDictionary(CadObject owner)
666,774✔
16
                {
666,774✔
17
                        this.Owner = owner;
666,774✔
18
                }
666,774✔
19

20
                public void Add(AppId app)
21
                {
×
NEW
22
                        this.Add(app, new ExtendedData());
×
NEW
23
                }
×
24

25
                public void Add(AppId app, ExtendedData extendedData)
26
                {
966✔
27
                        if (this.Owner.Document != null)
966✔
28
                        {
543✔
29
                                if (this.Owner.Document.AppIds.TryGetValue(app.Name, out AppId existing))
543✔
30
                                {
462✔
31
                                        this._data.Add(existing, extendedData);
462✔
32
                                }
462✔
33
                                else
34
                                {
81✔
35
                                        this.Owner.Document.AppIds.Add(app);
81✔
36
                                        this._data.Add(app, extendedData);
81✔
37
                                }
81✔
38
                        }
543✔
39
                        else
40
                        {
423✔
41
                                this._data.Add(app, extendedData);
423✔
42
                        }
423✔
43
                }
966✔
44

45
                /// <summary>
46
                /// Add ExtendedData for a specific AppId to the Dictionary.
47
                /// </summary>
48
                /// <param name="app">The AppId object.</param>
49
                /// <param name="records">The ExtendedData records.</param>
50
                public void Add(AppId app, IEnumerable<ExtendedDataRecord> records)
51
                {
22,713✔
52
                        this._data.Add(app, new ExtendedData(records));
22,713✔
53
                }
22,713✔
54

55
                /// <summary>
56
                /// Get the different extended data by it's name.
57
                /// </summary>
58
                /// <returns></returns>
59
                public IDictionary<string, ExtendedData> GetExtendedDataByName()
60
                {
2✔
61
                        return this._data.ToDictionary(x => x.Key.Name, x => x.Value);
6✔
62
                }
2✔
63

64
                public ExtendedData Get(string name)
65
                {
2✔
66
                        return this.GetExtendedDataByName()[name];
2✔
67
                }
2✔
68

69
                /// <summary>
70
                /// Get ExtendedData for a specific AppId from the Dictionary.
71
                /// </summary>
72
                /// <param name="app">The AppId object.</param>
73
                public ExtendedData Get(AppId app)
74
                {
6✔
75
                        return this._data[app];
6✔
76
                }
6✔
77

78
                /// <summary>
79
                /// Try to get ExtendedData for a specific AppId from the Dictionary.
80
                /// </summary>
81
                /// <param name="app">The AppId object.</param>
82
                /// <param name="value">ExtendedData object.</param>
83
                public bool TryGet(AppId app, out ExtendedData value)
84
                {
×
85
                        return this._data.TryGetValue(app, out value);
×
86
                }
×
87

88
                public bool TryGet(string name, out ExtendedData value)
89
                {
26✔
90
                        AppId app = this._data.Keys.FirstOrDefault(k => k.Name == name);
52✔
91
                        if (app == null)
26!
92
                        {
×
93
                                value = null;
×
94
                                return false;
×
95
                        }
96

97
                        value = this._data[app];
26✔
98
                        return true;
26✔
99
                }
26✔
100

101
                /// <summary>
102
                /// Check whether a AppId is given in the Dictionary.
103
                /// </summary>
104
                /// <param name="app">The AppId object.</param>
105
                public bool ContainsKey(AppId app)
106
                {
×
107
                        return this._data.ContainsKey(app);
×
108
                }
×
109

110
                public bool ContainsKeyName(string name)
111
                {
×
112
                        return this._data.Keys.Select(k => k.Name).Contains(name);
×
113
                }
×
114

115
                /// <summary>
116
                /// Clear all Dictionary entries.
117
                /// </summary>
118
                public void Clear()
119
                {
9,084✔
120
                        this._data.Clear();
9,084✔
121
                }
9,084✔
122

123
                public IEnumerator<KeyValuePair<AppId, ExtendedData>> GetEnumerator()
124
                {
171,266✔
125
                        return this._data.GetEnumerator();
171,266✔
126
                }
171,266✔
127

128
                IEnumerator IEnumerable.GetEnumerator()
129
                {
1✔
130
                        return this._data.GetEnumerator();
1✔
131
                }
1✔
132
        }
133
}
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