using System; using System.Collections.Generic; namespace FurnitureExporter; internal sealed class PendingExportSession { public PendingExportSession(string documentKey, IReadOnlyList panelHandles) { DocumentKey = documentKey; PanelHandles = panelHandles; CreatedAtUtc = DateTime.UtcNow; } public string DocumentKey { get; } public DateTime CreatedAtUtc { get; } public IReadOnlyList PanelHandles { get; } } /// /// 导出向导的“暂停/恢复”会话管理。 /// 仅保存在内存中(不落盘),用于允许用户在两步之间调整图层显示等操作。 /// internal static class ExportSessionManager { private static readonly object Sync = new(); private static readonly Dictionary Sessions = new(StringComparer.OrdinalIgnoreCase); public static PendingExportSession? Get(string documentKey) { if (string.IsNullOrWhiteSpace(documentKey)) return null; lock (Sync) { Sessions.TryGetValue(documentKey, out var session); return session; } } public static PendingExportSession SetPanels(string documentKey, IReadOnlyList panelHandles) { if (string.IsNullOrWhiteSpace(documentKey)) throw new ArgumentException("documentKey is required", nameof(documentKey)); if (panelHandles == null) throw new ArgumentNullException(nameof(panelHandles)); lock (Sync) { var session = new PendingExportSession(documentKey, panelHandles); Sessions[documentKey] = session; return session; } } public static void Clear(string documentKey) { if (string.IsNullOrWhiteSpace(documentKey)) return; lock (Sync) { Sessions.Remove(documentKey); } } }