Files
OpenNest/OpenNest.Data/DrawingSetBrowseSession.cs
T
ajandClaude Opus 5.5 7ce5e73a82 refactor: share duplicated paging, HTTP and helper code
Roslyn duplicate scans found the same code copied across layers:
- Data: the three browse sessions share BrowseSession<TPage, TSort>;
  the remote clients share NestServerHttp (JSON options, If-Match,
  error text).
- WinForms: five paged lists share BrowsePager for loading text,
  navigation, sort glyphs and failure messages. The Add Drawings to
  Release, Drawing Library and set browser dialogs now dispose their
  browse sessions.
- Server: NestQueryRequest reuses DrawingLibraryRequest's helpers;
  revision history queries share count and paging binds.
- Engine: RemnantPlateNester delegates to DefaultPlateNester;
  CuttingPlanService reuses JointCuttingPlanSearch.Map.
- Core: LineArc and CleanHole lead-ins share LineArcApproach with
  unchanged arithmetic order, so output is bit-identical.
- IO: Dxf.GetGeometry overloads share one reader; .nest JSON test
  helpers move to NestArchiveJson.

Also fixes the production compiler warnings (CS8632, CS8603, CS0108)
and moves a test off an obsolete forwarding API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 08:45:36 -04:00

46 lines
1.7 KiB
C#

namespace OpenNest.Data;
/// <summary>
/// Browse state for Nest &gt; Drawing Sets: the requested search, archived toggle, sort and
/// page, and the last page applied. Paging, superseding and disposal follow
/// <see cref="BrowseSession{TPage, TSort}"/>. Call from one thread (the UI thread).
/// </summary>
public sealed class DrawingSetBrowseSession : BrowseSession<DrawingSetPage, DrawingSetSortField>
{
private readonly IDrawingSetStore _sets;
public DrawingSetBrowseSession(IDrawingSetStore sets, int pageSize = DrawingSetQuery.DefaultLimit)
: base(pageSize, DrawingSetQuery.MaxLimit, DrawingSetSortField.SavedAt)
{
ArgumentNullException.ThrowIfNull(sets);
_sets = sets;
}
/// <summary>True when archived sets are listed with the active ones.</summary>
public bool IncludeArchived { get; private set; }
/// <inheritdoc />
public override string Summary =>
PageSummary("sets", Search.Length > 0 ? "No sets match the search." : "No drawing sets yet. Choose New Set to make one.");
/// <summary>Lists or hides archived sets and returns to the first page.</summary>
public Task<bool> SetIncludeArchivedAsync(bool includeArchived)
{
IncludeArchived = includeArchived;
return FirstPageAsync();
}
protected override Task<DrawingSetPage> QueryAsync(CancellationToken cancellationToken) =>
_sets.QueryAsync(
new DrawingSetQuery
{
Search = Search,
IncludeArchived = IncludeArchived,
Sort = Sort,
Descending = Descending,
Offset = Offset,
Limit = PageSize,
},
cancellationToken);
}