Dreamine.Web 1.0.0.0
WPF와 Blazor를 한 코드 흐름으로 연결하고 반복적인 MVVM 코드를 줄이는 오픈소스 FullKit 공식 웹 애플리케이션입니다.
로딩중...
검색중...
일치하는것 없음
XmlDocAutoLinker.cs
이 파일의 문서화 페이지로 가기
1using System.IO;
3
5
14public class XmlDocAutoLinker
15{
24 private readonly ILibraryStore _store;
33 private readonly string _xmlDocRoot;
34
52 {
53 _store = store;
54 _xmlDocRoot = Path.Combine(AppContext.BaseDirectory, "wwwroot", "xmldocs");
55 }
56
73 public async Task<int> LinkAsync()
74 {
75 if (!Directory.Exists(_xmlDocRoot)) return 0;
76
77 // wwwroot/xmldocs/{LibraryName}/{LibraryName}.xml 구조로 탐색
78 var map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
79 foreach (var dir in Directory.EnumerateDirectories(_xmlDocRoot))
80 {
81 var libName = Path.GetFileName(dir);
82 var xmlPath = Path.Combine(dir, $"{libName}.xml");
83 if (File.Exists(xmlPath))
84 map[libName] = xmlPath;
85 }
86
87 var libs = (await _store.GetAllAsync()).ToList();
88 int count = 0;
89
90 foreach (var lib in libs)
91 {
92 // 이미 설정된 경우 건너뜀
93 if (!string.IsNullOrEmpty(lib.XmlDocPath) && File.Exists(lib.XmlDocPath)) continue;
94
95 if (map.TryGetValue(lib.Name, out var path))
96 {
97 lib.XmlDocPath = path;
98 await _store.SaveAsync(lib);
99 count++;
100 }
101 }
102
103 return count;
104 }
105}