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

DomCR / ACadSharp / 20299272313

17 Dec 2025 10:13AM UTC coverage: 77.127% (+0.02%) from 77.112%
20299272313

Pull #585

github

web-flow
Merge e54f57d47 into 6f007367a
Pull Request #585: Visual style implementation

7694 of 10829 branches covered (71.05%)

Branch coverage included in aggregate %.

180 of 197 new or added lines in 4 files covered. (91.37%)

15 existing lines in 5 files now uncovered.

28362 of 35920 relevant lines covered (78.96%)

159598.6 hits per line

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

85.71
/src/ACadSharp/Objects/Collections/ObjectDictionaryCollection.cs
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using System.Linq;
5

6
namespace ACadSharp.Objects.Collections
7
{
8
        /// <summary>
9
        /// Object collection linked to a dictionary.
10
        /// </summary>
11
        /// <typeparam name="T"></typeparam>
12
        public abstract class ObjectDictionaryCollection<T> : ICadCollection<T>, IObservableCadCollection<T>, IHandledCadObject, IEnumerable<T>
13
                where T : NonGraphicalObject
14
        {
15
                public event EventHandler<CollectionChangedEventArgs> OnAdd
16
                { add { this._dictionary.OnAdd += value; } remove { this._dictionary.OnAdd -= value; } }
×
17

18
                public event EventHandler<CollectionChangedEventArgs> OnRemove
19
                { add { this._dictionary.OnRemove += value; } remove { this._dictionary.OnRemove -= value; } }
51,612✔
20

21
                /// <inheritdoc/>
22
                public ulong Handle { get { return this._dictionary.Handle; } }
4,521✔
23

24
                protected CadDictionary _dictionary;
25

26
                /// <summary>
27
                /// Initializes a new instance of the ObjectDictionaryCollection class with the specified CAD dictionary.
28
                /// </summary>
29
                /// <param name="dictionary">The CAD dictionary that provides the underlying storage for the collection. Cannot be null.</param>
30
                protected ObjectDictionaryCollection(CadDictionary dictionary)
12,950✔
31
                {
12,950✔
32
                        if (dictionary == null)
12,950!
UNCOV
33
                        {
×
UNCOV
34
                                throw new ArgumentNullException(nameof(dictionary));
×
35
                        }
36

37
                        this._dictionary = dictionary;
12,950✔
38
                }
12,950✔
39

40
                /// <summary>
41
                /// Add an entry to the collection
42
                /// </summary>
43
                /// <param name="entry"></param>
44
                public virtual void Add(T entry)
45
                {
1,883✔
46
                        this._dictionary.Add(entry);
1,883✔
47
                }
1,883✔
48

49
                /// <summary>
50
                /// Removes all keys and values from the <see cref="ObjectDictionaryCollection{T}"/>.
51
                /// </summary>
52
                public void Clear()
UNCOV
53
                {
×
UNCOV
54
                        this._dictionary.Clear();
×
UNCOV
55
                }
×
56

57
                /// <summary>
58
                /// Determines whether the <see cref="ObjectDictionaryCollection{T}"/> contains the specified key.
59
                /// </summary>
60
                /// <param name="key">The key to locate in the <see cref="ObjectDictionaryCollection{T}"/></param>
61
                /// <returns></returns>
62
                public bool ContainsKey(string key)
63
                {
22✔
64
                        return this._dictionary.ContainsKey(key);
22✔
65
                }
22✔
66

67
                /// <inheritdoc/>
68
                public IEnumerator<T> GetEnumerator()
69
                {
28✔
70
                        return this._dictionary.OfType<T>().GetEnumerator();
28✔
71
                }
28✔
72

73
                /// <inheritdoc/>
74
                IEnumerator IEnumerable.GetEnumerator()
75
                {
1✔
76
                        return this._dictionary.OfType<T>().GetEnumerator();
1✔
77
                }
1✔
78

79
                /// <summary>
80
                /// Remove an entry from the collection.
81
                /// </summary>
82
                /// <param name="name"></param>
83
                /// <returns></returns>
84
                public bool Remove(string name)
85
                {
4✔
86
                        return this.Remove(name, out _);
4✔
87
                }
2✔
88

89
                /// <summary>
90
                /// Remove an entry from the collection.
91
                /// </summary>
92
                /// <param name="name"></param>
93
                /// <param name="entry"></param>
94
                /// <returns></returns>
95
                public virtual bool Remove(string name, out T entry)
96
                {
2✔
97
                        bool result = this._dictionary.Remove(name, out NonGraphicalObject n);
2✔
98
                        entry = (T)n;
2✔
99
                        return result;
2✔
100
                }
2✔
101

102
                /// <inheritdoc/>
103
                public T TryAdd(T item)
104
                {
20,394✔
105
                        if (this.TryGet(item.Name, out T existing))
20,394✔
106
                        {
20,282✔
107
                                return existing;
20,282✔
108
                        }
109
                        else
110
                        {
112✔
111
                                this.Add(item);
112✔
112
                                return item;
112✔
113
                        }
114
                }
20,394✔
115

116
                /// <summary>
117
                /// Attempts to retrieve the entry associated with the specified name.
118
                /// </summary>
119
                /// <param name="name">The name of the entry to locate. Cannot be null.</param>
120
                /// <param name="entry">When this method returns, contains the entry associated with the specified name, if the name is found; otherwise,
121
                /// the default value for the type of the entry parameter. This parameter is passed uninitialized.</param>
122
                /// <returns>true if an entry with the specified name is found; otherwise, false.</returns>
123
                public bool TryGet(string name, out T entry)
124
                {
20,593✔
125
                        return this._dictionary.TryGetEntry(name, out entry);
20,593✔
126
                }
20,593✔
127

128
                public T this[string key] { get { return (T)this._dictionary[key]; } }
1,209✔
129
        }
130
}
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