초기 커밋: SheetMe 서식생성기 (P0~P5 완료 상태)
레거시 서식생성기(VB.NET WinForms) 대체용 C#/.NET 10 WPF 디자이너. 기준선: 실DB 활성 디자인 1,271건 왕복 의미론 diff 0 / 예외 0, 단위 테스트 49/49. 이 커밋에 함께 포함된 자격증명 분리: - appsettings.json 을 __HOST__/__PASSWORD__ 플레이스홀더로 전환 - 실접속 정보는 appsettings.Development.json 으로 분리(.gitignore 제외, csproj Debug 조건부 복사라 Release 산출물에 실리지 않음) - ConfigLoader 를 환경변수 > Development > appsettings 순 레이어링으로 변경, 미치환 플레이스홀더는 '미설정'으로 간주 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using SheetMe.Core.Models;
|
||||
|
||||
namespace SheetMe.Designer.Services;
|
||||
|
||||
/// <summary>컨트롤 Id 생성 — 문서 전체에서 유일한 "TextBox1" 식 이름 부여(레거시 관행).</summary>
|
||||
public static class IdGenerator
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>문서의 사용 중 Id 집합 수집</summary>
|
||||
public static HashSet<string> CollectUsed(FormDocument document)
|
||||
{
|
||||
var used = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var page in document.Pages)
|
||||
{
|
||||
Collect(page.Root, used);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
/// <summary>타입 기반 유일 Id 생성 — 발급한 Id 는 used 집합에 추가된다(연속 발급 안전)</summary>
|
||||
public static string NextId(HashSet<string> used, string type)
|
||||
{
|
||||
for (var i = 1; ; i++)
|
||||
{
|
||||
var candidate = type + i;
|
||||
if (used.Add(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>단건 발급 편의 — 문서 스캔 후 1개 생성</summary>
|
||||
public static string NextId(FormDocument document, string type)
|
||||
=> NextId(CollectUsed(document), type);
|
||||
|
||||
private static void Collect(ControlElement element, HashSet<string> used)
|
||||
{
|
||||
if (element.Id.Length > 0)
|
||||
{
|
||||
used.Add(element.Id);
|
||||
}
|
||||
foreach (var child in element.Children)
|
||||
{
|
||||
Collect(child, used);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user