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

DomCR / ACadSharp / 17301097975

28 Aug 2025 03:51PM UTC coverage: 78.218% (+0.06%) from 78.163%
17301097975

push

github

web-flow
Merge pull request #753 from DomCR/CadDictionary-variables

AcDbVariableDictionary

6549 of 9101 branches covered (71.96%)

Branch coverage included in aggregate %.

169 of 187 new or added lines in 30 files covered. (90.37%)

10 existing lines in 3 files now uncovered.

25386 of 31727 relevant lines covered (80.01%)

104987.27 hits per line

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

84.09
/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
NEW
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; } }
19,719✔
20

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

24
                protected CadDictionary _dictionary;
25

26
                protected ObjectDictionaryCollection(CadDictionary dictionary)
10,476✔
27
                {
10,476✔
28
                        this._dictionary = dictionary;
10,476✔
29
                }
10,476✔
30

31
                /// <summary>
32
                /// Add an entry to the collection
33
                /// </summary>
34
                /// <param name="entry"></param>
35
                public virtual void Add(T entry)
36
                {
1,808✔
37
                        this._dictionary.Add(entry);
1,808✔
38
                }
1,808✔
39

40
                /// <summary>
41
                /// Removes all keys and values from the <see cref="ObjectDictionaryCollection{T}"/>.
42
                /// </summary>
43
                public void Clear()
NEW
44
                {
×
NEW
45
                        this._dictionary.Clear();
×
NEW
46
                }
×
47

48
                /// <summary>
49
                /// Determines whether the <see cref="ObjectDictionaryCollection{T}"/> contains the specified key.
50
                /// </summary>
51
                /// <param name="key">The key to locate in the <see cref="ObjectDictionaryCollection{T}"/></param>
52
                /// <returns></returns>
53
                public bool ContainsKey(string key)
54
                {
22✔
55
                        return this._dictionary.ContainsKey(key);
22✔
56
                }
22✔
57

58
                /// <inheritdoc/>
59
                public IEnumerator<T> GetEnumerator()
60
                {
28✔
61
                        return this._dictionary.OfType<T>().GetEnumerator();
28✔
62
                }
28✔
63

64
                /// <inheritdoc/>
65
                IEnumerator IEnumerable.GetEnumerator()
NEW
66
                {
×
NEW
67
                        return this._dictionary.OfType<T>().GetEnumerator();
×
UNCOV
68
                }
×
69

70
                /// <summary>
71
                /// Remove an entry from the collection.
72
                /// </summary>
73
                /// <param name="name"></param>
74
                /// <returns></returns>
75
                public bool Remove(string name)
76
                {
4✔
77
                        return this.Remove(name, out _);
4✔
78
                }
2✔
79

80
                /// <summary>
81
                /// Remove an entry from the collection.
82
                /// </summary>
83
                /// <param name="name"></param>
84
                /// <param name="entry"></param>
85
                /// <returns></returns>
86
                public virtual bool Remove(string name, out T entry)
87
                {
2✔
88
                        bool result = this._dictionary.Remove(name, out NonGraphicalObject n);
2✔
89
                        entry = (T)n;
2✔
90
                        return result;
2✔
91
                }
2✔
92

93
                /// <inheritdoc/>
94
                public T TryAdd(T item)
95
                {
7,858✔
96
                        if (this.TryGetValue(item.Name, out T existing))
7,858✔
97
                        {
7,581✔
98
                                return existing;
7,581✔
99
                        }
100
                        else
101
                        {
277✔
102
                                this.Add(item);
277✔
103
                                return item;
277✔
104
                        }
105
                }
7,858✔
106

107
                /// <summary>
108
                /// Gets the value associated with the specific key
109
                /// </summary>
110
                /// <param name="name"></param>
111
                /// <param name="entry"></param>
112
                /// <returns>true if the value is found or false if not found.</returns>
113
                public bool TryGetValue(string name, out T entry)
114
                {
8,041✔
115
                        return this._dictionary.TryGetEntry(name, out entry);
8,041✔
116
                }
8,041✔
117

118
                public T this[string key] { get { return (T)this._dictionary[key]; } }
24✔
119
        }
120
}
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