-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreExtensions.cs
More file actions
37 lines (34 loc) · 1016 Bytes
/
Copy pathStoreExtensions.cs
File metadata and controls
37 lines (34 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Threading.Tasks;
using System.Windows;
using UnityModStudio.Common.Options;
namespace UnityModStudio.Options;
public static class StoreExtensions
{
public static async Task LoadSafeAsync(this IStore store)
{
try
{
await store.LoadAsync();
}
catch (Exception exception)
{
var storeType = store.StoreType;
MessageBox.Show($"Failed to load {storeType}: {exception.Message}", $"Failed to load {storeType}",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public static async Task SaveSafeAsync(this IStore store)
{
try
{
await store.SaveAsync();
}
catch (Exception exception)
{
var storeType = store.StoreType;
MessageBox.Show($"Failed to save {storeType}: {exception.Message}", $"Failed to save {storeType}",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}