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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 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> : IHandledCadObject, IEnumerable<T>
13
                where T : NonGraphicalObject
14
        {
15
                public event EventHandler<CollectionChangedEventArgs> OnAdd { add { this._dictionary.OnAdd += value; } remove { this._dictionary.OnAdd -= value; } }
×
16
                public event EventHandler<CollectionChangedEventArgs> OnRemove { add { this._dictionary.OnRemove += value; } remove { this._dictionary.OnRemove -= value; } }
×
17

18
                /// <inheritdoc/>
19
                public ulong Handle { get { return this._dictionary.Handle; } }
×
20

21
                public T this[string key] { get { return (T)this._dictionary[key]; } }
×
22

23
                protected CadDictionary _dictionary;
24

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

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

39
                /// <summary>
40
                /// Determines whether the <see cref="ObjectDictionaryCollection{T}"/> contains the specified key.
41
                /// </summary>
42
                /// <param name="key">The key to locate in the <see cref="ObjectDictionaryCollection{T}"/></param>
43
                /// <returns></returns>
44
                public bool ContainsKey(string key)
45
                {
×
46
                        return this._dictionary.ContainsKey(key);
×
47
                }
×
48

49
                /// <summary>
50
                /// Gets the value associated with the specific key
51
                /// </summary>
52
                /// <param name="name"></param>
53
                /// <param name="entry"></param>
54
                /// <returns>true if the value is found or false if not found.</returns>
55
                public bool TryGetValue(string name, out T entry)
56
                {
×
57
                        return this._dictionary.TryGetEntry(name, out entry);
×
58
                }
×
59

60
                /// <summary>
61
                /// Remove an entry from the collection.
62
                /// </summary>
63
                /// <param name="name"></param>
64
                /// <returns></returns>
65
                public bool Remove(string name)
66
                {
×
67
                        return this.Remove(name, out _);
×
68
                }
×
69

70
                /// <summary>
71
                /// Remove an entry from the collection.
72
                /// </summary>
73
                /// <param name="name"></param>
74
                /// <param name="entry"></param>
75
                /// <returns></returns>
76
                public virtual bool Remove(string name, out T entry)
77
                {
×
78
                        bool result = this._dictionary.Remove(name, out NonGraphicalObject n);
×
79
                        entry = (T)n;
×
80
                        return result;
×
81
                }
×
82

83
                /// <summary>
84
                /// Removes all keys and values from the <see cref="ObjectDictionaryCollection{T}"/>.
85
                /// </summary>
86
                public void Clear()
87
                {
×
88
                        this._dictionary.Clear();
×
89
                }
×
90

91
                /// <inheritdoc/>
92
                public IEnumerator<T> GetEnumerator()
93
                {
×
94
                        return this._dictionary.OfType<T>().GetEnumerator();
×
95
                }
×
96

97
                /// <inheritdoc/>
98
                IEnumerator IEnumerable.GetEnumerator()
99
                {
×
100
                        return this._dictionary.OfType<T>().GetEnumerator();
×
101
                }
×
102
        }
103
}
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