Skip to content

Commit

Permalink
exception
Browse files Browse the repository at this point in the history
  • Loading branch information
skyline75489 committed Aug 29, 2024
1 parent de6c1f2 commit 2662c86
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions examples/csharp/GennyMaui/GennyMaui/ViewModels/LoadableModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ public partial class LoadableModel: ObservableObject
[RelayCommand]
private async Task OpenModelAsync()
{
#if ANDROID
#else
var result = await FolderPicker.Default.PickAsync();

if (result.IsSuccessful)
{
ModelPath = result.Folder.Path;
}
else
{
await Application.Current.MainPage.DisplayAlert("Folder Open Error", result.Exception.Message, "OK");
}
#endif
}

[RelayCommand(CanExecute = "CanExecuteLoadModel")]
Expand All @@ -50,8 +57,8 @@ private async Task LoadModelAsync()
IsModelLoading = true;
Configuration = await LoadConfigAsync(ModelPath);

WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<ConfigurationModel>(this, "Configuration", null, Configuration));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<SearchOptionsModel>(this, "SearchOptionsModel", null, Configuration.SearchOptions));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<ConfigurationModel>(this, nameof(Configuration), null, Configuration));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<SearchOptionsModel>(this, nameof(SearchOptionsModel), null, Configuration.SearchOptions));

await Task.Run(() =>
{
Expand All @@ -60,8 +67,8 @@ await Task.Run(() =>
});
IsModelLoaded = true;

WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<Model>(this, "Model", null, Model));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<Tokenizer>(this, "Tokenizer", null, Tokenizer));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<Model>(this, nameof(Model), null, Model));
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<Tokenizer>(this, nameof(Tokenizer), null, Tokenizer));
}
catch (Exception ex)
{
Expand Down

0 comments on commit 2662c86

Please sign in to comment.