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

DomCR / ACadSharp / 15980992254

30 Jun 2025 06:40PM UTC coverage: 75.271% (-0.06%) from 75.329%
15980992254

Pull #700

github

web-flow
Merge 319fc6447 into d7e4a6e08
Pull Request #700: issue-696 sortentities fix

5835 of 8549 branches covered (68.25%)

Branch coverage included in aggregate %.

20 of 62 new or added lines in 6 files covered. (32.26%)

3 existing lines in 2 files now uncovered.

23242 of 30081 relevant lines covered (77.26%)

81960.28 hits per line

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

36.73
/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,080✔
27

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

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

34
                /// <inheritdoc/>
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,051✔
43

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

49
                internal SortEntitiesTable(BlockRecord owner) : this()
2✔
50
                {
2✔
51
                        this.BlockOwner = owner;
2✔
52
                }
2✔
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,811✔
62
                        this._sorters.Add(new Sorter(entity, sorterHandle));
2,811✔
63
                }
2,811✔
64

65
                /// <summary>
66
                /// Add an entity above all existing entities in the table.
67
                /// </summary>
68
                /// <param name="entity"></param>
69
                public void AddAbove(Entity entity)
NEW
70
                {
×
NEW
71
                        throw new NotImplementedException();
×
72
                }
73

74
                /// <summary>
75
                /// Add an entity below all existing entities in the table.
76
                /// </summary>
77
                /// <param name="entity"></param>
78
                public void AddBelow(Entity entity)
79
                {
×
NEW
80
                        throw new NotImplementedException();
×
81
                }
82

83
                /// <summary>
84
                /// Removes all elements in the collection.
85
                /// </summary>
86
                public void Clear()
NEW
87
                {
×
NEW
88
                        this._sorters.Clear();
×
NEW
89
                }
×
90

91
                /// <inheritdoc/>
92
                public IEnumerator<Sorter> GetEnumerator()
93
                {
32✔
94
                        this._sorters.Sort();
32✔
95
                        return this._sorters.GetEnumerator();
32✔
96
                }
32✔
97

98
                /// <inheritdoc/>
99
                IEnumerator IEnumerable.GetEnumerator()
NEW
100
                {
×
NEW
101
                        return this.GetEnumerator();
×
NEW
102
                }
×
103

104
                /// <summary>
105
                /// Get the sorter handle of an entity, if is not in the sorter table it will return the entity's handle.
106
                /// </summary>
107
                /// <param name="entity"></param>
108
                /// <returns></returns>
109
                public ulong GetSorterHandle(Entity entity)
NEW
110
                {
×
NEW
111
                        Sorter sorter = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
112

NEW
113
                        if (sorter is not null)
×
NEW
114
                        {
×
NEW
115
                                return sorter.SortHandle;
×
116
                        }
117
                        else
NEW
118
                        {
×
NEW
119
                                return entity.Handle;
×
120
                        }
NEW
121
                }
×
122

123
                /// <summary>
124
                /// Removes the first occurrence of a specific object from the sorters table.
125
                /// </summary>
126
                /// <param name="entity"></param>
127
                /// <returns></returns>
128
                public bool Remove(Entity entity)
NEW
129
                {
×
NEW
130
                        var sorter = _sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
NEW
131
                        if (sorter is null)
×
NEW
132
                        {
×
NEW
133
                                return false;
×
134
                        }
135

NEW
136
                        return _sorters.Remove(sorter);
×
UNCOV
137
                }
×
138
        }
139
}
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