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

DomCR / ACadSharp / 16146928965

08 Jul 2025 03:01PM UTC coverage: 75.057% (-0.04%) from 75.101%
16146928965

push

github

web-flow
Merge pull request #700 from DomCR/issue-696_sortentitiestable-dwg-fix

issue-696 sortentities fix

5851 of 8573 branches covered (68.25%)

Branch coverage included in aggregate %.

40 of 71 new or added lines in 6 files covered. (56.34%)

8 existing lines in 3 files now uncovered.

23265 of 30219 relevant lines covered (76.99%)

81591.98 hits per line

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

62.22
/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,138✔
27

28
                /// <inheritdoc/>
29
                public override string ObjectName => DxfFileToken.ObjectSortEntsTable;
1,373✔
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,099✔
43

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

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

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

73
                /// <inheritdoc/>
74
                public IEnumerator<Sorter> GetEnumerator()
75
                {
207✔
76
                        this._sorters.Sort();
207✔
77
                        return this._sorters.GetEnumerator();
207✔
78
                }
207✔
79

80
                /// <inheritdoc/>
81
                IEnumerator IEnumerable.GetEnumerator()
82
                {
1✔
83
                        return this.GetEnumerator();
1✔
84
                }
1✔
85

86
                /// <summary>
87
                /// Get the sorter handle of an entity, if is not in the sorter table it will return the entity's handle.
88
                /// </summary>
89
                /// <param name="entity"></param>
90
                /// <returns></returns>
91
                public ulong GetSorterHandle(Entity entity)
92
                {
3✔
93
                        Sorter sorter = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
9✔
94

95
                        if (sorter is not null)
3!
96
                        {
3✔
97
                                return sorter.SortHandle;
3✔
98
                        }
99
                        else
NEW
100
                        {
×
NEW
101
                                return entity.Handle;
×
102
                        }
103
                }
3✔
104

105
                /// <summary>
106
                /// Removes the first occurrence of a specific object from the sorters table.
107
                /// </summary>
108
                /// <param name="entity"></param>
109
                /// <returns></returns>
110
                public bool Remove(Entity entity)
NEW
111
                {
×
NEW
112
                        var sorter = _sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
NEW
113
                        if (sorter is null)
×
NEW
114
                        {
×
NEW
115
                                return false;
×
116
                        }
117

NEW
118
                        return _sorters.Remove(sorter);
×
UNCOV
119
                }
×
120
        }
121
}
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