Forge
csharpdeeb25a2
1namespace CascadeIDE.Features.Workspace.Application;
2
3/// <summary>Канонические имена SVG для SE (ADR 0167 §2.10; assets из vscode-icons, MIT).</summary>
4public static class SolutionExplorerIconKeys
5{
6 private static readonly HashSet<string> NodeKeys =
7 new(StringComparer.OrdinalIgnoreCase) { "solution", "folder", "file" };
8
9 public static string ResolveAssetName(string iconKey) =>
10 ResolveAssetName(iconKey, powerMonochrome: false);
11
12 public static string ResolveAssetName(string iconKey, bool powerMonochrome)
13 {
14 _ = powerMonochrome;
15 if (string.IsNullOrWhiteSpace(iconKey))
16 return "file";
17
18 if (NodeKeys.Contains(iconKey))
19 return iconKey;
20
21 if (iconKey.StartsWith("file_", StringComparison.OrdinalIgnoreCase))
22 {
23 var ext = iconKey[5..];
24 return ext switch
25 {
26 "csproj" => "csproj",
27 "fsproj" => "fsproj",
28 "vbproj" => "vbproj",
29 "cs" => "cs",
30 "axaml" => "axaml",
31 "json" => "json",
32 "md" => "md",
33 "xml" => "xml",
34 "txt" => "txt",
35 "toml" => "toml",
36 "sln" or "slnx" => "solution",
37 _ => KnownExtensionOrFile(ext),
38 };
39 }
40
41 return iconKey.Equals("project", StringComparison.OrdinalIgnoreCase) ? "csproj" : "file";
42 }
43
44 private static string KnownExtensionOrFile(string ext) =>
45 ext is "cs" or "axaml" or "json" or "md" or "xml" or "txt" or "toml"
46 or "js" or "ts" or "css" or "html" or "py" or "yaml" or "sh" or "ps1"
47 or "sql" or "go" or "scss" or "less" or "bat" or "svg" or "png"
48 ? ext
49 : "file";
50}
51
View only · write via MCP/CIDE