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

DomCR / ACadSharp / 29143042407

11 Jul 2026 06:34AM UTC coverage: 2.912% (-73.0%) from 75.918%
29143042407

push

github

web-flow
Merge pull request #1146 from ilCosmico/acds-read-payload-anchor

Read the AcDs payload area offset from the data segment header

264 of 12999 branches covered (2.03%)

Branch coverage included in aggregate %.

0 of 30 new or added lines in 1 file covered. (0.0%)

31243 existing lines in 465 files now uncovered.

1337 of 41984 relevant lines covered (3.18%)

5.38 hits per line

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

0.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)]
UNCOV
26
        public BlockRecord BlockOwner { get; internal set; }
×
27

28
        /// <inheritdoc/>
UNCOV
29
        public override string ObjectName => DxfFileToken.ObjectSortEntsTable;
×
30

31
        /// <inheritdoc/>
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

UNCOV
42
        private List<Sorter> _sorters = new();
×
43

UNCOV
44
        internal SortEntitiesTable()
×
UNCOV
45
        {
×
UNCOV
46
                this.Name = DictionaryEntryName;
×
UNCOV
47
        }
×
48

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

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

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

UNCOV
78
                clone._sorters = new List<Sorter>();
×
79

UNCOV
80
                return clone;
×
UNCOV
81
        }
×
82

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

90
        /// <inheritdoc/>
91
        IEnumerator IEnumerable.GetEnumerator()
UNCOV
92
        {
×
UNCOV
93
                return this.GetEnumerator();
×
UNCOV
94
        }
×
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)
UNCOV
102
        {
×
UNCOV
103
                Sorter sorter = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
104

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

115
        /// <summary>
116
        /// Moves the specified entity to the bottom of the draw order.
117
        /// </summary>
118
        /// <param name="entity">Entity to move to the bottom.</param>
119
        public void MoveToBottom(Entity entity)
UNCOV
120
        {
×
UNCOV
121
                ulong maxHandle = this._sorters.Count > 0
×
UNCOV
122
                        ? this._sorters.Max(s => s.SortHandle)
×
UNCOV
123
                        : entity.Handle;
×
124

UNCOV
125
                ulong newHandle = maxHandle < ulong.MaxValue ? maxHandle + 1 : ulong.MaxValue;
×
126

UNCOV
127
                Sorter existing = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
UNCOV
128
                if (existing is not null)
×
UNCOV
129
                {
×
UNCOV
130
                        existing.SortHandle = newHandle;
×
UNCOV
131
                }
×
132
                else
UNCOV
133
                {
×
UNCOV
134
                        this._sorters.Add(new Sorter(entity, newHandle));
×
UNCOV
135
                }
×
UNCOV
136
        }
×
137

138
        /// <summary>
139
        /// Moves the specified entity to the top of the draw order.
140
        /// </summary>
141
        /// <param name="entity">Entity to move to the top.</param>
142
        public void MoveToTop(Entity entity)
UNCOV
143
        {
×
UNCOV
144
                ulong minHandle = this._sorters.Count > 0
×
UNCOV
145
                        ? this._sorters.Min(s => s.SortHandle)
×
UNCOV
146
                        : entity.Handle;
×
147

UNCOV
148
                ulong sorter = minHandle > 0 ? minHandle - 1 : 0;
×
149

UNCOV
150
                Sorter existing = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
UNCOV
151
                if (existing is not null)
×
UNCOV
152
                {
×
UNCOV
153
                        existing.SortHandle = sorter;
×
UNCOV
154
                }
×
155
                else
UNCOV
156
                {
×
UNCOV
157
                        this._sorters.Add(new Sorter(entity, sorter));
×
UNCOV
158
                }
×
UNCOV
159
        }
×
160

161
        /// <summary>
162
        /// Removes the first occurrence of a specific object from the sorters table.
163
        /// </summary>
164
        /// <param name="entity"></param>
165
        /// <returns></returns>
166
        public bool Remove(Entity entity)
167
        {
×
168
                var sorter = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
169
                if (sorter is null)
×
170
                {
×
171
                        return false;
×
172
                }
173

174
                return this._sorters.Remove(sorter);
×
175
        }
×
176

177
        /// <summary>
178
        /// Moves the specified entity one step up in the draw order.
179
        /// If the entity is not in the table or is already at the top, no action is taken.
180
        /// </summary>
181
        /// <param name="entity">Entity to move one step up.</param>
182
        public void OneStepUp(Entity entity)
UNCOV
183
        {
×
UNCOV
184
                Sorter existing = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
UNCOV
185
                if (existing is null)
×
UNCOV
186
                {
×
UNCOV
187
                        return;
×
188
                }
189

UNCOV
190
                int index = this._sorters.OrderBy(s => s.SortHandle).ToList().IndexOf(existing);
×
UNCOV
191
                if (index <= 0 || _sorters.Count < 2)
×
UNCOV
192
                {
×
UNCOV
193
                        return;
×
194
                }
195

UNCOV
196
                Sorter previous = this._sorters[index - 1];
×
UNCOV
197
                (existing.SortHandle, previous.SortHandle) = (previous.SortHandle, existing.SortHandle);
×
UNCOV
198
        }
×
199

200
        /// <summary>
201
        /// Moves the specified entity one step down in the draw order.
202
        /// If the entity is not in the table or is already at the bottom, no action is taken.
203
        /// </summary>
204
        /// <param name="entity">Entity to move one step down.</param>
205
        public void OneStepDown(Entity entity)
UNCOV
206
        {
×
UNCOV
207
                Sorter existing = this._sorters.FirstOrDefault(s => s.Entity.Equals(entity));
×
UNCOV
208
                if (existing is null)
×
UNCOV
209
                {
×
UNCOV
210
                        return;
×
211
                }
212

UNCOV
213
                this._sorters.Sort();
×
214

UNCOV
215
                int index = this._sorters.IndexOf(existing);
×
UNCOV
216
                if (index < 0 || index >= this._sorters.Count - 1)
×
UNCOV
217
                {
×
UNCOV
218
                        return;
×
219
                }
220

UNCOV
221
                Sorter next = this._sorters[index + 1];
×
UNCOV
222
                (existing.SortHandle, next.SortHandle) = (next.SortHandle, existing.SortHandle);
×
UNCOV
223
        }
×
224
}
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