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

DomCR / ACadSharp / 25394487403

05 May 2026 06:23PM UTC coverage: 76.803% (-0.001%) from 76.804%
25394487403

Pull #1062

github

web-flow
Merge 7aa5d2673 into ab35acaf4
Pull Request #1062: issue-897 Refactor SortEntitiesTable

8556 of 12079 branches covered (70.83%)

Branch coverage included in aggregate %.

44 of 58 new or added lines in 3 files covered. (75.86%)

1 existing line in 1 file now uncovered.

30724 of 39065 relevant lines covered (78.65%)

153028.62 hits per line

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

72.0
/src/ACadSharp/Objects/SortEntitiesTable.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Entities;
3
using ACadSharp.Tables;
4
using System;
5
using System.Collections;
6
using System.Collections.Generic;
7
using System.Linq;
8

9
namespace ACadSharp.Objects
10
{
11
        /// <summary>
12
        /// Represents a <see cref="SortEntitiesTable"/> object
13
        /// </summary>
14
        /// <remarks>
15
        /// Object name <see cref="DxfFileToken.ObjectSortEntsTable"/> <br/>
16
        /// Dxf class name <see cref="DxfSubclassMarker.SortentsTable"/>
17
        /// </remarks>
18
        [DxfName(DxfFileToken.ObjectSortEntsTable)]
19
        [DxfSubClass(DxfSubclassMarker.SortentsTable)]
20
        public partial class SortEntitiesTable : NonGraphicalObject, IEnumerable<SortEntitiesTable.Sorter>
21
        {
22
                /// <summary>
23
                /// Block owner where the table is applied
24
                /// </summary>
25
                [DxfCodeValue(330)]
26
                public BlockRecord BlockOwner { get; internal set; }
1,047✔
27

28
                /// <inheritdoc/>
29
                public override string ObjectName => DxfFileToken.ObjectSortEntsTable;
1,719✔
30

31
                /// <inheritdoc/>
NEW
32
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
33

34
                /// <inheritdoc/>
NEW
35
                public override string SubclassMarker => DxfSubclassMarker.SortentsTable;
×
36

37
                /// <summary>
38
                /// Dictionary entry name for the object <see cref="SortEntitiesTable"/>
39
                /// </summary>
40
                public const string DictionaryEntryName = "ACAD_SORTENTS";
41

42
                private List<Sorter> _sorters = new();
1,009✔
43

44
                internal SortEntitiesTable()
1,009✔
45
                {
1,009✔
46
                        this.Name = DictionaryEntryName;
1,009✔
47
                }
1,009✔
48

49
                internal SortEntitiesTable(BlockRecord owner) : this()
3✔
50
                {
3✔
51
                        this.BlockOwner = owner;
3✔
52
                }
3✔
53

54
                /// <summary>
55
                /// Sorter attached to an entity.
56
                /// </summary>
57
                /// <param name="entity">Entity in the block to be sorted.</param>
58
                /// <param name="sorterHandle">Sorter handle.</param>
59
                /// <exception cref="ArgumentException"></exception>
60
                public void Add(Entity entity, ulong sorterHandle)
61
                {
2,743✔
62
                        this._sorters.Add(new Sorter(entity, sorterHandle));
2,743✔
63
                }
2,743✔
64

65
                /// <summary>
66
                /// Removes all elements in the collection.
67
                /// </summary>
68
                public void Clear()
NEW
69
                {
×
NEW
70
                        this._sorters.Clear();
×
NEW
71
                }
×
72

73
                /// <inheritdoc/>
74
                public override CadObject Clone()
75
                {
122✔
76
                        SortEntitiesTable clone = (SortEntitiesTable)base.Clone();
122✔
77

78
                        clone._sorters = new List<Sorter>();
122✔
79

80
                        return clone;
122✔
81
                }
122✔
82

83
                /// <inheritdoc/>
84
                public IEnumerator<Sorter> GetEnumerator()
85
                {
43✔
86
                        this._sorters.Sort();
43✔
87
                        return this._sorters.GetEnumerator();
43✔
88
                }
43✔
89

90
                /// <inheritdoc/>
91
                IEnumerator IEnumerable.GetEnumerator()
92
                {
1✔
93
                        return this.GetEnumerator();
1✔
94
                }
1✔
95

96
                /// <summary>
97
                /// Get the sorter handle of an entity, if is not in the sorter table it will return the entity's handle.
98
                /// </summary>
99
                /// <param name="entity"></param>
100
                /// <returns></returns>
101
                public ulong GetSorterHandle(Entity entity)
102
                {
290✔
103
                        Sorter sorter = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
318✔
104

105
                        if (sorter is not null)
290✔
106
                        {
8✔
107
                                return sorter.SortHandle;
8✔
108
                        }
109
                        else
110
                        {
282✔
111
                                return entity.Handle;
282✔
112
                        }
113
                }
290✔
114

115
                /// <summary>
116
                /// Removes the first occurrence of a specific object from the sorters table.
117
                /// </summary>
118
                /// <param name="entity"></param>
119
                /// <returns></returns>
120
                public bool Remove(Entity entity)
NEW
121
                {
×
NEW
122
                        var sorter = _sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
NEW
123
                        if (sorter is null)
×
124
                        {
×
NEW
125
                                return false;
×
126
                        }
127

NEW
128
                        return _sorters.Remove(sorter);
×
129
                }
×
130
        }
131
}
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