Skip to content

Commit

Permalink
Ignore invalid data when loading APP list
Browse files Browse the repository at this point in the history
  • Loading branch information
hbl917070 committed Nov 18, 2024
1 parent 0ddda49 commit 51b348d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Tiefsee/VW/WV_RunApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ public List<UwpItem> GetUwpList() {
jsonString = sr.ReadToEnd();
}
}
_tempUwpItem = JsonSerializer.Deserialize<Dictionary<string, UwpItem>>(jsonString);
_tempUwpItem = JsonSerializer.Deserialize<Dictionary<string, UwpItem>>(jsonString)
// 忽略異常的資料
.Where(x => string.IsNullOrEmpty(x.Value.Name) == false &&
string.IsNullOrEmpty(x.Value.Logo) == false &&
string.IsNullOrEmpty(x.Value.Id) == false)
.ToDictionary();

}
catch (Exception) {
_tempUwpItem = new();
Expand All @@ -145,6 +151,10 @@ public List<UwpItem> GetUwpList() {
string name = package.DisplayName; // APP在地化的名稱 (取得成本高)
string logo = package.Logo.ToString(); // 圖示的路徑 (取得成本高)
string id = package.Id.Name + "_" + package.Id.PublisherId;
// 忽略異常的資料
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(logo) || string.IsNullOrEmpty(id)) {
continue;
}
_tempUwpItem.Add(fullName, new UwpItem {
Logo = logo,
Name = name,
Expand Down

0 comments on commit 51b348d

Please sign in to comment.