• 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/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
UNCOV
19
                { add { this._dictionary.OnRemove += value; } remove { this._dictionary.OnRemove -= value; } }
×
20

21
                /// <inheritdoc/>
UNCOV
22
                public ulong Handle { get { return this._dictionary.Handle; } }
×
23

24
                protected CadDictionary _dictionary;
25

UNCOV
26
                protected ObjectDictionaryCollection(CadDictionary dictionary)
×
UNCOV
27
                {
×
UNCOV
28
                        this._dictionary = dictionary;
×
UNCOV
29
                }
×
30

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

40
                /// <summary>
41
                /// Removes all keys and values from the <see cref="ObjectDictionaryCollection{T}"/>.
42
                /// </summary>
43
                public void Clear()
44
                {
×
45
                        this._dictionary.Clear();
×
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)
UNCOV
54
                {
×
UNCOV
55
                        return this._dictionary.ContainsKey(key);
×
UNCOV
56
                }
×
57

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

64
                /// <inheritdoc/>
65
                IEnumerator IEnumerable.GetEnumerator()
66
                {
×
67
                        return this._dictionary.OfType<T>().GetEnumerator();
×
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)
UNCOV
76
                {
×
UNCOV
77
                        return this.Remove(name, out _);
×
UNCOV
78
                }
×
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)
UNCOV
87
                {
×
UNCOV
88
                        bool result = this._dictionary.Remove(name, out NonGraphicalObject n);
×
UNCOV
89
                        entry = (T)n;
×
UNCOV
90
                        return result;
×
UNCOV
91
                }
×
92

93
                /// <inheritdoc/>
94
                public T TryAdd(T item)
UNCOV
95
                {
×
UNCOV
96
                        if (this.TryGetValue(item.Name, out T existing))
×
UNCOV
97
                        {
×
UNCOV
98
                                return existing;
×
99
                        }
100
                        else
UNCOV
101
                        {
×
UNCOV
102
                                this.Add(item);
×
UNCOV
103
                                return item;
×
104
                        }
UNCOV
105
                }
×
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)
UNCOV
114
                {
×
UNCOV
115
                        return this._dictionary.TryGetEntry(name, out entry);
×
UNCOV
116
                }
×
117

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