From b2ee27c9e4667d68466497658fa4d33153d6c284 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 10:33:36 -0400 Subject: [PATCH 01/41] Updated release roll-out notes --- Upgrade-Prism-8.1-9.x.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Upgrade-Prism-8.1-9.x.md b/Upgrade-Prism-8.1-9.x.md index f7bcc90..6f7b613 100644 --- a/Upgrade-Prism-8.1-9.x.md +++ b/Upgrade-Prism-8.1-9.x.md @@ -4,6 +4,20 @@ This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soon we will be moving this repo to be apart of the main Prism Library `:)` +### Release Upgrade Path + +Each of the following will be tagged and merged into the branch `Prism-9x` before being merged with `develop` and `master` branches. + +* [ ] 9.0.264-pre - Won't be published +* [ ] 9.0.271-pre - Will be tagged and released +* [ ] 9.0.401-pre - Will be tagged and released + +### Prism Tag Comparisons + +* [DNF - 9.0.264-pre](https://github.com/PrismLibrary/Prism/compare/DNF...9.0.264-pre) - (_DNF = Dot Net Foundation_) +* [9.0.264-pre - 9.0.274-pre](https://github.com/PrismLibrary/Prism/compare/9.0.264-pre...9.0.271-pre) +* [9.0.274-pre - 9.0.401-pre](https://github.com/PrismLibrary/Prism/compare/9.0.271-pre...9.0.401-pre) + ## Changes * `Samples` folder renamed to `e2e` From 923ca3ca383795609478f938943cdaf9e090150d Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 15:14:35 -0400 Subject: [PATCH 02/41] Added Directory.Build.Props and SLNF for core Prism.Avalonia solution projects --- Directory.Build.Props | 13 +++++++++++++ Prism.Avalonia.sln | 1 + PrismLibrary_Avalonia.slnf | 14 ++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 Directory.Build.Props create mode 100644 PrismLibrary_Avalonia.slnf diff --git a/Directory.Build.Props b/Directory.Build.Props new file mode 100644 index 0000000..bad5a62 --- /dev/null +++ b/Directory.Build.Props @@ -0,0 +1,13 @@ + + + en + true + + + + + true + $(NoWarn);NU5104;NU5100;NU5118;NU5123;NU1603;CS1701;CS1702;XA0101;MSB3277;CS8785;CS8669;CS1998;NU1507 + + + diff --git a/Prism.Avalonia.sln b/Prism.Avalonia.sln index ee611f5..7455793 100644 --- a/Prism.Avalonia.sln +++ b/Prism.Avalonia.sln @@ -35,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A1A058C5 build\AvaloniaDependency.props = build\AvaloniaDependency.props build\Base.props = build\Base.props build\BuildTargets.props = build\BuildTargets.props + Directory.Build.Props = Directory.Build.Props build\EmbedXaml.props = build\EmbedXaml.props build\Library.props = build\Library.props build\Nuget.props = build\Nuget.props diff --git a/PrismLibrary_Avalonia.slnf b/PrismLibrary_Avalonia.slnf new file mode 100644 index 0000000..3f4b24d --- /dev/null +++ b/PrismLibrary_Avalonia.slnf @@ -0,0 +1,14 @@ +{ + "solution": { + "path": "Prism.Avalonia.sln", + "projects": [ + "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj", + "src\\Prism.Avalonia\\Prism.Avalonia.csproj", + "src\\Prism.DryIoc.Avalonia\\Prism.DryIoc.Avalonia.csproj", + "tests\\Avalonia\\Prism.Avalonia.Tests\\Prism.Avalonia.Tests.csproj", + "tests\\Avalonia\\Prism.Container.Avalonia.Shared\\Prism.Container.Avalonia.Shared.shproj", + "tests\\Avalonia\\Prism.DryIoc.Avalonia.Tests\\Prism.DryIoc.Avalonia.Tests.csproj", + "tests\\Avalonia\\Prism.IocContainer.Avalonia.Tests.Support\\Prism.IocContainer.Avalonia.Tests.Support.csproj" + ] + } +} \ No newline at end of file From a360b9beac8171d941aac1566ca080f975db429c Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 15:44:42 -0400 Subject: [PATCH 03/41] Updated Prism dependency to v9.0.271-pre --- build/PrismDependency.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/PrismDependency.props b/build/PrismDependency.props index 18af5dd..f33eca9 100644 --- a/build/PrismDependency.props +++ b/build/PrismDependency.props @@ -3,7 +3,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - + From 7f478b02751d37e4ec329bb530a7f3747efafcca Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 20:15:15 -0400 Subject: [PATCH 04/41] Goodbye .NET 3.1 --- src/Prism.Avalonia/Prism.Avalonia.csproj | 2 +- src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Prism.Avalonia/Prism.Avalonia.csproj b/src/Prism.Avalonia/Prism.Avalonia.csproj index 06551bc..7fea9d5 100644 --- a/src/Prism.Avalonia/Prism.Avalonia.csproj +++ b/src/Prism.Avalonia/Prism.Avalonia.csproj @@ -8,7 +8,7 @@ Properties Prism - netcoreapp3.1;net6.0;net7.0;net8.0 + net6.0;net7.0;net8.0 Prism.Avalonia is a fully open source version of the Prism guidance originally produced by Microsoft Patterns & Practices. Prism.Avalonia provides an implementation of a collection of design patterns that are helpful in writing well structured, maintainable, and testable XAML applications, including MVVM, dependency injection, commanding, event aggregation, and more. Prism's core functionality is a shared library targeting the .NET Framework and .NET Standard. Features that need to be platform specific are implemented in the respective libraries for the target platform (Avalonia, WPF, Uno Platform, and Xamarin Forms). Prism.Avalonia helps you more easily design and build rich, flexible, and easy to maintain cross-platform Avalonia desktop applications. This library provides user interface composition as well as modularity support. diff --git a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj index 4644ca4..4219097 100644 --- a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj +++ b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj @@ -7,7 +7,7 @@ Prism.DryIoc - netcoreapp3.1;net6.0;net7.0;net8.0 + net6.0;net7.0;net8.0 This extension is used to build Prism.Avalonia applications based on DryIoc. Users must install the Prism.Avalonia NuGet package as well. Damian Suess, various contributors Copyright (c) 2024 Xeno Innovations, Inc. From 72f38edf32446922eb120e38697aa703270bc136 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 20:34:55 -0400 Subject: [PATCH 05/41] Migrated package versioning to Directory.Packages.props --- ...ctory.Build.Props => Directory.Build.props | 0 Directory.Build.targets | 2 + Directory.Packages.props | 42 +++++++++++++++++++ Prism.Avalonia.sln | 4 +- build/PrismDependency.props | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) rename Directory.Build.Props => Directory.Build.props (100%) create mode 100644 Directory.Build.targets create mode 100644 Directory.Packages.props diff --git a/Directory.Build.Props b/Directory.Build.props similarity index 100% rename from Directory.Build.Props rename to Directory.Build.props diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..8c119d5 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..3098a39 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prism.Avalonia.sln b/Prism.Avalonia.sln index 7455793..64106ce 100644 --- a/Prism.Avalonia.sln +++ b/Prism.Avalonia.sln @@ -35,7 +35,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A1A058C5 build\AvaloniaDependency.props = build\AvaloniaDependency.props build\Base.props = build\Base.props build\BuildTargets.props = build\BuildTargets.props - Directory.Build.Props = Directory.Build.Props + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + Directory.Packages.props = Directory.Packages.props build\EmbedXaml.props = build\EmbedXaml.props build\Library.props = build\Library.props build\Nuget.props = build\Nuget.props diff --git a/build/PrismDependency.props b/build/PrismDependency.props index f33eca9..57f198f 100644 --- a/build/PrismDependency.props +++ b/build/PrismDependency.props @@ -4,6 +4,7 @@ + From 5dfe74c82e031ad6d1014ab6fb58bfd7f3544db3 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 21:18:24 -0400 Subject: [PATCH 06/41] Moved versioning to central package management and not the misc `.props` files --- Directory.Packages.props | 4 +++- build/AvaloniaDependency.props | 6 +++--- build/PrismDependency.props | 3 +-- build/SampleApp.props | 12 ++++++------ src/Prism.Avalonia/Prism.Avalonia.csproj | 7 +++++-- .../Prism.DryIoc.Avalonia.csproj | 4 ++-- .../Prism.Avalonia.Tests.csproj | 14 +++++++------- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 3098a39..e1b0af5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -22,8 +22,10 @@ - + + + diff --git a/build/AvaloniaDependency.props b/build/AvaloniaDependency.props index fd5be6a..d86f649 100644 --- a/build/AvaloniaDependency.props +++ b/build/AvaloniaDependency.props @@ -2,9 +2,9 @@ - - - + + + diff --git a/build/PrismDependency.props b/build/PrismDependency.props index 57f198f..97976e1 100644 --- a/build/PrismDependency.props +++ b/build/PrismDependency.props @@ -3,9 +3,8 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - + - diff --git a/build/SampleApp.props b/build/SampleApp.props index f06c124..3faa810 100644 --- a/build/SampleApp.props +++ b/build/SampleApp.props @@ -6,12 +6,12 @@ - - - - - - + + + + + + diff --git a/src/Prism.Avalonia/Prism.Avalonia.csproj b/src/Prism.Avalonia/Prism.Avalonia.csproj index 7fea9d5..4c79601 100644 --- a/src/Prism.Avalonia/Prism.Avalonia.csproj +++ b/src/Prism.Avalonia/Prism.Avalonia.csproj @@ -14,7 +14,7 @@ Prism.Avalonia helps you more easily design and build rich, flexible, and easy to maintain cross-platform Avalonia desktop applications. This library provides user interface composition as well as modularity support. prism;mvvm;xaml;avalonia;navigation;dialog;prismavalonia; Copyright (c) 2024 Xeno Innovations, Inc. - Damian Suess, various contributors + Damian Suess, Suess Labs, various contributors Prism.Avalonia README.md Prism.Avalonia.png @@ -44,7 +44,10 @@ Prism.Avalonia helps you more easily design and build rich, flexible, and easy t - + + diff --git a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj index 4219097..f51c5d9 100644 --- a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj +++ b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj @@ -9,7 +9,7 @@ Prism.DryIoc net6.0;net7.0;net8.0 This extension is used to build Prism.Avalonia applications based on DryIoc. Users must install the Prism.Avalonia NuGet package as well. - Damian Suess, various contributors + Damian Suess, Suess Labs, various contributors Copyright (c) 2024 Xeno Innovations, Inc. Prism.DryIoc.Avalonia README.md @@ -29,7 +29,7 @@ - + diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj b/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj index bb58862..179465f 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj +++ b/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj @@ -12,19 +12,19 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + From 93b4d576123738e6680ff1e3f2acf8e5fb9580f8 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 22:12:26 -0400 Subject: [PATCH 07/41] Refactored Prism.Services.Dialogs to Prism.Dialogs, dropping files which got absorbed by Prism.Core. Added MarkDown Lint rules file --- .markdownlint.json | 12 ++++ Upgrade-Prism-8.1-9.x.md | 23 ------ ...-Prism-7.2-to-8.1.md => Upgrading-Prism.md | 72 ++++++++++++++++--- .../ViewModels/DialogViewModel.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 2 +- .../ViewModels/MessageBoxViewModel.cs | 2 +- e2e/SampleDialogApp/Views/DialogView.axaml.cs | 4 +- .../{Services => }/Dialogs/Dialog.cs | 2 +- .../{Services => }/Dialogs/DialogService.cs | 2 +- .../{Services => }/Dialogs/DialogWindow.axaml | 2 +- .../Dialogs/DialogWindow.axaml.cs | 2 +- .../{Services => }/Dialogs/IDialogAware.cs | 6 +- .../{Services => }/Dialogs/IDialogService.cs | 2 +- .../Dialogs/IDialogServiceExtensions.cs | 2 +- .../{Services => }/Dialogs/IDialogWindow.cs | 2 +- .../Dialogs/IDialogWindowExtensions.cs | 2 +- .../Ioc/IContainerRegistryExtensions.cs | 10 +-- .../PrismInitializationExtensions.cs | 2 +- src/Prism.Avalonia/Properties/AssemblyInfo.cs | 2 +- .../Services/Dialogs/ButtonResult.cs | 23 ------ .../Services/Dialogs/DialogParameters.cs | 18 ----- .../Services/Dialogs/DialogResult.cs | 34 --------- .../Services/Dialogs/IDialogParameters.cs | 63 ---------------- .../Services/Dialogs/IDialogResult.cs | 19 ----- .../PrismApplicationBaseFixture.cs | 2 +- .../PrismBootstrapperBaseFixture.cs | 4 +- 26 files changed, 100 insertions(+), 216 deletions(-) create mode 100644 .markdownlint.json delete mode 100644 Upgrade-Prism-8.1-9.x.md rename Upgrade-Prism-7.2-to-8.1.md => Upgrading-Prism.md (92%) rename src/Prism.Avalonia/{Services => }/Dialogs/Dialog.cs (99%) rename src/Prism.Avalonia/{Services => }/Dialogs/DialogService.cs (99%) rename src/Prism.Avalonia/{Services => }/Dialogs/DialogWindow.axaml (90%) rename src/Prism.Avalonia/{Services => }/Dialogs/DialogWindow.axaml.cs (95%) rename src/Prism.Avalonia/{Services => }/Dialogs/IDialogAware.cs (95%) rename src/Prism.Avalonia/{Services => }/Dialogs/IDialogService.cs (98%) rename src/Prism.Avalonia/{Services => }/Dialogs/IDialogServiceExtensions.cs (98%) rename src/Prism.Avalonia/{Services => }/Dialogs/IDialogWindow.cs (98%) rename src/Prism.Avalonia/{Services => }/Dialogs/IDialogWindowExtensions.cs (94%) delete mode 100644 src/Prism.Avalonia/Services/Dialogs/ButtonResult.cs delete mode 100644 src/Prism.Avalonia/Services/Dialogs/DialogParameters.cs delete mode 100644 src/Prism.Avalonia/Services/Dialogs/DialogResult.cs delete mode 100644 src/Prism.Avalonia/Services/Dialogs/IDialogParameters.cs delete mode 100644 src/Prism.Avalonia/Services/Dialogs/IDialogResult.cs diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..4790edf --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,12 @@ +{ + "default": true, + "no-hard-tabs": true, + "MD007": { "indent": 2 }, + "MD013": false, + "MD024": { "siblings_only": true, "allow_different_nesting": true }, + "MD033": { + "allowed_elements": [ "br", "hr" ] + }, + "MD055": false, + "MD056": false +} \ No newline at end of file diff --git a/Upgrade-Prism-8.1-9.x.md b/Upgrade-Prism-8.1-9.x.md deleted file mode 100644 index 6f7b613..0000000 --- a/Upgrade-Prism-8.1-9.x.md +++ /dev/null @@ -1,23 +0,0 @@ -# Upgrading Prism.Avalonia to v9.0-pre - -## Overview - -This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soon we will be moving this repo to be apart of the main Prism Library `:)` - -### Release Upgrade Path - -Each of the following will be tagged and merged into the branch `Prism-9x` before being merged with `develop` and `master` branches. - -* [ ] 9.0.264-pre - Won't be published -* [ ] 9.0.271-pre - Will be tagged and released -* [ ] 9.0.401-pre - Will be tagged and released - -### Prism Tag Comparisons - -* [DNF - 9.0.264-pre](https://github.com/PrismLibrary/Prism/compare/DNF...9.0.264-pre) - (_DNF = Dot Net Foundation_) -* [9.0.264-pre - 9.0.274-pre](https://github.com/PrismLibrary/Prism/compare/9.0.264-pre...9.0.271-pre) -* [9.0.274-pre - 9.0.401-pre](https://github.com/PrismLibrary/Prism/compare/9.0.271-pre...9.0.401-pre) - -## Changes - -* `Samples` folder renamed to `e2e` diff --git a/Upgrade-Prism-7.2-to-8.1.md b/Upgrading-Prism.md similarity index 92% rename from Upgrade-Prism-7.2-to-8.1.md rename to Upgrading-Prism.md index 3f43097..8aae5af 100644 --- a/Upgrade-Prism-7.2-to-8.1.md +++ b/Upgrading-Prism.md @@ -1,4 +1,6 @@ -# Upgrading from Prism 7.2 to 8.1 +# Upgrading Prism.Avalonia + +This file documents the upgrade path of the Prism releases, noting files removed :x: , added :new:, and notes on breaking changes. | Icon | Text | Description | |------|------|-------------| @@ -10,9 +12,57 @@ | 💔 | `:broken_heart:` | Never implemented in this platform * [Icon Reference](https://github.com/markdown-templates/markdown-emojis) + +## Overview Prism 8.1.97 to 9.0.x + +This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soon we will be moving this repo to be apart of the main Prism Library `:)` + +Each of the following will be tagged and merged into the branch `Prism-9x` before being merged with `develop` and `master` branches. + +### Progress + +* [/] 9.0.271-pre - Will be tagged and released +* [ ] 9.0.401-pre - Will be tagged and released + +### Release Comparison + +* [DNF - 9.0.264-pre](https://github.com/PrismLibrary/Prism/compare/DNF...9.0.264-pre) - (_DNF = Dot Net Foundation_) +* [9.0.264-pre - 9.0.274-pre](https://github.com/PrismLibrary/Prism/compare/9.0.264-pre...9.0.271-pre) +* [9.0.274-pre - 9.0.401-pre](https://github.com/PrismLibrary/Prism/compare/9.0.271-pre...9.0.401-pre) + +### Changes + +* `Samples` folder renamed to `e2e` + +#### Dialogs + +**Breaking Changes:** + +* Namespace changed from `Prism.Services.Dialogs` to `Prism.Dialogs`. +* `IDialogAware` property, `RequestClose` + * Refactored from `event` to `property` (`event Action RequestClose;` -> `DialogCloseListener RequestClose { get; }`) + * Property is now read-only + +**Removed Files:** + +| File | Status | Notes | +|-------------------------|---------|--------| +| `ButtonResult.cs` | :x: | Absorbed into `Prism.Core` +| `DialogParameters.cs` | :x: | Absorbed into `Prism.Core` +| `DialogResult.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogParameters.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogResult.cs` | :x: | Absorbed into `Prism.Core` + +#### Generic + +| File | Status | Notes | +|-------------------------------------|---------|--------| + +## Upgrading from Prism 7.2 to 8.1 + * Basis of comparison: [Prism Library v7.2.0.1422...v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) -## Action Items +### Action Items * [X] Upgrade Prism.Avalonia * [X] Upgrade Prism.DryIoc @@ -28,14 +78,14 @@ * This requires Avalonia v0.11 and [PR #8277](https://github.com/AvaloniaUI/Avalonia/pull/8277) as per [Issue 7908](https://github.com/AvaloniaUI/Avalonia/issues/7908). * Restructure folders to match PrismLibrary -## Upgrade Progress +### Upgrade Progress | File | Status | Notes | |-----------------------|---------|--------| | Readme.md | :warning: | Needs updated to match 8.1.x NuGet package version | src\Readme.md | :new: | Added from PrismLibrary v8.1.x -### Prism.Avalonia +#### Prism.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -178,7 +228,7 @@ | Services\Dialogs\IDialogWindow.cs | :new: :heavy_check_mark: | Services\Dialogs\IDialogWindowExtensions.cs | :new: :heavy_check_mark: -### Containers +#### Containers Containers is a :new: Folder @@ -193,7 +243,7 @@ Containers is a :new: Folder | Containers\Prism.Unity.Shared\PrismIocExntensions.cs | :new: | Containers\Prism.Unity.Shared\UnityContainerExtension.cs | :new: -### Prism.DryIoc.Avalonia +#### Prism.DryIoc.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -210,7 +260,7 @@ Containers is a :new: Folder | Properties\Resources.Designer.resx | :white_square_button: | Properties\Resources.resx | :white_square_button: -### Prism.Unity.Avalonia +#### Prism.Unity.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -218,7 +268,7 @@ Containers is a :new: Folder | PrismBootstrapper.cs | :heavy_check_mark: | GlobalSuppressions.cs | :heavy_check_mark: -### Tests - Prism.Avalonia.Tests +#### Tests - Prism.Avalonia.Tests Test writted to [Prism.WPF specs](https://github.com/PrismLibrary/Prism/tree/master/tests/Wpf/Prism.Wpf.Tests). @@ -319,14 +369,14 @@ Test writted to [Prism.WPF specs](https://github.com/PrismLibrary/Prism/tree/mas | Regions\Behaviors\SelectorItemsSourceSyncRegionBehaviorFixture.cs | :white_square_button: :warning: | Regions\Behaviors\SyncRegionContextWithHostBehaviorFixture.cs | :heavy_check_mark: -### Tests - Prism.Container.Avalonia.Shared +#### Tests - Prism.Container.Avalonia.Shared | File | Status | Notes | |-----------------------------------------------|---------|--------| | Fixtures\ContainerExtensionCollection.cs | :heavy_check_mark: | | Mocks\NullModuleCatalogBootstrapper.cs | :heavy_check_mark: | -### Tests - Prism.DryIoc.Avalonia.Tests +#### Tests - Prism.DryIoc.Avalonia.Tests **_TBD_** @@ -341,7 +391,7 @@ As we all know, not everything is straight forward between these two XAML techno * [Prism v7.2.0.1422 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) * [Prism v8.0.0.1909 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v8.0.0.1909...v8.1.97) -## Conversion Helpers +### Conversion Helpers [https://docs.avaloniaui.net/misc/wpf/Control-frameworkelement-and-control] diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index 5ae8716..4229aae 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; using Prism.Commands; using Prism.Mvvm; -using Prism.Services.Dialogs; +using Prism.Dialogs; using SampleDialogApp.Views; namespace SampleDialogApp.ViewModels; diff --git a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs index 35f4db1..988be5b 100644 --- a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs @@ -1,5 +1,5 @@ using Prism.Commands; -using Prism.Services.Dialogs; +using Prism.Dialogs; using SampleDialogApp.Views; namespace SampleDialogApp.ViewModels; diff --git a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs index 1f2340b..5861083 100644 --- a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs @@ -1,7 +1,7 @@ using System; using Prism.Commands; using Prism.Mvvm; -using Prism.Services.Dialogs; +using Prism.Dialogs; namespace SampleDialogApp.ViewModels; diff --git a/e2e/SampleDialogApp/Views/DialogView.axaml.cs b/e2e/SampleDialogApp/Views/DialogView.axaml.cs index bb45ac0..696e183 100644 --- a/e2e/SampleDialogApp/Views/DialogView.axaml.cs +++ b/e2e/SampleDialogApp/Views/DialogView.axaml.cs @@ -1,8 +1,8 @@ -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; using Prism.Ioc; -using Prism.Services.Dialogs; +using Prism.Dialogs; using SampleDialogApp.ViewModels; namespace SampleDialogApp.Views; diff --git a/src/Prism.Avalonia/Services/Dialogs/Dialog.cs b/src/Prism.Avalonia/Dialogs/Dialog.cs similarity index 99% rename from src/Prism.Avalonia/Services/Dialogs/Dialog.cs rename to src/Prism.Avalonia/Dialogs/Dialog.cs index faf8d43..bfdc794 100644 --- a/src/Prism.Avalonia/Services/Dialogs/Dialog.cs +++ b/src/Prism.Avalonia/Dialogs/Dialog.cs @@ -3,7 +3,7 @@ using Avalonia.Controls; using Avalonia.Styling; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// This class contains attached properties. diff --git a/src/Prism.Avalonia/Services/Dialogs/DialogService.cs b/src/Prism.Avalonia/Dialogs/DialogService.cs similarity index 99% rename from src/Prism.Avalonia/Services/Dialogs/DialogService.cs rename to src/Prism.Avalonia/Dialogs/DialogService.cs index b7db607..30770e7 100644 --- a/src/Prism.Avalonia/Services/Dialogs/DialogService.cs +++ b/src/Prism.Avalonia/Dialogs/DialogService.cs @@ -6,7 +6,7 @@ using Prism.Common; using Prism.Ioc; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// Implements to show modal and non-modal dialogs. diff --git a/src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml similarity index 90% rename from src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml rename to src/Prism.Avalonia/Dialogs/DialogWindow.axaml index 488b8e7..b97c3bc 100644 --- a/src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml +++ b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - x:Class="Prism.Services.Dialogs.DialogWindow" + x:Class="Prism.Dialogs.DialogWindow" Title="{Binding Title}" WindowStartupLocation="CenterOwner"> diff --git a/src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml.cs b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs similarity index 95% rename from src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml.cs rename to src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs index 7a9039a..73980fe 100644 --- a/src/Prism.Avalonia/Services/Dialogs/DialogWindow.axaml.cs +++ b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs @@ -3,7 +3,7 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// Prism's default dialog host. public partial class DialogWindow : Window, IDialogWindow diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogAware.cs b/src/Prism.Avalonia/Dialogs/IDialogAware.cs similarity index 95% rename from src/Prism.Avalonia/Services/Dialogs/IDialogAware.cs rename to src/Prism.Avalonia/Dialogs/IDialogAware.cs index 7117f57..4ec41fe 100644 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogAware.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogAware.cs @@ -1,6 +1,7 @@ -using System; +/* +using System; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// Interface that provides dialog functions and events to ViewModels. @@ -35,3 +36,4 @@ public interface IDialogAware event Action RequestClose; } } +*/ diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogService.cs b/src/Prism.Avalonia/Dialogs/IDialogService.cs similarity index 98% rename from src/Prism.Avalonia/Services/Dialogs/IDialogService.cs rename to src/Prism.Avalonia/Dialogs/IDialogService.cs index 30dfba2..1046351 100644 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogService.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogService.cs @@ -1,7 +1,7 @@ using System; using Avalonia.Controls; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// Interface to show modal and non-modal dialogs. public interface IDialogService diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogServiceExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs similarity index 98% rename from src/Prism.Avalonia/Services/Dialogs/IDialogServiceExtensions.cs rename to src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs index 7fc5e02..55991da 100644 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogServiceExtensions.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs @@ -1,7 +1,7 @@ using System; using Avalonia.Controls; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// Extensions for the IDialogService diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogWindow.cs b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs similarity index 98% rename from src/Prism.Avalonia/Services/Dialogs/IDialogWindow.cs rename to src/Prism.Avalonia/Dialogs/IDialogWindow.cs index 449af8e..8dcef99 100644 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogWindow.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs @@ -4,7 +4,7 @@ using Avalonia.Controls; using Avalonia.Styling; -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// Interface for a dialog hosting window. diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogWindowExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogWindowExtensions.cs similarity index 94% rename from src/Prism.Avalonia/Services/Dialogs/IDialogWindowExtensions.cs rename to src/Prism.Avalonia/Dialogs/IDialogWindowExtensions.cs index 07bfc04..d60158a 100644 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogWindowExtensions.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogWindowExtensions.cs @@ -1,4 +1,4 @@ -namespace Prism.Services.Dialogs +namespace Prism.Dialogs { /// /// extensions. diff --git a/src/Prism.Avalonia/Ioc/IContainerRegistryExtensions.cs b/src/Prism.Avalonia/Ioc/IContainerRegistryExtensions.cs index 67b575b..47746cf 100644 --- a/src/Prism.Avalonia/Ioc/IContainerRegistryExtensions.cs +++ b/src/Prism.Avalonia/Ioc/IContainerRegistryExtensions.cs @@ -26,7 +26,7 @@ public static void RegisterDialog(this IContainerRegistry containerRegist /// The ViewModel to use as the DataContext for the dialog /// /// The unique name to register with the dialog. - public static void RegisterDialog(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Services.Dialogs.IDialogAware + public static void RegisterDialog(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware { containerRegistry.RegisterForNavigation(name); } @@ -36,9 +36,9 @@ public static void RegisterDialog(this IContainerRegistry con /// /// The Type of the Window class that will be used to host dialogs in the IDialogService /// - public static void RegisterDialogWindow(this IContainerRegistry containerRegistry) where TWindow : Services.Dialogs.IDialogWindow + public static void RegisterDialogWindow(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow { - containerRegistry.Register(typeof(Services.Dialogs.IDialogWindow), typeof(TWindow)); + containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow)); } /// @@ -47,9 +47,9 @@ public static void RegisterDialogWindow(this IContainerRegistry contain /// The Type of the Window class that will be used to host dialogs in the IDialogService /// /// The name of the dialog window - public static void RegisterDialogWindow(this IContainerRegistry containerRegistry, string name) where TWindow : Services.Dialogs.IDialogWindow + public static void RegisterDialogWindow(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow { - containerRegistry.Register(typeof(Services.Dialogs.IDialogWindow), typeof(TWindow), name); + containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow), name); } /// diff --git a/src/Prism.Avalonia/PrismInitializationExtensions.cs b/src/Prism.Avalonia/PrismInitializationExtensions.cs index 4d051c3..f93d3e7 100644 --- a/src/Prism.Avalonia/PrismInitializationExtensions.cs +++ b/src/Prism.Avalonia/PrismInitializationExtensions.cs @@ -5,7 +5,7 @@ using Prism.Mvvm; using Prism.Regions; using Prism.Regions.Behaviors; -using Prism.Services.Dialogs; +using Prism.Dialogs; namespace Prism { diff --git a/src/Prism.Avalonia/Properties/AssemblyInfo.cs b/src/Prism.Avalonia/Properties/AssemblyInfo.cs index e503e22..4d4b6e9 100644 --- a/src/Prism.Avalonia/Properties/AssemblyInfo.cs +++ b/src/Prism.Avalonia/Properties/AssemblyInfo.cs @@ -16,5 +16,5 @@ [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Regions.Behaviors")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Mvvm")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Interactivity")] -[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Services.Dialogs")] +[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Dialogs")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Ioc")] diff --git a/src/Prism.Avalonia/Services/Dialogs/ButtonResult.cs b/src/Prism.Avalonia/Services/Dialogs/ButtonResult.cs deleted file mode 100644 index 174db12..0000000 --- a/src/Prism.Avalonia/Services/Dialogs/ButtonResult.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Prism.Services.Dialogs -{ - /// The result of the dialog. - public enum ButtonResult - { - /// Abort. - Abort = 3, - /// Cancel. - Cancel = 2, - /// Ignore. - Ignore = 5, - /// No. - No = 7, - /// No result returned. - None = 0, - /// OK. - OK = 1, - /// Retry. - Retry = 4, - /// Yes. - Yes = 6 - } -} diff --git a/src/Prism.Avalonia/Services/Dialogs/DialogParameters.cs b/src/Prism.Avalonia/Services/Dialogs/DialogParameters.cs deleted file mode 100644 index b03b7f4..0000000 --- a/src/Prism.Avalonia/Services/Dialogs/DialogParameters.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Prism.Common; - -namespace Prism.Services.Dialogs -{ - /// Represents Dialog parameters. - /// - /// This class can be used to to pass object parameters during the showing and closing of Dialogs. - /// - public class DialogParameters : ParametersBase, IDialogParameters - { - /// Initializes a new instance of the class. - public DialogParameters() : base() { } - - /// Constructs a list of parameters. - /// Query string to be parsed. - public DialogParameters(string query) : base(query) { } - } -} diff --git a/src/Prism.Avalonia/Services/Dialogs/DialogResult.cs b/src/Prism.Avalonia/Services/Dialogs/DialogResult.cs deleted file mode 100644 index 95491d1..0000000 --- a/src/Prism.Avalonia/Services/Dialogs/DialogResult.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Prism.Services.Dialogs -{ - /// - /// An that contains from the dialog - /// and the of the dialog. - /// - public class DialogResult : IDialogResult - { - /// The parameters from the dialog. - public IDialogParameters Parameters { get; private set; } = new DialogParameters(); - - /// The result of the dialog. - public ButtonResult Result { get; private set; } = ButtonResult.None; - - /// Initializes a new instance of the class. - public DialogResult() { } - - /// Initializes a new instance of the class. - /// The result of the dialog. - public DialogResult(ButtonResult result) - { - Result = result; - } - - /// Initializes a new instance of the class. - /// The result of the dialog. - /// The parameters from the dialog. - public DialogResult(ButtonResult result, IDialogParameters parameters) - { - Result = result; - Parameters = parameters; - } - } -} diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogParameters.cs b/src/Prism.Avalonia/Services/Dialogs/IDialogParameters.cs deleted file mode 100644 index 0083505..0000000 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogParameters.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; - -namespace Prism.Services.Dialogs -{ - /// - /// Represents Dialog parameters. - /// - /// - /// A class that implements this interface can be used to pass - /// object parameters during the showing and closing of Dialogs. - /// - public interface IDialogParameters - { - /// - /// Adds the key and value to the collection. - /// - /// The key to reference this parameter value in the collection. - /// The parameter value to store. - void Add(string key, object value); - - /// - /// Checks the collection for the presence of a key. - /// - /// The key to check. - /// true if key exists; false otherwise. - bool ContainsKey(string key); - - /// - /// The number of parameters in the collection. - /// - int Count { get; } - - /// - /// The keys in the collection. - /// - IEnumerable Keys { get; } - - /// - /// Gets the parameter value referenced by a key. - /// - /// The type of object to be returned. - /// The key of the parameter value to be returned. - /// The matching parameter of type . - T GetValue(string key); - - /// - /// Gets all parameter values referenced by a key. - /// - /// The type of object to be returned. - /// The key of the parameter values to be returned. - ///All matching parameter values of type . - IEnumerable GetValues(string key); - - /// - /// Gets the parameter value if the referenced key exists. - /// - /// The type of object to be returned. - /// The key of the parameter value to be returned. - /// The matching parameter of type if the key exists. - /// true if the parameter exists; false otherwise. - bool TryGetValue(string key, out T value); - } -} diff --git a/src/Prism.Avalonia/Services/Dialogs/IDialogResult.cs b/src/Prism.Avalonia/Services/Dialogs/IDialogResult.cs deleted file mode 100644 index 1fefeb9..0000000 --- a/src/Prism.Avalonia/Services/Dialogs/IDialogResult.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Prism.Services.Dialogs -{ - /// - /// Contains from the dialog - /// and the of the dialog. - /// - public interface IDialogResult - { - /// - /// The parameters from the dialog. - /// - IDialogParameters Parameters { get; } - - /// - /// The result of the dialog. - /// - ButtonResult Result { get; } - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs index 14b49db..14ebff3 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs @@ -11,7 +11,7 @@ using Prism.Modularity; using Prism.Regions; using Prism.Regions.Behaviors; -using Prism.Services.Dialogs; +using Prism.Dialogs; using Xunit; namespace Prism.Avalonia.Tests diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs index 23b61f2..44ec2bc 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; using Avalonia.Controls; using Moq; using Prism.Events; @@ -6,7 +6,7 @@ using Prism.Modularity; using Prism.Regions; using Prism.Regions.Behaviors; -using Prism.Services.Dialogs; +using Prism.Dialogs; using Xunit; namespace Prism From 0abe31fc777a462d810402776dbf85abfeddb2b1 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 23:09:40 -0400 Subject: [PATCH 08/41] IDialogWindow ShowDialog() is now a bool? and not a Task. Removed IDialogAware, IDialogServiceExtensions, and IDialogService. Added KnownDialogParameters.cs and IDialogServiceCompatExtensions.cs. Updated dialog sample for handling `RequestClose` --- Upgrading-Prism.md | 18 ++++++ build/Base.props | 2 +- .../ViewModels/DialogViewModel.cs | 2 + src/Prism.Avalonia/Dialogs/DialogService.cs | 20 +++--- src/Prism.Avalonia/Dialogs/IDialogAware.cs | 39 ------------ src/Prism.Avalonia/Dialogs/IDialogService.cs | 31 ---------- .../Dialogs/IDialogServiceCompatExtensions.cs | 62 +++++++++++++++++++ .../Dialogs/IDialogServiceExtensions.cs | 54 ---------------- src/Prism.Avalonia/Dialogs/IDialogWindow.cs | 22 ++----- .../Dialogs/KnownDialogParameters.cs | 11 ++++ 10 files changed, 108 insertions(+), 153 deletions(-) delete mode 100644 src/Prism.Avalonia/Dialogs/IDialogAware.cs delete mode 100644 src/Prism.Avalonia/Dialogs/IDialogService.cs create mode 100644 src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs delete mode 100644 src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs create mode 100644 src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index 8aae5af..2c9b273 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -42,6 +42,9 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor * `IDialogAware` property, `RequestClose` * Refactored from `event` to `property` (`event Action RequestClose;` -> `DialogCloseListener RequestClose { get; }`) * Property is now read-only +* `IDialogService` moved to Prism.Core + * Deprecated `void Show(...)` + * Deprecated `void ShowDialog(Window owner, ...` **Removed Files:** @@ -52,6 +55,21 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor | `DialogResult.cs` | :x: | Absorbed into `Prism.Core` | `IDialogParameters.cs` | :x: | Absorbed into `Prism.Core` | `IDialogResult.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogService.cs` | :white_square_button: :x: | Absorbed into `Prism.Core` +| `IDialogServiceExtensions.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogServiceCompatExtensions` | :new: +| `KnownDialogParameters` | :new: + +**Not Implemented:** + +* `IDialogWindow.Style` - Custom window styles are not implemented at this time. + +**Avalonia vs WPF:** + +| Avalonia | WPF | Reference | +|-|-|-| +| `dialogWindow.Opened` | `dialogWindow.Loaded` +| `EventHandler? Closing;` | `event CancelEventHandler Closing;` | `IDialogWindow.cs` #### Generic diff --git a/build/Base.props b/build/Base.props index 6aec944..324d0a9 100644 --- a/build/Base.props +++ b/build/Base.props @@ -2,7 +2,7 @@ - 9.0.264.11073 + 9.0.271.11073 https://github.com/AvaloniaCommunity/Prism.Avalonia Copyright (c) 2024 Xeno Innovations, Inc. MIT diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index 4229aae..c9cb25f 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -23,6 +23,8 @@ public DialogViewModel(IDialogService dialogService) Title = "I'm a Sample Dialog!"; } + public DialogCloseListener RequestClose { get; } + public string Title { get => _title; set => SetProperty(ref _title, value); } /// Gets or sets the optional parent window of this Dialog pop-up. diff --git a/src/Prism.Avalonia/Dialogs/DialogService.cs b/src/Prism.Avalonia/Dialogs/DialogService.cs index 30770e7..a095d84 100644 --- a/src/Prism.Avalonia/Dialogs/DialogService.cs +++ b/src/Prism.Avalonia/Dialogs/DialogService.cs @@ -1,5 +1,4 @@ using System; -using System.ComponentModel; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; @@ -146,11 +145,10 @@ protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, A { // WPF: dialogWindow.Loaded -= loadedHandler; dialogWindow.Opened -= loadedHandler; - dialogWindow.GetDialogViewModel().RequestClose += requestCloseHandler; + DialogUtilities.InitializeListener(dialogWindow.GetDialogViewModel(), requestCloseHandler); }; dialogWindow.Opened += loadedHandler; - //// WPF: dialogWindow.Loaded += loadedHandler; EventHandler closingHandler = null; closingHandler = (o, e) => @@ -166,7 +164,6 @@ protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, A { dialogWindow.Closed -= closedHandler; dialogWindow.Closing -= closingHandler; - dialogWindow.GetDialogViewModel().RequestClose -= requestCloseHandler; dialogWindow.GetDialogViewModel().OnDialogClosed(); @@ -194,17 +191,16 @@ protected virtual void ConfigureDialogWindowProperties(IDialogWindow window, Ava // WPF: Window > ContentControl > FrameworkElement // Ava: Window > WindowBase > TopLevel > Control > InputElement > Interactive > Layoutable > Visual > StyledElement.Styles (collection) - window.Content = dialogContent; - window.DataContext = viewModel; - - // WPF + // WPF: //// var windowStyle = Dialog.GetWindowStyle(dialogContent); //// if (windowStyle != null) //// window.Style = windowStyle; - //// - //// window.Content = dialogContent; - //// window.DataContext = viewModel; //we want the host window and the dialog to share the same data context - //// + + // Make the host window and the dialog window to share the same context + window.Content = dialogContent; + window.DataContext = viewModel; + + // WPF: //// if (window.Owner == null) //// window.Owner = Application.Current?.Windows.OfType().FirstOrDefault(x => x.IsActive); } diff --git a/src/Prism.Avalonia/Dialogs/IDialogAware.cs b/src/Prism.Avalonia/Dialogs/IDialogAware.cs deleted file mode 100644 index 4ec41fe..0000000 --- a/src/Prism.Avalonia/Dialogs/IDialogAware.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* -using System; - -namespace Prism.Dialogs -{ - /// - /// Interface that provides dialog functions and events to ViewModels. - /// - public interface IDialogAware - { - /// - /// Determines if the dialog can be closed. - /// - /// If true the dialog can be closed. If false the dialog will not close. - bool CanCloseDialog(); - - /// - /// Called when the dialog is closed. - /// - void OnDialogClosed(); - - /// - /// Called when the dialog is opened. - /// - /// The parameters passed to the dialog. - void OnDialogOpened(IDialogParameters parameters); - - /// - /// The title of the dialog that will show in the window title bar. - /// - string Title { get; } - - /// - /// Instructs the to close the dialog. - /// - event Action RequestClose; - } -} -*/ diff --git a/src/Prism.Avalonia/Dialogs/IDialogService.cs b/src/Prism.Avalonia/Dialogs/IDialogService.cs deleted file mode 100644 index 1046351..0000000 --- a/src/Prism.Avalonia/Dialogs/IDialogService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Avalonia.Controls; - -namespace Prism.Dialogs -{ - /// Interface to show modal and non-modal dialogs. - public interface IDialogService - { - /// Shows a non-modal dialog. - /// The name of the dialog to show. - /// The parameters to pass to the dialog. - /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry. - void Show(string name, IDialogParameters parameters, Action callback = null, string windowName = null); - - /// Shows a modal dialog. - /// The name of the dialog to show. - /// The parameters to pass to the dialog. - /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry. - void ShowDialog(string name, IDialogParameters parameters, Action callback = null, string windowName = null); - - /// Shows a modal dialog attached to the defined parent. - /// The optional host window of the modal dialog. - /// The name of the dialog to show. - /// The parameters to pass to the dialog. - /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry. - void ShowDialog(Window owner, string name, IDialogParameters parameters, Action callback = null, string windowName = null); - } -} diff --git a/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs new file mode 100644 index 0000000..dc1c7ca --- /dev/null +++ b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs @@ -0,0 +1,62 @@ +using System; + +namespace Prism.Dialogs +{ + /// Extensions for the IDialogService + public static class IDialogServiceCompatExtensions + { + /// Shows a non-modal dialog. + /// The DialogService + /// The name of the dialog to show. + public static void Show(this IDialogService dialogService, string name, IDialogParameters parameters, Action callback) + { + parameters = EnsureShowNonModalParameter(parameters); + dialogService.ShowDialog(name, parameters, new DialogCallback().OnClose(callback)); + } + + /// Shows a non-modal dialog. + /// The DialogService + /// The name of the dialog to show. + /// The parameters to pass to the dialog. + /// The action to perform when the dialog is closed. + /// The name of the hosting window registered with the IContainerRegistry. + public static void Show(this IDialogService dialogService, string name, IDialogParameters parameters, Action callback, string windowName) + { + parameters = EnsureShowNonModalParameter(parameters); + + if (!string.IsNullOrEmpty(windowName)) + parameters.Add(KnownDialogParameters.WindowName, windowName); + + dialogService.ShowDialog(name, parameters, new DialogCallback().OnClose(callback)); + } + + /// Shows a non-modal dialog. + /// The DialogService + /// The name of the dialog to show. + public static void Show(this IDialogService dialogService, string name) + { + var parameters = EnsureShowNonModalParameter(null); + dialogService.Show(name, parameters, null); + } + + /// Shows a non-modal dialog. + /// The DialogService + /// The name of the dialog to show. + /// The action to perform when the dialog is closed. + public static void Show(this IDialogService dialogService, string name, Action callback) + { + var parameters = EnsureShowNonModalParameter(null); + dialogService.Show(name, parameters, callback); + } + + private static IDialogParameters EnsureShowNonModalParameter(IDialogParameters parameters) + { + parameters ??= new DialogParameters(); + + if (!parameters.ContainsKey(KnownDialogParameters.ShowNonModal)) + parameters.Add(KnownDialogParameters.ShowNonModal, true); + + return parameters; + } + } +} diff --git a/src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs deleted file mode 100644 index 55991da..0000000 --- a/src/Prism.Avalonia/Dialogs/IDialogServiceExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using Avalonia.Controls; - -namespace Prism.Dialogs -{ - /// - /// Extensions for the IDialogService - /// - public static class IDialogServiceExtensions - { - /// - /// Shows a non-modal dialog. - /// - /// The DialogService - /// The name of the dialog to show. - public static void Show(this IDialogService dialogService, string name) - { - dialogService.Show(name, new DialogParameters(), null); - } - - /// - /// Shows a non-modal dialog. - /// - /// The DialogService - /// The name of the dialog to show. - /// The action to perform when the dialog is closed. - public static void Show(this IDialogService dialogService, string name, Action callback) - { - dialogService.Show(name, new DialogParameters(), callback); - } - /// - /// Shows a modal dialog. - /// - /// The DialogService - /// The parent window of the dialog. - /// The name of the dialog to show. - public static void ShowDialog(this IDialogService dialogService, string name) - { - dialogService.ShowDialog(name, new DialogParameters(), null); - } - - /// - /// Shows a modal dialog. - /// - /// The DialogService - /// The parent window of the dialog. - /// The name of the dialog to show. - /// The action to perform when the dialog is closed. - public static void ShowDialog(this IDialogService dialogService, string name, Action callback) - { - dialogService.ShowDialog(name, new DialogParameters(), callback); - } - } -} diff --git a/src/Prism.Avalonia/Dialogs/IDialogWindow.cs b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs index 8dcef99..14d599b 100644 --- a/src/Prism.Avalonia/Dialogs/IDialogWindow.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs @@ -11,30 +11,22 @@ namespace Prism.Dialogs /// public interface IDialogWindow { - /// - /// Dialog content. - /// + /// Dialog content. object Content { get; set; } - /// - /// Close the window. - /// + /// Close the window. void Close(); /// The window's owner. /// Avalonia's WindowBase.Owner's property access is { get; protected set; }. WindowBase Owner { get; } - /// - /// Show a non-modal dialog. - /// + /// Show a non-modal dialog. void Show(); - /// - /// Show a modal dialog. - /// + /// Show a modal dialog. /// - Task ShowDialog(Window owner); + bool? ShowDialog(Window owner); /// /// The data context of the window. @@ -70,9 +62,7 @@ public interface IDialogWindow /// IDialogResult Result { get; set; } - /// - /// The window style. - /// + /// The window style. // WPF: Window > ContentControl > FrameworkElement // Ava: Window > WindowBase > TopLevel > ContentControl > TemplatedControl > Control //Style Style { get; set; } diff --git a/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs b/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs new file mode 100644 index 0000000..89040e3 --- /dev/null +++ b/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs @@ -0,0 +1,11 @@ +namespace Prism.Dialogs; + +/// Provides Dialog Parameter Keys for well known parameters used by the +public static class KnownDialogParameters +{ + /// The name of the window. + public const string WindowName = "windowName"; + + /// Flag to show the Dialog Modally or Non-Modally. + public const string ShowNonModal = "nonModal"; +} From 2ccf9906f0a0d5ea8b27fbb7a836edc01cca8417 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 23:36:40 -0400 Subject: [PATCH 09/41] DialogService handles new parameter format. Forgot, IDialogWindow's ShowDialog() needs to return a `Task` not `bool?` like WPF --- Upgrading-Prism.md | 3 +- src/Prism.Avalonia/Dialogs/DialogService.cs | 61 +++++-------------- .../Dialogs/DialogWindow.axaml.cs | 8 +-- src/Prism.Avalonia/Dialogs/IDialogWindow.cs | 2 +- 4 files changed, 19 insertions(+), 55 deletions(-) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index 2c9b273..035c3fd 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -63,6 +63,7 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor **Not Implemented:** * `IDialogWindow.Style` - Custom window styles are not implemented at this time. +* `DialogWindow.axaml.cs` - Does not implement `this.AttachDevTools();` at this time - _would be helpful during debugging_ **Avalonia vs WPF:** @@ -429,7 +430,7 @@ As we all know, not everything is straight forward between these two XAML techno | `System.Windows.DependencyPropertyChangedEventArgs` | `Avalonia.AvaloniaPropertyChangedEventArgs` | `System.ComponentModel.DesignerProperties.GetIsInDesignMode(DependencyObject element);` | `Avalonia.Controls.Design.IsDesignMode;` | `System.Windows.Controls.Primitives.Selector` | ?? | _used by `SelectorRegionAdapter.cs` and `PrismInitializationExtensions.cs`_ -| `RoutedEventHandler` | _Not Implemented_ +| `RoutedEventHandler` | `EventHandler` ### AvaloniaProperty vs DependencyProperty diff --git a/src/Prism.Avalonia/Dialogs/DialogService.cs b/src/Prism.Avalonia/Dialogs/DialogService.cs index a095d84..b0d2295 100644 --- a/src/Prism.Avalonia/Dialogs/DialogService.cs +++ b/src/Prism.Avalonia/Dialogs/DialogService.cs @@ -7,12 +7,8 @@ namespace Prism.Dialogs { - /// - /// Implements to show modal and non-modal dialogs. - /// - /// - /// The dialog's ViewModel must implement IDialogAware. - /// + /// Implements to show modal and non-modal dialogs. + /// The dialog's ViewModel must implement IDialogAware. public class DialogService : IDialogService { private readonly IContainerExtension _containerExtension; @@ -24,47 +20,20 @@ public DialogService(IContainerExtension containerExtension) _containerExtension = containerExtension; } - /// Shows a non-modal dialog. - /// The name of the dialog to show. - /// The parameters to pass to the dialog. - /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry. - public void Show(string name, IDialogParameters parameters, Action callback = null, string windowName = null) - { - ShowDialogInternal(name, parameters, callback, false, windowName); - } - - /// Shows a modal dialog. - /// The name of the dialog to show. - /// The parameters to pass to the dialog. - /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry. - public void ShowDialog(string name, IDialogParameters parameters, Action callback = null, string windowName = null) + public void ShowDialog(string name, IDialogParameters parameters, DialogCallback callback) { - ShowDialogInternal(name, parameters, callback, true, windowName); - } - - /// - public void ShowDialog(Window owner, string name, IDialogParameters parameters, Action callback = null, string windowName = null) - { - ShowDialogInternal(name, parameters, callback, true, parentWindow: owner, windowName: windowName); - } - - private void ShowDialogInternal(string name, IDialogParameters parameters, Action? callback, bool isModal, string windowName = null, Window parentWindow = null) - { - if (parameters == null) - parameters = new DialogParameters(); + parameters ??= new DialogParameters(); + var isModal = parameters.TryGetValue(KnownDialogParameters.ShowNonModal, out var show) ? !show : true; + var windowName = parameters.TryGetValue(KnownDialogParameters.WindowName, out var wName) ? wName : null; IDialogWindow dialogWindow = CreateDialogWindow(windowName); ConfigureDialogWindowEvents(dialogWindow, callback); ConfigureDialogWindowContent(name, dialogWindow, parameters); - ShowDialogWindow(dialogWindow, isModal, parentWindow); + ShowDialogWindow(dialogWindow, isModal); } - /// - /// Shows the dialog window. - /// + /// Shows the dialog window. /// The dialog window to show. /// If true; dialog is shown as a modal /// Optional host window of the dialog. @@ -74,7 +43,7 @@ protected virtual void ShowDialogWindow(IDialogWindow dialogWindow, bool isModal Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime deskLifetime) { // Ref: - // - https://docs.avaloniaui.net/docs/controls/window#show-a-window-as-a-dialog + // - https://docs.avaloniaui.net/docs/reference/controls/window#show-a-window-as-a-dialog // - https://github.com/AvaloniaUI/Avalonia/discussions/7924 // (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) @@ -129,16 +98,14 @@ protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWi /// /// The hosting window. /// The action to perform when the dialog is closed. - protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, Action? callback = null) + protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, DialogCallback callback) { - Action requestCloseHandler = null; - requestCloseHandler = (o) => + Action requestCloseHandler = (result) => { - dialogWindow.Result = o; + dialogWindow.Result = result; dialogWindow.Close(); }; - // WPF: RoutedEventHandler loadedHandler = null; EventHandler loadedHandler = null; loadedHandler = (o, e) => @@ -160,7 +127,7 @@ protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, A dialogWindow.Closing += closingHandler; EventHandler closedHandler = null; - closedHandler = (o, e) => + closedHandler = async (o, e) => { dialogWindow.Closed -= closedHandler; dialogWindow.Closing -= closingHandler; @@ -170,7 +137,7 @@ protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, A if (dialogWindow.Result == null) dialogWindow.Result = new DialogResult(); - callback?.Invoke(dialogWindow.Result); + await callback.Invoke(dialogWindow.Result); dialogWindow.DataContext = null; dialogWindow.Content = null; diff --git a/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs index 73980fe..5c32254 100644 --- a/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs +++ b/src/Prism.Avalonia/Dialogs/DialogWindow.axaml.cs @@ -8,14 +8,10 @@ namespace Prism.Dialogs /// Prism's default dialog host. public partial class DialogWindow : Window, IDialogWindow { - /// - /// The of the dialog. - /// + /// The of the dialog. public IDialogResult Result { get; set; } - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. public DialogWindow() { InitializeComponent(); diff --git a/src/Prism.Avalonia/Dialogs/IDialogWindow.cs b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs index 14d599b..c367f1f 100644 --- a/src/Prism.Avalonia/Dialogs/IDialogWindow.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogWindow.cs @@ -26,7 +26,7 @@ public interface IDialogWindow /// Show a modal dialog. /// - bool? ShowDialog(Window owner); + Task ShowDialog(Window owner); /// /// The data context of the window. From ca8add04a1d6672aaf943e03b3154b836a98e45e Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 7 Apr 2024 23:53:45 -0400 Subject: [PATCH 10/41] Upgrade Prism notes --- Upgrading-Prism.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index 035c3fd..768a839 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -76,6 +76,29 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor | File | Status | Notes | |-------------------------------------|---------|--------| +| DryIocContainerExtension +| MockHostAwareRegionBehavior.cs +| MockPresentationRegion.cs +| MockRegion.cs +| MockRegionAdapter.cs +| MockRegionBehavior.cs +| MockRegionBehaviorCollection.cs +| MockRegionManager.cs +| MockRegionmanagerAccessor.cs +| MockSortableViews.cs +| MockViewsCollection.cs +| PrismApplicationBaseFixture.cs +| PrismBootstrapperBaseFixture.cs +| AutoPopulateRegionBehaviorFixture.cs +| RegionActiveAwareBehaviorFixture.cs +| RegionManagerRegistrationBehaviorFixture.cs +| RegionMemberlifetimeBehaviorFixture.cs +| ContentControlRegionAdapterFixture.cs +| RegionAdapterBaseFixture.cs +| RegionBehaviorFixture.cs +| RegionFixture.cs +| RegionManagerRequestNavigateFixture.cs +| RegionViewRegistryFixture.cs ## Upgrading from Prism 7.2 to 8.1 From 3cc39599adba7c4da15ec6b169d040918e852501 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Mon, 8 Apr 2024 00:15:36 -0400 Subject: [PATCH 11/41] New Prism.Container packages --- Upgrading-Prism.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index 768a839..4a59c81 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -19,13 +19,18 @@ This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soo Each of the following will be tagged and merged into the branch `Prism-9x` before being merged with `develop` and `master` branches. -### Progress +**Progress:** * [/] 9.0.271-pre - Will be tagged and released * [ ] 9.0.401-pre - Will be tagged and released ### Release Comparison +As we all know, not everything is straight forward between these two XAML technologies. However, it's a good reminder to document the differences and 'got-yas'. + +* [Prism v7.2.0.1422 to v8.0.0.1909](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.0.0.1909) +* [Prism v7.2.0.1422 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) +* [Prism v8.0.0.1909 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v8.0.0.1909...v8.1.97) * [DNF - 9.0.264-pre](https://github.com/PrismLibrary/Prism/compare/DNF...9.0.264-pre) - (_DNF = Dot Net Foundation_) * [9.0.264-pre - 9.0.274-pre](https://github.com/PrismLibrary/Prism/compare/9.0.264-pre...9.0.271-pre) * [9.0.274-pre - 9.0.401-pre](https://github.com/PrismLibrary/Prism/compare/9.0.271-pre...9.0.401-pre) @@ -33,11 +38,13 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor ### Changes * `Samples` folder renamed to `e2e` +* Prism.Dialogs - _See section for more info_ #### Dialogs **Breaking Changes:** +* ***UPGRADE SAMPLE NEEDED*** * Namespace changed from `Prism.Services.Dialogs` to `Prism.Dialogs`. * `IDialogAware` property, `RequestClose` * Refactored from `event` to `property` (`event Action RequestClose;` -> `DialogCloseListener RequestClose { get; }`) @@ -72,11 +79,16 @@ Each of the following will be tagged and merged into the branch `Prism-9x` befor | `dialogWindow.Opened` | `dialogWindow.Loaded` | `EventHandler? Closing;` | `event CancelEventHandler Closing;` | `IDialogWindow.cs` -#### Generic +#### Prism.DryIoc.Avalonia + +| File | Status | Notes | +|-------------------------------------|---------|--------| +| DryIocContainerExtension.cs | :x: | [New Prism.Container Packages](https://github.com/PrismLibrary/Prism/pull/2968) + +#### Prism.Avalonia.Tests | File | Status | Notes | |-------------------------------------|---------|--------| -| DryIocContainerExtension | MockHostAwareRegionBehavior.cs | MockPresentationRegion.cs | MockRegion.cs @@ -425,15 +437,7 @@ Test writted to [Prism.WPF specs](https://github.com/PrismLibrary/Prism/tree/mas | File | Status | Notes | |-----------------------------------------------|---------|--------| -## Prism Upgrade Comparison - -As we all know, not everything is straight forward between these two XAML technologies. However, it's a good reminder to document the differences and 'got-yas'. - -* [Prism v7.2.0.1422 to v8.0.0.1909](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.0.0.1909) -* [Prism v7.2.0.1422 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) -* [Prism v8.0.0.1909 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v8.0.0.1909...v8.1.97) - -### Conversion Helpers +## Conversion Helpers [https://docs.avaloniaui.net/misc/wpf/Control-frameworkelement-and-control] From d263d76ebf88088172ac340d162d19798a4b2f75 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Mon, 8 Apr 2024 00:26:07 -0400 Subject: [PATCH 12/41] Deprecates the use of the Containers built with each platform --- Prism.Avalonia.sln | 14 - .../DryIocContainerExtension.cs | 429 ----------------- .../Prism.DryIoc.Shared.projitems | 15 - .../Prism.DryIoc.Shared.shproj | 13 - .../Prism.DryIoc.Shared/PrismIocExtensions.cs | 31 -- .../Prism.Unity.Shared.projitems | 15 - .../Prism.Unity.Shared.shproj | 13 - .../Prism.Unity.Shared/PrismIocExtensions.cs | 31 -- .../UnityContainerExtension.cs | 449 ------------------ .../Prism.DryIoc.Avalonia.csproj | 1 - .../Fixtures/ContainerExtensionCollection.cs | 13 - .../Mocks/NullModuleCatalogBootstrapper.cs | 23 - .../Prism.Container.Avalonia.Shared.projitems | 18 - .../Prism.Container.Avalonia.Shared.shproj | 13 - .../BootstrapperFixtureBase.cs | 28 -- .../Mocks/DependantA.cs | 17 - .../Mocks/DependantB.cs | 17 - .../Mocks/MockLoggerAdapter.cs | 15 - .../Mocks/MockModuleLoader.cs | 15 - .../Mocks/MockRegionManager.cs | 82 ---- .../Mocks/MockService.cs | 8 - .../Mocks/ViewModels/MockViewModel.cs | 19 - .../Mocks/Views/MockView.cs | 8 - ...IocContainer.Avalonia.Tests.Support.csproj | 19 - 24 files changed, 1306 deletions(-) delete mode 100644 src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs delete mode 100644 src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems delete mode 100644 src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj delete mode 100644 src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs delete mode 100644 src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems delete mode 100644 src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj delete mode 100644 src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs delete mode 100644 src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs delete mode 100644 tests/Avalonia/Prism.Container.Avalonia.Shared/Fixtures/ContainerExtensionCollection.cs delete mode 100644 tests/Avalonia/Prism.Container.Avalonia.Shared/Mocks/NullModuleCatalogBootstrapper.cs delete mode 100644 tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.projitems delete mode 100644 tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.shproj delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/BootstrapperFixtureBase.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantA.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantB.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockLoggerAdapter.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockModuleLoader.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockRegionManager.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockService.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/ViewModels/MockViewModel.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/Views/MockView.cs delete mode 100644 tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Prism.IocContainer.Avalonia.Tests.Support.csproj diff --git a/Prism.Avalonia.sln b/Prism.Avalonia.sln index 64106ce..b12029f 100644 --- a/Prism.Avalonia.sln +++ b/Prism.Avalonia.sln @@ -47,16 +47,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A1A058C5 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Avalonia", "Avalonia", "{9FF880E7-B56A-4E8E-9226-90A928FDE3AB}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{366415D3-E0ED-449C-99E2-A258F6A566F6}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.DryIoc.Shared", "src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.shproj", "{6E7EC81D-DA39-4C4F-A898-0148558C34F4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleMvvmApp", "e2e\SampleMvvmApp\SampleMvvmApp.csproj", "{7AF14280-214B-4A96-AFE8-CF063E2B6CA4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{966DDDE9-D31A-404B-9F24-5378DE8A12C8}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Container.Avalonia.Shared", "tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.shproj", "{340538B6-0781-470E-8BD1-7B7735FDC554}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Avalonia.Tests", "tests\Avalonia\Prism.Avalonia.Tests\Prism.Avalonia.Tests.csproj", "{DAFC499B-E379-4453-BDCE-2EC30E1290C8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleDialogApp", "e2e\SampleDialogApp\SampleDialogApp.csproj", "{97F8C6D3-308C-40BD-B181-5CDFCF101CBF}" @@ -138,19 +132,11 @@ Global {47BC0E69-AF2D-4C4F-886E-31B61E05C57A} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} {B7112DF9-D7A1-48B8-8821-CF81D52F793E} = {47BC0E69-AF2D-4C4F-886E-31B61E05C57A} {9FF880E7-B56A-4E8E-9226-90A928FDE3AB} = {70B9D432-E8BD-4EB9-9CA8-E63E2C804F3F} - {366415D3-E0ED-449C-99E2-A258F6A566F6} = {70B9D432-E8BD-4EB9-9CA8-E63E2C804F3F} - {6E7EC81D-DA39-4C4F-A898-0148558C34F4} = {366415D3-E0ED-449C-99E2-A258F6A566F6} {7AF14280-214B-4A96-AFE8-CF063E2B6CA4} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} - {340538B6-0781-470E-8BD1-7B7735FDC554} = {966DDDE9-D31A-404B-9F24-5378DE8A12C8} {DAFC499B-E379-4453-BDCE-2EC30E1290C8} = {966DDDE9-D31A-404B-9F24-5378DE8A12C8} {97F8C6D3-308C-40BD-B181-5CDFCF101CBF} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D260344D-8648-441D-B85B-9D280005F098} EndGlobalSection - GlobalSection(SharedMSBuildProjectFiles) = preSolution - tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.projitems*{340538b6-0781-470e-8bd1-7b7735fdc554}*SharedItemsImports = 13 - src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*SharedItemsImports = 13 - src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{a379e2c8-bd9a-42a1-8218-ced3c0d75e64}*SharedItemsImports = 5 - EndGlobalSection EndGlobal diff --git a/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs b/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs deleted file mode 100644 index cc4b2bf..0000000 --- a/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs +++ /dev/null @@ -1,429 +0,0 @@ -using System; -using System.Linq; -using DryIoc; -using Prism.Ioc; -using Prism.Ioc.Internals; - -namespace Prism.DryIoc -{ - /// - /// The Implementation to use with DryIoc - /// -#if ContainerExtensions - internal partial -#else - public -#endif - class DryIocContainerExtension : IContainerExtension, IContainerInfo - { - private DryIocScopedProvider _currentScope; - - /// - /// Gets the Default DryIoc Container Rules used by Prism - /// - public static Rules DefaultRules => Rules.Default.WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient) - .With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments)) - .WithFuncAndLazyWithoutRegistration() - .WithTrackingDisposableTransients() - .WithoutFastExpressionCompiler() - .WithFactorySelector(Rules.SelectLastRegisteredFactory()); - - /// - /// The instance of the wrapped container - /// - public IContainer Instance { get; } - -#if !ContainerExtensions - /// - /// Constructs a default instance of the - /// - public DryIocContainerExtension() - : this(new Container(DefaultRules)) - { - } - - /// - /// Constructs a new - /// - /// The instance to use. - public DryIocContainerExtension(IContainer container) - { - Instance = container; - Instance.RegisterInstanceMany(new[] - { - typeof(IContainerExtension), - typeof(IContainerProvider) - }, this); - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(ContainerException)); - } -#endif - - /// - /// Gets the current scope - /// - public IScopedProvider CurrentScope => _currentScope; - - /// - /// Used to perform any final steps for configuring the extension that may be required by the container. - /// - public void FinalizeExtension() { } - - /// - /// Registers an instance of a given - /// - /// The service that is being registered - /// The instance of the service or - /// The instance - public IContainerRegistry RegisterInstance(Type type, object instance) - { - Instance.RegisterInstance(type, instance); - return this; - } - - /// - /// Registers an instance of a given with the specified name or key - /// - /// The service that is being registered - /// The instance of the service or - /// The name or key to register the service - /// The instance - public IContainerRegistry RegisterInstance(Type type, object instance, string name) - { - Instance.RegisterInstance(type, instance, ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: name); - return this; - } - - /// - /// Registers a Singleton with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry RegisterSingleton(Type from, Type to) - { - Instance.Register(from, to, Reuse.Singleton); - return this; - } - - /// - /// Registers a Singleton with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The name or key to register the service - /// The instance - public IContainerRegistry RegisterSingleton(Type from, Type to, string name) - { - Instance.Register(from, to, Reuse.Singleton, ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: name); - return this; - } - - /// - /// Registers a Singleton with the given service factory delegate method. - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry RegisterSingleton(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, r => factoryMethod(), Reuse.Singleton); - return this; - } - - /// - /// Registers a Singleton with the given service factory delegate method. - /// - /// The service - /// The delegate method using . - /// The instance - public IContainerRegistry RegisterSingleton(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, factoryMethod, Reuse.Singleton); - return this; - } - - /// - /// Registers a Singleton Service which implements service interfaces - /// - /// The implementation . - /// The service 's. - /// The instance - /// Registers all interfaces if none are specified. - public IContainerRegistry RegisterManySingleton(Type type, params Type[] serviceTypes) - { - if (serviceTypes.Length == 0) - { - serviceTypes = type.GetInterfaces(); - } - - Instance.RegisterMany(serviceTypes, type, Reuse.Singleton); - return this; - } - - /// - /// Registers a scoped service - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry RegisterScoped(Type from, Type to) - { - Instance.Register(from, to, Reuse.ScopedOrSingleton); - return this; - } - - /// - /// Registers a scoped service using a delegate method. - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry RegisterScoped(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, r => factoryMethod(), Reuse.ScopedOrSingleton); - return this; - } - - /// - /// Registers a scoped service using a delegate method. - /// - /// The service . - /// The delegate method using the . - /// The instance - public IContainerRegistry RegisterScoped(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, factoryMethod, Reuse.ScopedOrSingleton); - return this; - } - - /// - /// Registers a Transient with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry Register(Type from, Type to) - { - Instance.Register(from, to, Reuse.Transient); - return this; - } - - /// - /// Registers a Transient with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The name or key to register the service - /// The instance - public IContainerRegistry Register(Type from, Type to, string name) - { - Instance.Register(from, to, Reuse.Transient, ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: name); - return this; - } - - /// - /// Registers a Transient Service using a delegate method - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry Register(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, r => factoryMethod()); - return this; - } - - /// - /// Registers a Transient Service using a delegate method - /// - /// The service - /// The delegate method using . - /// The instance - public IContainerRegistry Register(Type type, Func factoryMethod) - { - Instance.RegisterDelegate(type, factoryMethod); - return this; - } - - /// - /// Registers a Transient Service which implements service interfaces - /// - /// The implementing . - /// The service 's. - /// The instance - /// Registers all interfaces if none are specified. - public IContainerRegistry RegisterMany(Type type, params Type[] serviceTypes) - { - if (serviceTypes.Length == 0) - { - serviceTypes = type.GetInterfaces(); - } - - Instance.RegisterMany(serviceTypes, type, Reuse.Transient); - return this; - } - - /// - /// Resolves a given - /// - /// The service - /// The resolved Service - public object Resolve(Type type) => - Resolve(type, Array.Empty<(Type, object)>()); - - /// - /// Resolves a given - /// - /// The service - /// The service name/key used when registering the - /// The resolved Service - public object Resolve(Type type, string name) => - Resolve(type, name, Array.Empty<(Type, object)>()); - - /// - /// Resolves a given - /// - /// The service - /// Typed parameters to use when resolving the Service - /// The resolved Service - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - try - { - var container = _currentScope?.Resolver ?? Instance; - return container.Resolve(type, args: parameters.Select(p => p.Instance).ToArray()); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, ex); - } - } - - /// - /// Resolves a given - /// - /// The service - /// The service name/key used when registering the - /// Typed parameters to use when resolving the Service - /// The resolved Service - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - try - { - var container = _currentScope?.Resolver ?? Instance; - return container.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray()); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, name, ex); - } - } - - /// - /// Determines if a given service is registered - /// - /// The service - /// true if the service is registered. - public bool IsRegistered(Type type) - { - return Instance.IsRegistered(type); - } - - /// - /// Determines if a given service is registered with the specified name - /// - /// The service - /// The service name or key used - /// true if the service is registered. - public bool IsRegistered(Type type, string name) - { - return Instance.IsRegistered(type, name) || Instance.IsRegistered(type, name, FactoryType.Wrapper); ; - } - - Type IContainerInfo.GetRegistrationType(string key) - { - var matchingRegistration = Instance.GetServiceRegistrations().Where(r => key.Equals(r.OptionalServiceKey?.ToString(), StringComparison.Ordinal)).FirstOrDefault(); - if (matchingRegistration.OptionalServiceKey == null) - matchingRegistration = Instance.GetServiceRegistrations().Where(r => key.Equals(r.ImplementationType.Name, StringComparison.Ordinal)).FirstOrDefault(); - - return matchingRegistration.ImplementationType; - } - - Type IContainerInfo.GetRegistrationType(Type serviceType) - { - var registration = Instance.GetServiceRegistrations().Where(x => x.ServiceType == serviceType).FirstOrDefault(); - return registration.ServiceType is null ? null : registration.ImplementationType; - } - - /// - /// Creates a new Scope - /// - public virtual IScopedProvider CreateScope() => - CreateScopeInternal(); - - /// - /// Creates a new Scope and provides the updated ServiceProvider - /// - /// The Scoped . - /// - /// This should be called by custom implementations that Implement IServiceScopeFactory - /// - protected IScopedProvider CreateScopeInternal() - { - var resolver = Instance.OpenScope(); - _currentScope = new DryIocScopedProvider(resolver); - return _currentScope; - } - - private class DryIocScopedProvider : IScopedProvider - { - public DryIocScopedProvider(IResolverContext resolver) - { - Resolver = resolver; - } - - public bool IsAttached { get; set; } - - public IResolverContext Resolver { get; private set; } - public IScopedProvider CurrentScope => this; - - public IScopedProvider CreateScope() => this; - - public void Dispose() - { - Resolver.Dispose(); - Resolver = null; - } - - public object Resolve(Type type) => - Resolve(type, Array.Empty<(Type, object)>()); - - public object Resolve(Type type, string name) => - Resolve(type, name, Array.Empty<(Type, object)>()); - - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - try - { - return Resolver.Resolve(type, args: parameters.Select(p => p.Instance).ToArray()); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, ex); - } - } - - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - try - { - return Resolver.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray()); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, name, ex); - } - } - } - } -} diff --git a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems deleted file mode 100644 index 2536e87..0000000 --- a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems +++ /dev/null @@ -1,15 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 6e7ec81d-da39-4c4f-a898-0148558c34f4 - - - Prism.DryIoc - - - - - - \ No newline at end of file diff --git a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj deleted file mode 100644 index ba802d8..0000000 --- a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 6e7ec81d-da39-4c4f-a898-0148558c34f4 - 14.0 - - - - - - - - diff --git a/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs b/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs deleted file mode 100644 index 0fc865e..0000000 --- a/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs +++ /dev/null @@ -1,31 +0,0 @@ -using DryIoc; -using Prism.Ioc; - -namespace Prism.DryIoc -{ - /// - /// Extensions help get the underlying - /// - public static class PrismIocExtensions - { - /// - /// Gets the from the - /// - /// The current - /// The underlying - public static IContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - /// - /// Gets the from the - /// - /// The current - /// The underlying - public static IContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} diff --git a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems deleted file mode 100644 index 06152c6..0000000 --- a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems +++ /dev/null @@ -1,15 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - d66336a6-07e5-401a-a710-daedd6975d59 - - - Prism.Unity - - - - - - \ No newline at end of file diff --git a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj deleted file mode 100644 index 8ce0b4e..0000000 --- a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - d66336a6-07e5-401a-a710-daedd6975d59 - 14.0 - - - - - - - - diff --git a/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs b/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs deleted file mode 100644 index 33e60a4..0000000 --- a/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Prism.Ioc; -using Unity; - -namespace Prism.Unity -{ - /// - /// Extensions help get the underlying - /// - public static class PrismIocExtensions - { - /// - /// Gets the from the - /// - /// The current - /// The underlying - public static IUnityContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - /// - /// Gets the from the - /// - /// The current - /// The underlying - public static IUnityContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} diff --git a/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs b/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs deleted file mode 100644 index 024e098..0000000 --- a/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs +++ /dev/null @@ -1,449 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Prism.Ioc; -using Prism.Ioc.Internals; -using Unity; -using Unity.Lifetime; -using Unity.Resolution; - -namespace Prism.Unity -{ - /// - /// The Unity implementation of the - /// -#if ContainerExtensions - internal partial -#else - public -#endif - class UnityContainerExtension : IContainerExtension, IContainerInfo - { - private UnityScopedProvider _currentScope; - - /// - /// The instance of the wrapped container - /// - public IUnityContainer Instance { get; } - -#if !ContainerExtensions - /// - /// Constructs a default - /// - public UnityContainerExtension() - : this(new UnityContainer()) - { - } - - /// - /// Constructs a with the specified - /// - /// - public UnityContainerExtension(IUnityContainer container) - { - Instance = container; - string currentContainer = "CurrentContainer"; - Instance.RegisterInstance(currentContainer, this); - Instance.RegisterFactory(typeof(IContainerExtension), c => c.Resolve(currentContainer)); - Instance.RegisterFactory(typeof(IContainerProvider), c => c.Resolve(currentContainer)); - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(ResolutionFailedException)); - } -#endif - - /// - /// Gets the current - /// - public IScopedProvider CurrentScope => _currentScope; - - /// - /// Used to perform any final steps for configuring the extension that may be required by the container. - /// - public void FinalizeExtension() { } - - /// - /// Registers an instance of a given - /// - /// The service that is being registered - /// The instance of the service or - /// The instance - public IContainerRegistry RegisterInstance(Type type, object instance) - { - Instance.RegisterInstance(type, instance); - return this; - } - - /// - /// Registers an instance of a given with the specified name or key - /// - /// The service that is being registered - /// The instance of the service or - /// The name or key to register the service - /// The instance - public IContainerRegistry RegisterInstance(Type type, object instance, string name) - { - Instance.RegisterInstance(type, name, instance); - return this; - } - - /// - /// Registers a Singleton with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry RegisterSingleton(Type from, Type to) - { - Instance.RegisterSingleton(from, to); - return this; - } - - /// - /// Registers a Singleton with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The name or key to register the service - /// The instance - public IContainerRegistry RegisterSingleton(Type from, Type to, string name) - { - Instance.RegisterSingleton(from, to, name); - return this; - } - - /// - /// Registers a Singleton with the given service factory delegate method. - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry RegisterSingleton(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, _ => factoryMethod(), new ContainerControlledLifetimeManager()); - return this; - } - - /// - /// Registers a Singleton with the given service factory delegate method. - /// - /// The service - /// The delegate method using . - /// The instance - public IContainerRegistry RegisterSingleton(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, c => factoryMethod(c.Resolve()), new ContainerControlledLifetimeManager()); - return this; - } - - /// - /// Registers a Singleton Service which implements service interfaces - /// - /// The implementation . - /// The service 's. - /// The instance - /// Registers all interfaces if none are specified. - public IContainerRegistry RegisterManySingleton(Type type, params Type[] serviceTypes) - { - Instance.RegisterSingleton(type); - return RegisterManyInternal(type, serviceTypes); - } - - private IContainerRegistry RegisterManyInternal(Type implementingType, Type[] serviceTypes) - { - if (serviceTypes is null || serviceTypes.Length == 0) - { - serviceTypes = implementingType.GetInterfaces().Where(x => x != typeof(IDisposable)).ToArray(); - } - - foreach (var service in serviceTypes) - { - Instance.RegisterFactory(service, c => c.Resolve(implementingType)); - } - - return this; - } - - /// - /// Registers a Transient with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry Register(Type from, Type to) - { - Instance.RegisterType(from, to); - return this; - } - - /// - /// Registers a Transient with the given service and mapping to the specified implementation . - /// - /// The service - /// The implementation - /// The name or key to register the service - /// The instance - public IContainerRegistry Register(Type from, Type to, string name) - { - Instance.RegisterType(from, to, name); - return this; - } - - /// - /// Registers a Transient Service using a delegate method - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry Register(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, _ => factoryMethod()); - return this; - } - - /// - /// Registers a Transient Service using a delegate method - /// - /// The service - /// The delegate method using . - /// The instance - public IContainerRegistry Register(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, c => factoryMethod(c.Resolve())); - return this; - } - - /// - /// Registers a Transient Service which implements service interfaces - /// - /// The implementing . - /// The service 's. - /// The instance - /// Registers all interfaces if none are specified. - public IContainerRegistry RegisterMany(Type type, params Type[] serviceTypes) - { - Instance.RegisterType(type); - return RegisterManyInternal(type, serviceTypes); - } - - /// - /// Registers a scoped service - /// - /// The service - /// The implementation - /// The instance - public IContainerRegistry RegisterScoped(Type from, Type to) - { - Instance.RegisterType(from, to, new HierarchicalLifetimeManager()); - return this; - } - - /// - /// Registers a scoped service using a delegate method. - /// - /// The service - /// The delegate method. - /// The instance - public IContainerRegistry RegisterScoped(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, c => factoryMethod(), new HierarchicalLifetimeManager()); - return this; - } - - /// - /// Registers a scoped service using a delegate method. - /// - /// The service . - /// The delegate method. - /// The instance - public IContainerRegistry RegisterScoped(Type type, Func factoryMethod) - { - Instance.RegisterFactory(type, c => factoryMethod(c.Resolve()), new HierarchicalLifetimeManager()); - return this; - } - - /// - /// Resolves a given - /// - /// The service - /// The resolved Service - public object Resolve(Type type) => - Resolve(type, Array.Empty<(Type, object)>()); - - /// - /// Resolves a given - /// - /// The service - /// The service name/key used when registering the - /// The resolved Service - public object Resolve(Type type, string name) => - Resolve(type, name, Array.Empty<(Type, object)>()); - - /// - /// Resolves a given - /// - /// The service - /// Typed parameters to use when resolving the Service - /// The resolved Service - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - try - { - var c = _currentScope?.Container ?? Instance; - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - - if (typeof(IEnumerable).IsAssignableFrom(type) && type.GetGenericArguments().Length > 0) - { - type = type.GetGenericArguments()[0]; - return c.ResolveAll(type, overrides); - } - - return c.Resolve(type, overrides); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, ex); - } - } - - /// - /// Resolves a given - /// - /// The service - /// The service name/key used when registering the - /// Typed parameters to use when resolving the Service - /// The resolved Service - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - try - { - var c = _currentScope?.Container ?? Instance; - - // Unity will simply return a new object() for unregistered Views - if (!c.IsRegistered(type, name)) - throw new KeyNotFoundException($"No registered type {type.Name} with the key {name}."); - - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return c.Resolve(type, name, overrides); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, name, ex); - } - } - - /// - /// Determines if a given service is registered - /// - /// The service - /// true if the service is registered. - public bool IsRegistered(Type type) - { - return Instance.IsRegistered(type); - } - - /// - /// Determines if a given service is registered with the specified name - /// - /// The service - /// The service name or key used - /// true if the service is registered. - public bool IsRegistered(Type type, string name) - { - return Instance.IsRegistered(type, name); - } - - Type IContainerInfo.GetRegistrationType(string key) - { - //First try friendly name registration. If not found, try type registration - var matchingRegistration = Instance.Registrations.Where(r => key.Equals(r.Name, StringComparison.Ordinal)).FirstOrDefault(); - if (matchingRegistration == null) - { - matchingRegistration = Instance.Registrations.Where(r => key.Equals(r.RegisteredType.Name, StringComparison.Ordinal)).FirstOrDefault(); - } - - return matchingRegistration?.MappedToType; - } - - Type IContainerInfo.GetRegistrationType(Type serviceType) - { - var matchingRegistration = Instance.Registrations.Where(x => x.RegisteredType == serviceType).FirstOrDefault(); - return matchingRegistration?.MappedToType; - } - - /// - /// Creates a new Scope - /// - public virtual IScopedProvider CreateScope() => - CreateScopeInternal(); - - /// - /// Creates a new Scope and provides the updated ServiceProvider - /// - /// A child . - /// - /// This should be called by custom implementations that Implement IServiceScopeFactory - /// - protected IScopedProvider CreateScopeInternal() - { - var child = Instance.CreateChildContainer(); - _currentScope = new UnityScopedProvider(child); - return _currentScope; - } - - private class UnityScopedProvider : IScopedProvider - { - public UnityScopedProvider(IUnityContainer container) - { - Container = container; - } - - public IUnityContainer Container { get; private set; } - public bool IsAttached { get; set; } - public IScopedProvider CurrentScope => this; - - public IScopedProvider CreateScope() => this; - - public void Dispose() - { - Container.Dispose(); - Container = null; - } - - public object Resolve(Type type) => - Resolve(type, Array.Empty<(Type, object)>()); - - public object Resolve(Type type, string name) => - Resolve(type, name, Array.Empty<(Type, object)>()); - - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - try - { - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Container.Resolve(type, overrides); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, ex); - } - } - - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - try - { - // Unity will simply return a new object() for unregistered Views - if (!Container.IsRegistered(type, name)) - throw new KeyNotFoundException($"No registered type {type.Name} with the key {name}."); - - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Container.Resolve(type, name, overrides); - } - catch (Exception ex) - { - throw new ContainerResolutionException(type, name, ex); - } - } - } - } -} diff --git a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj index f51c5d9..9b31122 100644 --- a/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj +++ b/src/Prism.DryIoc.Avalonia/Prism.DryIoc.Avalonia.csproj @@ -3,7 +3,6 @@ - Prism.DryIoc diff --git a/tests/Avalonia/Prism.Container.Avalonia.Shared/Fixtures/ContainerExtensionCollection.cs b/tests/Avalonia/Prism.Container.Avalonia.Shared/Fixtures/ContainerExtensionCollection.cs deleted file mode 100644 index 24d0dca..0000000 --- a/tests/Avalonia/Prism.Container.Avalonia.Shared/Fixtures/ContainerExtensionCollection.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Prism.Container.Avalonia.Tests -{ - public class ContainerExtension { } - - [CollectionDefinition(nameof(ContainerExtension), DisableParallelization = true)] - public class ContainerExtensionCollection : ICollectionFixture - { - } -} diff --git a/tests/Avalonia/Prism.Container.Avalonia.Shared/Mocks/NullModuleCatalogBootstrapper.cs b/tests/Avalonia/Prism.Container.Avalonia.Shared/Mocks/NullModuleCatalogBootstrapper.cs deleted file mode 100644 index 3cdd2cf..0000000 --- a/tests/Avalonia/Prism.Container.Avalonia.Shared/Mocks/NullModuleCatalogBootstrapper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Prism.Container.Avalonia.Mocks -{ - internal partial class NullModuleCatalogBootstrapper - { - protected override IModuleCatalog CreateModuleCatalog() - { - return null; - } - - protected override DependencyObject CreateShell() - { - return null; - } - - protected override void RegisterTypes(IContainerRegistry containerRegistry) - { - } - } -} diff --git a/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.projitems b/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.projitems deleted file mode 100644 index c47218a..0000000 --- a/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.projitems +++ /dev/null @@ -1,18 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 340538b6-0781-470e-8bd1-7b7735fdc554 - - - Prism.Container.Avalonia.Shared - - - - - - - - - \ No newline at end of file diff --git a/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.shproj b/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.shproj deleted file mode 100644 index d02b62e..0000000 --- a/tests/Avalonia/Prism.Container.Avalonia.Shared/Prism.Container.Avalonia.Shared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 340538b6-0781-470e-8bd1-7b7735fdc554 - 14.0 - - - - - - - - diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/BootstrapperFixtureBase.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/BootstrapperFixtureBase.cs deleted file mode 100644 index 7bdbc66..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/BootstrapperFixtureBase.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Prism.IocContainer.Avalonia.Tests.Support -{ - public class BootstrapperFixtureBase - { - protected static void AssertExceptionThrownOnRun(Bootstrapper bootstrapper, Type expectedExceptionType, string expectedExceptionMessageSubstring) - { - bool exceptionThrown = false; - try - { - bootstrapper.Run(); - } - catch (Exception ex) - { - Assert.AreEqual(expectedExceptionType, ex.GetType()); - StringAssert.Contains(ex.Message, expectedExceptionMessageSubstring); - exceptionThrown = true; - } - - if (!exceptionThrown) - { - Assert.Fail("Exception not thrown."); - } - } - } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantA.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantA.cs deleted file mode 100644 index 6910c8f..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantA.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class DependantA : IDependantA - { - public DependantA(IDependantB dependantB) - { - MyDependantB = dependantB; - } - - public IDependantB MyDependantB { get; set; } - } - - public interface IDependantA - { - IDependantB MyDependantB { get; } - } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantB.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantB.cs deleted file mode 100644 index 4a3523a..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/DependantB.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class DependantB : IDependantB - { - public DependantB(IService service) - { - MyService = service; - } - - public IService MyService { get; set; } - } - - public interface IDependantB - { - IService MyService { get; } - } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockLoggerAdapter.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockLoggerAdapter.cs deleted file mode 100644 index f4cda24..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockLoggerAdapter.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using Prism.Logging; - -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class MockLoggerAdapter : ILoggerFacade - { - public IList Messages = new List(); - - public void Log(string message, Category category, Priority priority) - { - Messages.Add(message); - } - } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockModuleLoader.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockModuleLoader.cs deleted file mode 100644 index fc791ad..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockModuleLoader.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Prism.Modularity; - -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class MockModuleInitializer : IModuleInitializer - { - public bool LoadCalled; - - public void Initialize(IModuleInfo moduleInfo) - { - LoadCalled = true; - } - - } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockRegionManager.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockRegionManager.cs deleted file mode 100644 index 8759dbd..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockRegionManager.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using Prism.Regions; - -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class MockRegionManager : IRegionManager - { - #region IRegionManager Members - - public IRegionCollection Regions - { - get { throw new NotImplementedException(); } - } - - public IRegionManager CreateRegionManager() - { - throw new NotImplementedException(); - } - - public IRegionManager AddToRegion(string regionName, object view) - { - throw new NotImplementedException(); - } - - public IRegionManager RegisterViewWithRegion(string regionName, Type viewType) - { - throw new NotImplementedException(); - } - - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, Uri source, Action navigationCallback) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, Uri source) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, string source, Action navigationCallback) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, string source) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters) - { - throw new NotImplementedException(); - } - - public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters) - { - throw new NotImplementedException(); - } - - #endregion - - public bool Navigate(Uri source) - { - throw new NotImplementedException(); - } - } -} diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockService.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockService.cs deleted file mode 100644 index 5b5ed88..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/MockService.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks -{ - public class MockService : IService - { - } - - public interface IService { } -} \ No newline at end of file diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/ViewModels/MockViewModel.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/ViewModels/MockViewModel.cs deleted file mode 100644 index 02bdb68..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/ViewModels/MockViewModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Prism.Mvvm; - -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks.ViewModels -{ - public class MockViewModel : BindableBase - { - private IService _mockService; - public IService MockService - { - get { return _mockService; } - set { SetProperty(ref _mockService, value); } - } - - public MockViewModel(IService mockService) - { - _mockService = mockService; - } - } -} diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/Views/MockView.cs b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/Views/MockView.cs deleted file mode 100644 index 2908c73..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Mocks/Views/MockView.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Avalonia.Controls; - -namespace Prism.IocContainer.Avalonia.Tests.Support.Mocks.Views -{ - public class MockView : Control - { - } -} diff --git a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Prism.IocContainer.Avalonia.Tests.Support.csproj b/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Prism.IocContainer.Avalonia.Tests.Support.csproj deleted file mode 100644 index d42c4d2..0000000 --- a/tests/Avalonia/Prism.IocContainer.Avalonia.Tests.Support/Prism.IocContainer.Avalonia.Tests.Support.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.0 - - false - - - - - - - - - - - - - From 851ed9ae855fe4c1e1fb0709e4e8ebe03487af6b Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Mon, 8 Apr 2024 00:37:30 -0400 Subject: [PATCH 13/41] typo --- .../Regions/Behaviors/DelayedRegionCreationBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs index 79036c5..30078c4 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs +++ b/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; @@ -32,7 +32,7 @@ public class DelayedRegionCreationBehavior /// /// /// The region adapter mappings, that are used to find the correct adapter for - /// a given controltype. The controltype is determined by the value. + /// a given control type. The control type is determined by the value. /// public DelayedRegionCreationBehavior(RegionAdapterMappings regionAdapterMappings) { From a08311ecc6d49833db951a42388d04ded191d94c Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 17:05:51 -0400 Subject: [PATCH 14/41] Moved Regions under the Navigation namespace --- src/Prism.Avalonia/Common/UriParsingHelper.cs | 2 +- .../Regions/AllActiveRegion.cs | 2 +- .../Behaviors/AutoPopulateRegionBehavior.cs | 25 ++-- ...ndRegionContextToAvaloniaObjectBehavior.cs | 31 ++--- .../ClearChildViewsRegionBehavior.cs | 13 +- .../DelayedRegionCreationBehavior.cs | 51 ++++---- .../Behaviors/DestructibleRegionBehavior.cs | 3 +- .../Behaviors/IHostAwareRegionBehavior.cs | 3 +- .../Behaviors/RegionActiveAwareBehavior.cs | 15 +-- .../RegionCreationException.Desktop.cs | 0 .../Behaviors/RegionCreationException.cs | 0 .../RegionManagerRegistrationBehavior.cs | 47 +++---- .../Behaviors/RegionMemberLifetimeBehavior.cs | 7 +- .../SelectorItemsSourceSyncBehavior.cs | 0 .../SyncRegionContextWithHostBehavior.cs | 25 ++-- .../Regions/ContentControlRegionAdapter.cs | 2 +- .../Regions/DefaultRegionManagerAccessor.cs | 2 +- .../{ => Navigation}/Regions/IJournalAware.cs | 2 +- .../Regions/INavigateAsync.cs | 2 +- .../Regions/INavigationAware.cs | 2 +- .../Regions/IRegionAdapter.cs | 2 +- .../Regions/IRegionBehavior.cs | 2 +- .../Regions/IRegionBehaviorCollection.cs | 2 +- .../Regions/IRegionBehaviorFactory.cs | 2 +- .../IRegionBehaviorFactoryExtensions.cs | 2 +- .../Regions/IRegionCollection.cs | 2 +- .../Regions/IRegionManager.cs | 2 +- .../Regions/IRegionManagerAccessor.cs | 2 +- .../Regions/IRegionManagerExtensions.cs | 2 +- .../Regions/IRegionMemberLifetime.cs | 4 +- .../Regions/IRegionNavigationContentLoader.cs | 2 +- .../Regions/IRegionNavigationJournal.cs | 2 +- .../Regions/IRegionNavigationJournalEntry.cs | 2 +- .../Regions/IRegionNavigationService.cs | 2 +- .../Regions/IRegionViewRegistry.cs | 2 +- .../Regions/IViewsCollection.cs | 2 +- .../{ => Navigation}/Regions/ItemMetadata.cs | 8 +- .../Regions/ItemsControlRegionAdapter.cs | 2 +- .../Regions/NavigationAsyncExtensions.cs | 4 +- .../Regions/NavigationContext.cs | 4 +- .../Regions/NavigationParameters.cs | 2 +- .../Regions/NavigationResult.cs | 12 +- .../{ => Navigation}/Regions/Region.cs | 40 +++--- .../Regions/RegionAdapterBase.cs | 18 +-- .../Regions/RegionAdapterMappings.cs | 2 +- .../Regions/RegionBehavior.cs | 8 +- .../Regions/RegionBehaviorCollection.cs | 12 +- .../Regions/RegionBehaviorFactory.cs | 2 +- .../{ => Navigation}/Regions/RegionContext.cs | 2 +- .../{ => Navigation}/Regions/RegionManager.cs | 25 ++-- .../Regions/RegionNavigationContentLoader.cs | 2 +- .../Regions/RegionNavigationEventArgs.cs | 8 +- .../RegionNavigationFailedEventArgs.cs | 10 +- .../Regions/RegionNavigationJournal.cs | 54 ++++---- .../Regions/RegionNavigationJournalEntry.cs | 10 +- .../Regions/RegionNavigationService.cs | 4 +- .../Regions/RegionViewRegistry.cs | 2 +- .../Regions/SelectorRegionAdapter.cs | 0 .../Regions/SingleActiveRegion.cs | 2 +- .../Regions/UpdateRegionsException.Desktop.cs | 0 .../Regions/UpdateRegionsException.cs | 0 .../Regions/ViewRegisteredEventArgs.cs | 6 +- .../ViewRegistrationException.Desktop.cs | 1 + .../Regions/ViewRegistrationException.cs | 1 + .../Regions/ViewsCollection.cs | 100 +++++++-------- src/Prism.Avalonia/PrismApplicationBase.cs | 2 +- src/Prism.Avalonia/PrismBootstrapperBase.cs | 2 +- .../PrismInitializationExtensions.cs | 4 +- .../Regions/IConfirmNavigationRequest.cs | 21 ---- src/Prism.Avalonia/Regions/IRegion.cs | 116 ------------------ .../Regions/RegionMemberLifetimeAttribute.cs | 28 ----- .../Regions/SyncActiveStateAttribute.cs | 12 -- .../Regions/ViewSortHintAttribute.cs | 26 ---- .../Mocks/MockHostAwareRegionBehavior.cs | 2 +- .../Mocks/MockPresentationRegion.cs | 1 - .../Prism.Avalonia.Tests/Mocks/MockRegion.cs | 1 - .../Mocks/MockRegionAdapter.cs | 1 - .../Mocks/MockRegionBehavior.cs | 2 - .../Mocks/MockRegionBehaviorCollection.cs | 1 - .../Mocks/MockRegionManager.cs | 1 - .../Mocks/MockRegionManagerAccessor.cs | 1 - .../Mocks/MockViewsCollection.cs | 1 - .../PrismApplicationBaseFixture.cs | 3 +- .../PrismBootstrapperBaseFixture.cs | 3 +- .../AutoPopulateRegionBehaviorFixture.cs | 1 - ...nContextToAvaloniaObjectBehaviorFixture.cs | 1 - .../ClearChildViewsRegionBehaviorFixture.cs | 3 +- .../DelayedRegionCreationBehaviorFixture.cs | 3 +- .../RegionActiveAwareBehaviorFixture.cs | 1 - ...egionManagerRegistrationBehaviorFixture.cs | 1 - .../RegionMemberLifetimeBehaviorFixture.cs | 2 +- ...yncRegionContextWithHostBehaviorFixture.cs | 3 +- .../ContentControlRegionAdapterFixture.cs | 1 - .../LocatorNavigationTargetHandlerFixture.cs | 1 - .../NavigationAsyncExtensionsFixture.cs | 1 - .../Regions/RegionAdapterBaseFixture.cs | 1 - .../RegionBehaviorCollectionFixture.cs | 1 - .../Regions/RegionBehaviorFactoryFixture.cs | 1 - .../Regions/RegionBehaviorFixture.cs | 1 - .../Regions/RegionFixture.cs | 1 - .../Regions/RegionManagerFixture.cs | 1 - .../RegionManagerRequestNavigateFixture.cs | 1 - .../Regions/RegionNavigationJournalFixture.cs | 1 - .../RegionNavigationServiceFixture.new.cs | 1 - .../Regions/ViewsCollectionFixture.cs | 1 - 105 files changed, 322 insertions(+), 543 deletions(-) rename src/Prism.Avalonia/{ => Navigation}/Regions/AllActiveRegion.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/AutoPopulateRegionBehavior.cs (81%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs (75%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/ClearChildViewsRegionBehavior.cs (89%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/DelayedRegionCreationBehavior.cs (83%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/DestructibleRegionBehavior.cs (94%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/IHostAwareRegionBehavior.cs (90%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/RegionActiveAwareBehavior.cs (89%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/RegionCreationException.Desktop.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/RegionCreationException.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/RegionManagerRegistrationBehavior.cs (75%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/RegionMemberLifetimeBehavior.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs (77%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ContentControlRegionAdapter.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/DefaultRegionManagerAccessor.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IJournalAware.cs (92%) rename src/Prism.Avalonia/{ => Navigation}/Regions/INavigateAsync.cs (97%) rename src/Prism.Avalonia/{ => Navigation}/Regions/INavigationAware.cs (97%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionAdapter.cs (94%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionBehavior.cs (92%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionBehaviorCollection.cs (97%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionBehaviorFactory.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionBehaviorFactoryExtensions.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionCollection.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionManager.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionManagerAccessor.cs (97%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionManagerExtensions.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionMemberLifetime.cs (86%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionNavigationContentLoader.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionNavigationJournal.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionNavigationJournalEntry.cs (93%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionNavigationService.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IRegionViewRegistry.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/IViewsCollection.cs (94%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ItemMetadata.cs (94%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ItemsControlRegionAdapter.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/NavigationAsyncExtensions.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/NavigationContext.cs (95%) rename src/Prism.Avalonia/{ => Navigation}/Regions/NavigationParameters.cs (95%) rename src/Prism.Avalonia/{ => Navigation}/Regions/NavigationResult.cs (87%) rename src/Prism.Avalonia/{ => Navigation}/Regions/Region.cs (91%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionAdapterBase.cs (92%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionAdapterMappings.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionBehavior.cs (91%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionBehaviorCollection.cs (92%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionBehaviorFactory.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionContext.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionManager.cs (97%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationContentLoader.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationEventArgs.cs (86%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationFailedEventArgs.cs (89%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationJournal.cs (74%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationJournalEntry.cs (75%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionNavigationService.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/RegionViewRegistry.cs (99%) rename src/Prism.Avalonia/{ => Navigation}/Regions/SelectorRegionAdapter.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/SingleActiveRegion.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/UpdateRegionsException.Desktop.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/UpdateRegionsException.cs (100%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ViewRegisteredEventArgs.cs (89%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ViewRegistrationException.Desktop.cs (96%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ViewRegistrationException.cs (98%) rename src/Prism.Avalonia/{ => Navigation}/Regions/ViewsCollection.cs (75%) delete mode 100644 src/Prism.Avalonia/Regions/IConfirmNavigationRequest.cs delete mode 100644 src/Prism.Avalonia/Regions/IRegion.cs delete mode 100644 src/Prism.Avalonia/Regions/RegionMemberLifetimeAttribute.cs delete mode 100644 src/Prism.Avalonia/Regions/SyncActiveStateAttribute.cs delete mode 100644 src/Prism.Avalonia/Regions/ViewSortHintAttribute.cs diff --git a/src/Prism.Avalonia/Common/UriParsingHelper.cs b/src/Prism.Avalonia/Common/UriParsingHelper.cs index a174b51..c824741 100644 --- a/src/Prism.Avalonia/Common/UriParsingHelper.cs +++ b/src/Prism.Avalonia/Common/UriParsingHelper.cs @@ -1,5 +1,5 @@ using System; -using Prism.Regions; +using Prism.Navigation.Regions; namespace Prism.Common { diff --git a/src/Prism.Avalonia/Regions/AllActiveRegion.cs b/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs similarity index 96% rename from src/Prism.Avalonia/Regions/AllActiveRegion.cs rename to src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs index 6216a7a..92441b2 100644 --- a/src/Prism.Avalonia/Regions/AllActiveRegion.cs +++ b/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs @@ -1,7 +1,7 @@ using System; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Region that keeps all the views in it as active. Deactivation of views is not allowed. diff --git a/src/Prism.Avalonia/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs similarity index 81% rename from src/Prism.Avalonia/Regions/Behaviors/AutoPopulateRegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs index f323633..1a21622 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/AutoPopulateRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Populates the target region with the views registered to it in the . @@ -30,24 +31,24 @@ public AutoPopulateRegionBehavior(IRegionViewRegistry regionViewRegistry) /// protected override void OnAttach() { - if (string.IsNullOrEmpty(this.Region.Name)) + if (string.IsNullOrEmpty(Region.Name)) { - this.Region.PropertyChanged += this.Region_PropertyChanged; + Region.PropertyChanged += Region_PropertyChanged; } else { - this.StartPopulatingContent(); + StartPopulatingContent(); } } private void StartPopulatingContent() { - foreach (object view in this.CreateViewsToAutoPopulate()) + foreach (object view in CreateViewsToAutoPopulate()) { AddViewIntoRegion(view); } - this.regionViewRegistry.ContentRegistered += this.OnViewRegistered; + regionViewRegistry.ContentRegistered += OnViewRegistered; } /// @@ -57,7 +58,7 @@ private void StartPopulatingContent() /// protected virtual IEnumerable CreateViewsToAutoPopulate() { - return this.regionViewRegistry.GetContents(this.Region.Name); + return regionViewRegistry.GetContents(Region.Name); } /// @@ -66,15 +67,15 @@ protected virtual IEnumerable CreateViewsToAutoPopulate() /// protected virtual void AddViewIntoRegion(object viewToAdd) { - this.Region.Add(viewToAdd); + Region.Add(viewToAdd); } private void Region_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName == "Name" && !string.IsNullOrEmpty(this.Region.Name)) + if (e.PropertyName == "Name" && !string.IsNullOrEmpty(Region.Name)) { - this.Region.PropertyChanged -= this.Region_PropertyChanged; - this.StartPopulatingContent(); + Region.PropertyChanged -= Region_PropertyChanged; + StartPopulatingContent(); } } @@ -90,7 +91,7 @@ public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e) if (e == null) throw new ArgumentNullException(nameof(e)); - if (e.RegionName == this.Region.Name) + if (e.RegionName == Region.Name) { AddViewIntoRegion(e.GetView()); } diff --git a/src/Prism.Avalonia/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs similarity index 75% rename from src/Prism.Avalonia/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs index 66022cb..012b3f8 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs @@ -1,10 +1,11 @@ using Avalonia; using Prism.Common; +using Prism.Navigation.Regions; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Defines a behavior that forwards the @@ -27,10 +28,10 @@ public class BindRegionContextToAvaloniaObjectBehavior : IRegionBehavior /// public void Attach() { - this.Region.Views.CollectionChanged += this.Views_CollectionChanged; - this.Region.PropertyChanged += this.Region_PropertyChanged; - SetContextToViews(this.Region.Views, this.Region.Context); - this.AttachNotifyChangeEvent(this.Region.Views); + Region.Views.CollectionChanged += Views_CollectionChanged; + Region.PropertyChanged += Region_PropertyChanged; + SetContextToViews(Region.Views, Region.Context); + AttachNotifyChangeEvent(Region.Views); } private static void SetContextToViews(IEnumerable views, object context) @@ -54,7 +55,7 @@ private void AttachNotifyChangeEvent(IEnumerable views) if (AvaloniaObject != null) { ObservableObject viewRegionContext = RegionContext.GetObservableContext(AvaloniaObject); - viewRegionContext.PropertyChanged += this.ViewRegionContext_OnPropertyChangedEvent; + viewRegionContext.PropertyChanged += ViewRegionContext_OnPropertyChangedEvent; } } } @@ -67,7 +68,7 @@ private void DetachNotifyChangeEvent(IEnumerable views) if (AvaloniaObject != null) { ObservableObject viewRegionContext = RegionContext.GetObservableContext(AvaloniaObject); - viewRegionContext.PropertyChanged -= this.ViewRegionContext_OnPropertyChangedEvent; + viewRegionContext.PropertyChanged -= ViewRegionContext_OnPropertyChangedEvent; } } } @@ -76,8 +77,8 @@ private void ViewRegionContext_OnPropertyChangedEvent(object sender, PropertyCha { if (args.PropertyName == "Value") { - var context = (ObservableObject) sender; - this.Region.Context = context.Value; + var context = (ObservableObject)sender; + Region.Context = context.Value; } } @@ -85,14 +86,14 @@ private void Views_CollectionChanged(object sender, NotifyCollectionChangedEvent { if (e.Action == NotifyCollectionChangedAction.Add) { - SetContextToViews(e.NewItems, this.Region.Context); - this.AttachNotifyChangeEvent(e.NewItems); + SetContextToViews(e.NewItems, Region.Context); + AttachNotifyChangeEvent(e.NewItems); } - else if (e.Action == NotifyCollectionChangedAction.Remove && this.Region.Context != null) + else if (e.Action == NotifyCollectionChangedAction.Remove && Region.Context != null) { - this.DetachNotifyChangeEvent(e.OldItems); + DetachNotifyChangeEvent(e.OldItems); SetContextToViews(e.OldItems, null); - + } } @@ -100,7 +101,7 @@ private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Context") { - SetContextToViews(this.Region.Views, this.Region.Context); + SetContextToViews(Region.Views, Region.Context); } } } diff --git a/src/Prism.Avalonia/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs similarity index 89% rename from src/Prism.Avalonia/Regions/Behaviors/ClearChildViewsRegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs index 2435dc7..296c77e 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/ClearChildViewsRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs @@ -1,8 +1,9 @@ using Avalonia; using Avalonia.Controls; +using Prism.Navigation.Regions; using System; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Behavior that removes the RegionManager attached property of all the views in a region once the RegionManager property of a region becomes null. @@ -35,7 +36,7 @@ public static bool GetClearChildViews(AvaloniaObject target) if (target == null) throw new ArgumentNullException(nameof(target)); - return (bool)target.GetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty); + return (bool)target.GetValue(ClearChildViewsProperty); } /// @@ -48,7 +49,7 @@ public static void SetClearChildViews(AvaloniaObject target, bool value) if (target == null) throw new ArgumentNullException(nameof(target)); - target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value); + target.SetValue(ClearChildViewsProperty, value); } /// @@ -56,7 +57,7 @@ public static void SetClearChildViews(AvaloniaObject target, bool value) /// protected override void OnAttach() { - this.Region.PropertyChanged += Region_PropertyChanged; + Region.PropertyChanged += Region_PropertyChanged; } private static void ClearChildViews(IRegion region) @@ -78,9 +79,9 @@ private void Region_PropertyChanged(object sender, System.ComponentModel.Propert { if (e.PropertyName == "RegionManager") { - if (this.Region.RegionManager == null) + if (Region.RegionManager == null) { - ClearChildViews(this.Region); + ClearChildViews(Region); } } } diff --git a/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs similarity index 83% rename from src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs index 30078c4..3011f0f 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/DelayedRegionCreationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs @@ -5,9 +5,10 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Threading; +using Prism.Navigation.Regions; using Prism.Properties; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Behavior that creates a new , when the control that will host the (see ) @@ -37,7 +38,7 @@ public class DelayedRegionCreationBehavior public DelayedRegionCreationBehavior(RegionAdapterMappings regionAdapterMappings) { this.regionAdapterMappings = regionAdapterMappings; - this.RegionManagerAccessor = new DefaultRegionManagerAccessor(); + RegionManagerAccessor = new DefaultRegionManagerAccessor(); } /// @@ -53,8 +54,8 @@ public DelayedRegionCreationBehavior(RegionAdapterMappings regionAdapterMappings /// The target element. public AvaloniaObject TargetElement { - get { return this.elementWeakReference != null ? this.elementWeakReference.Target as AvaloniaObject : null; } - set { this.elementWeakReference = new WeakReference(value); } + get { return elementWeakReference != null ? elementWeakReference.Target as AvaloniaObject : null; } + set { elementWeakReference = new WeakReference(value); } } /// @@ -63,8 +64,8 @@ public AvaloniaObject TargetElement /// public void Attach() { - this.RegionManagerAccessor.UpdatingRegions += this.OnUpdatingRegions; - this.WireUpTargetElement(); + RegionManagerAccessor.UpdatingRegions += OnUpdatingRegions; + WireUpTargetElement(); } /// @@ -72,8 +73,8 @@ public void Attach() /// public void Detach() { - this.RegionManagerAccessor.UpdatingRegions -= this.OnUpdatingRegions; - this.UnWireTargetElement(); + RegionManagerAccessor.UpdatingRegions -= OnUpdatingRegions; + UnWireTargetElement(); } /// @@ -83,31 +84,31 @@ public void Detach() /// This method has to be public, because it has to be callable using weak references in silverlight and other partial trust environments. /// /// The . - /// The instance containing the event data. + /// The instance containing the event data. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", Justification = "This has to be public in order to work with weak references in partial trust or Silverlight environments.")] public void OnUpdatingRegions(object sender, EventArgs e) { - this.TryCreateRegion(); + TryCreateRegion(); } private void TryCreateRegion() { - AvaloniaObject targetElement = this.TargetElement; + AvaloniaObject targetElement = TargetElement; if (targetElement == null) { - this.Detach(); + Detach(); return; } if (Dispatcher.UIThread.CheckAccess()) { - this.Detach(); + Detach(); - if (!this.regionCreated) + if (!regionCreated) { - string regionName = this.RegionManagerAccessor.GetRegionName(targetElement); + string regionName = RegionManagerAccessor.GetRegionName(targetElement); CreateRegion(targetElement, regionName); - this.regionCreated = true; + regionCreated = true; } } } @@ -126,7 +127,7 @@ protected virtual IRegion CreateRegion(AvaloniaObject targetElement, string regi try { // Build the region - IRegionAdapter regionAdapter = this.regionAdapterMappings.GetMapping(targetElement.GetType()); + IRegionAdapter regionAdapter = regionAdapterMappings.GetMapping(targetElement.GetType()); IRegion region = regionAdapter.Initialize(targetElement, regionName); return region; @@ -139,16 +140,16 @@ protected virtual IRegion CreateRegion(AvaloniaObject targetElement, string regi private void ElementLoaded(object sender, VisualTreeAttachmentEventArgs e) { - this.UnWireTargetElement(); - this.TryCreateRegion(); + UnWireTargetElement(); + TryCreateRegion(); } private void WireUpTargetElement() { - Control element = this.TargetElement as Control; + Control element = TargetElement as Control; if (element != null) { - element.AttachedToVisualTree += this.ElementLoaded; + element.AttachedToVisualTree += ElementLoaded; return; } @@ -164,7 +165,7 @@ private void WireUpTargetElement() //if the element is a dependency object, and not a Control, nothing is holding onto the reference after the DelayedRegionCreationBehavior //is instantiated inside RegionManager.CreateRegion(DependencyObject element). If the GC runs before RegionManager.UpdateRegions is called, the region will //never get registered because it is gone from the updatingRegionsListeners list inside RegionManager. So we need to hold on to it. This should be rare. - AvaloniaObject depObj = this.TargetElement as AvaloniaObject; + AvaloniaObject depObj = TargetElement as AvaloniaObject; if (depObj != null) { Track(); @@ -174,10 +175,10 @@ private void WireUpTargetElement() private void UnWireTargetElement() { - Control element = this.TargetElement as Control; + Control element = TargetElement as Control; if (element != null) { - element.AttachedToVisualTree -= this.ElementLoaded; + element.AttachedToVisualTree -= ElementLoaded; return; } @@ -190,7 +191,7 @@ private void UnWireTargetElement() // return; //} - AvaloniaObject depObj = this.TargetElement as AvaloniaObject; + AvaloniaObject depObj = TargetElement as AvaloniaObject; if (depObj != null) { Untrack(); diff --git a/src/Prism.Avalonia/Regions/Behaviors/DestructibleRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs similarity index 94% rename from src/Prism.Avalonia/Regions/Behaviors/DestructibleRegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs index eedfeee..06cbe9f 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/DestructibleRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs @@ -2,8 +2,9 @@ using System.Collections.Specialized; using Prism.Common; using Prism.Navigation; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Calls on Views and ViewModels diff --git a/src/Prism.Avalonia/Regions/Behaviors/IHostAwareRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs similarity index 90% rename from src/Prism.Avalonia/Regions/Behaviors/IHostAwareRegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs index 8c180a2..eebe7ac 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/IHostAwareRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs @@ -1,6 +1,7 @@ using Avalonia; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Defines a that not allows extensible behaviors on regions which also interact diff --git a/src/Prism.Avalonia/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs similarity index 89% rename from src/Prism.Avalonia/Regions/Behaviors/RegionActiveAwareBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs index 304c4ea..95a73f5 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/RegionActiveAwareBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs @@ -1,11 +1,12 @@ -using System; +using System; using System.Collections.Specialized; using System.Linq; using Avalonia; using Avalonia.Controls; using Prism.Common; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Behavior that monitors a object and @@ -15,7 +16,7 @@ namespace Prism.Regions.Behaviors /// /// /// This class can also sync the active state for any scoped regions directly on the view based on the . - /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view. + /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view. /// public class RegionActiveAwareBehavior : IRegionBehavior { @@ -34,7 +35,7 @@ public class RegionActiveAwareBehavior : IRegionBehavior /// public void Attach() { - INotifyCollectionChanged collection = this.GetCollection(); + INotifyCollectionChanged collection = GetCollection(); if (collection != null) { collection.CollectionChanged += OnCollectionChanged; @@ -46,7 +47,7 @@ public void Attach() /// public void Detach() { - INotifyCollectionChanged collection = this.GetCollection(); + INotifyCollectionChanged collection = GetCollection(); if (collection != null) { collection.CollectionChanged -= OnCollectionChanged; @@ -91,7 +92,7 @@ private void InvokeOnSynchronizedActiveAwareChildren(object item, Action e.ActiveViews); @@ -125,7 +126,7 @@ private bool ShouldSyncActiveState(object view) private INotifyCollectionChanged GetCollection() { - return this.Region.ActiveViews; + return Region.ActiveViews; } } } diff --git a/src/Prism.Avalonia/Regions/Behaviors/RegionCreationException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs similarity index 100% rename from src/Prism.Avalonia/Regions/Behaviors/RegionCreationException.Desktop.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs diff --git a/src/Prism.Avalonia/Regions/Behaviors/RegionCreationException.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs similarity index 100% rename from src/Prism.Avalonia/Regions/Behaviors/RegionCreationException.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs diff --git a/src/Prism.Avalonia/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs similarity index 75% rename from src/Prism.Avalonia/Regions/Behaviors/RegionManagerRegistrationBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs index 55f2f83..d621101 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/RegionManagerRegistrationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs @@ -4,8 +4,9 @@ using Avalonia; using Avalonia.Controls; using Avalonia.VisualTree; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Subscribes to a static event from the in order to register the target @@ -27,7 +28,7 @@ public class RegionManagerRegistrationBehavior : RegionBehavior, IHostAwareRegio /// public RegionManagerRegistrationBehavior() { - this.RegionManagerAccessor = new DefaultRegionManagerAccessor(); + RegionManagerAccessor = new DefaultRegionManagerAccessor(); } /// @@ -54,7 +55,7 @@ public AvaloniaObject HostControl throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach); } - this.hostControl = value; + hostControl = value; } } @@ -64,52 +65,52 @@ public AvaloniaObject HostControl /// protected override void OnAttach() { - if (string.IsNullOrEmpty(this.Region.Name)) + if (string.IsNullOrEmpty(Region.Name)) { - this.Region.PropertyChanged += this.Region_PropertyChanged; + Region.PropertyChanged += Region_PropertyChanged; } else { - this.StartMonitoringRegionManager(); + StartMonitoringRegionManager(); } } private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == "Name" && !string.IsNullOrEmpty(this.Region.Name)) + if (e.PropertyName == "Name" && !string.IsNullOrEmpty(Region.Name)) { - this.Region.PropertyChanged -= this.Region_PropertyChanged; - this.StartMonitoringRegionManager(); + Region.PropertyChanged -= Region_PropertyChanged; + StartMonitoringRegionManager(); } } private void StartMonitoringRegionManager() { - this.RegionManagerAccessor.UpdatingRegions += this.OnUpdatingRegions; - this.TryRegisterRegion(); + RegionManagerAccessor.UpdatingRegions += OnUpdatingRegions; + TryRegisterRegion(); } private void TryRegisterRegion() { - AvaloniaObject targetElement = this.HostControl; + AvaloniaObject targetElement = HostControl; if (targetElement.CheckAccess()) { - IRegionManager regionManager = this.FindRegionManager(targetElement); + IRegionManager regionManager = FindRegionManager(targetElement); - IRegionManager attachedRegionManager = this.GetAttachedRegionManager(); + IRegionManager attachedRegionManager = GetAttachedRegionManager(); if (regionManager != attachedRegionManager) { if (attachedRegionManager != null) { - this.attachedRegionManagerWeakReference = null; - attachedRegionManager.Regions.Remove(this.Region.Name); + attachedRegionManagerWeakReference = null; + attachedRegionManager.Regions.Remove(Region.Name); } if (regionManager != null) { - this.attachedRegionManagerWeakReference = new WeakReference(regionManager); - regionManager.Regions.Add(this.Region); + attachedRegionManagerWeakReference = new WeakReference(regionManager); + regionManager.Regions.Add(Region); } } } @@ -124,12 +125,12 @@ private void TryRegisterRegion() [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", Justification = "This has to be public in order to work with weak references in partial trust or Silverlight environments.")] public void OnUpdatingRegions(object sender, EventArgs e) { - this.TryRegisterRegion(); + TryRegisterRegion(); } private IRegionManager FindRegionManager(AvaloniaObject dependencyObject) { - var regionmanager = this.RegionManagerAccessor.GetRegionManager(dependencyObject); + var regionmanager = RegionManagerAccessor.GetRegionManager(dependencyObject); if (regionmanager != null) { return regionmanager; @@ -139,7 +140,7 @@ private IRegionManager FindRegionManager(AvaloniaObject dependencyObject) AvaloniaObject parent = ((dependencyObject as Visual)?.GetVisualParent() ?? null) as AvaloniaObject; if (parent != null) { - return this.FindRegionManager(parent); + return FindRegionManager(parent); } return null; @@ -147,9 +148,9 @@ private IRegionManager FindRegionManager(AvaloniaObject dependencyObject) private IRegionManager GetAttachedRegionManager() { - if (this.attachedRegionManagerWeakReference != null) + if (attachedRegionManagerWeakReference != null) { - return this.attachedRegionManagerWeakReference.Target as IRegionManager; + return attachedRegionManagerWeakReference.Target as IRegionManager; } return null; diff --git a/src/Prism.Avalonia/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs similarity index 96% rename from src/Prism.Avalonia/Regions/Behaviors/RegionMemberLifetimeBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs index d9ac27b..16627f7 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/RegionMemberLifetimeBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs @@ -1,11 +1,12 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Avalonia.Controls; using Prism.Common; +using Prism.Navigation.Regions; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// The RegionMemberLifetimeBehavior determines if items should be removed from the @@ -42,7 +43,7 @@ public class RegionMemberLifetimeBehavior : RegionBehavior /// protected override void OnAttach() { - this.Region.ActiveViews.CollectionChanged += this.OnActiveViewsChanged; + Region.ActiveViews.CollectionChanged += OnActiveViewsChanged; } private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e) diff --git a/src/Prism.Avalonia/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs similarity index 100% rename from src/Prism.Avalonia/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs diff --git a/src/Prism.Avalonia/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs similarity index 77% rename from src/Prism.Avalonia/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs index 7d36d5d..c9c2ea0 100644 --- a/src/Prism.Avalonia/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs @@ -1,9 +1,10 @@ using System; using Avalonia; using Prism.Common; +using Prism.Navigation.Regions; using Prism.Properties; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { /// /// Behavior that synchronizes the property of a with @@ -26,7 +27,7 @@ private ObservableObject HostControlRegionContext { get { - return RegionContext.GetObservableContext(this.hostControl); + return RegionContext.GetObservableContext(hostControl); } } @@ -49,7 +50,7 @@ public AvaloniaObject HostControl { throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach); } - this.hostControl = value; + hostControl = value; } } @@ -58,14 +59,14 @@ public AvaloniaObject HostControl /// protected override void OnAttach() { - if (this.HostControl != null) + if (HostControl != null) { // Sync values initially. SynchronizeRegionContext(); // Now register for events to keep them in sync - this.HostControlRegionContext.PropertyChanged += this.RegionContextObservableObject_PropertyChanged; - this.Region.PropertyChanged += this.Region_PropertyChanged; + HostControlRegionContext.PropertyChanged += RegionContextObservableObject_PropertyChanged; + Region.PropertyChanged += Region_PropertyChanged; } } @@ -73,11 +74,11 @@ private void Region_PropertyChanged(object sender, System.ComponentModel.Propert { if (e.PropertyName == RegionContextPropertyName) { - if (RegionManager.GetRegionContext(this.HostControl) != this.Region.Context) + if (RegionManager.GetRegionContext(HostControl) != Region.Context) { // Setting this Dependency Property will automatically also change the HostControlRegionContext.Value // (see RegionManager.OnRegionContextChanged()) - RegionManager.SetRegionContext(this.hostControl, this.Region.Context); + RegionManager.SetRegionContext(hostControl, Region.Context); } } } @@ -93,16 +94,16 @@ private void RegionContextObservableObject_PropertyChanged(object sender, System private void SynchronizeRegionContext() { // Forward this value to the Region - if (this.Region.Context != this.HostControlRegionContext.Value) + if (Region.Context != HostControlRegionContext.Value) { - this.Region.Context = this.HostControlRegionContext.Value; + Region.Context = HostControlRegionContext.Value; } // Also make sure the region's StyledProperty was changed (this can occur if the value // was changed only on the HostControlRegionContext) - if (RegionManager.GetRegionContext(this.HostControl) != this.HostControlRegionContext.Value) + if (RegionManager.GetRegionContext(HostControl) != HostControlRegionContext.Value) { - RegionManager.SetRegionContext(this.HostControl, this.HostControlRegionContext.Value); + RegionManager.SetRegionContext(HostControl, HostControlRegionContext.Value); } } } diff --git a/src/Prism.Avalonia/Regions/ContentControlRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs similarity index 98% rename from src/Prism.Avalonia/Regions/ContentControlRegionAdapter.cs rename to src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs index 4830ca9..b9af439 100644 --- a/src/Prism.Avalonia/Regions/ContentControlRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs @@ -5,7 +5,7 @@ using System.Collections.Specialized; using System.Linq; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Adapter that creates a new and monitors its diff --git a/src/Prism.Avalonia/Regions/DefaultRegionManagerAccessor.cs b/src/Prism.Avalonia/Navigation/Regions/DefaultRegionManagerAccessor.cs similarity index 98% rename from src/Prism.Avalonia/Regions/DefaultRegionManagerAccessor.cs rename to src/Prism.Avalonia/Navigation/Regions/DefaultRegionManagerAccessor.cs index d803eff..2f4d1c4 100644 --- a/src/Prism.Avalonia/Regions/DefaultRegionManagerAccessor.cs +++ b/src/Prism.Avalonia/Navigation/Regions/DefaultRegionManagerAccessor.cs @@ -1,7 +1,7 @@ using System; using Avalonia; -namespace Prism.Regions +namespace Prism.Navigation.Regions { internal class DefaultRegionManagerAccessor : IRegionManagerAccessor { diff --git a/src/Prism.Avalonia/Regions/IJournalAware.cs b/src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs similarity index 92% rename from src/Prism.Avalonia/Regions/IJournalAware.cs rename to src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs index dc80eaa..446aa4f 100644 --- a/src/Prism.Avalonia/Regions/IJournalAware.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides a way for objects involved in navigation to opt-out of being added to the IRegionNavigationJournal backstack. diff --git a/src/Prism.Avalonia/Regions/INavigateAsync.cs b/src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs similarity index 97% rename from src/Prism.Avalonia/Regions/INavigateAsync.cs rename to src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs index aa71c5f..ac02fa3 100644 --- a/src/Prism.Avalonia/Regions/INavigateAsync.cs +++ b/src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides methods to perform navigation. diff --git a/src/Prism.Avalonia/Regions/INavigationAware.cs b/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs similarity index 97% rename from src/Prism.Avalonia/Regions/INavigationAware.cs rename to src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs index 488989f..b0c0cbe 100644 --- a/src/Prism.Avalonia/Regions/INavigationAware.cs +++ b/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides a way for objects involved in navigation to be notified of navigation activities. diff --git a/src/Prism.Avalonia/Regions/IRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs similarity index 94% rename from src/Prism.Avalonia/Regions/IRegionAdapter.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs index b08c6f2..455b186 100644 --- a/src/Prism.Avalonia/Regions/IRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines an interfaces to adapt an object and bind it to a new . diff --git a/src/Prism.Avalonia/Regions/IRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs similarity index 92% rename from src/Prism.Avalonia/Regions/IRegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs index 318836d..efd0af3 100644 --- a/src/Prism.Avalonia/Regions/IRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Interface for allowing extensible behavior on regions. diff --git a/src/Prism.Avalonia/Regions/IRegionBehaviorCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs similarity index 97% rename from src/Prism.Avalonia/Regions/IRegionBehaviorCollection.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs index 0612d83..a074929 100644 --- a/src/Prism.Avalonia/Regions/IRegionBehaviorCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines the interface for a collection of classes on a Region. diff --git a/src/Prism.Avalonia/Regions/IRegionBehaviorFactory.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs similarity index 98% rename from src/Prism.Avalonia/Regions/IRegionBehaviorFactory.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs index b9a4c28..75def9f 100644 --- a/src/Prism.Avalonia/Regions/IRegionBehaviorFactory.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Interface for RegionBehaviorFactories. This factory allows the registration of the default set of RegionBehaviors, that will diff --git a/src/Prism.Avalonia/Regions/IRegionBehaviorFactoryExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs similarity index 96% rename from src/Prism.Avalonia/Regions/IRegionBehaviorFactoryExtensions.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs index 4fdfae8..7665565 100644 --- a/src/Prism.Avalonia/Regions/IRegionBehaviorFactoryExtensions.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Extension methods for the IRegionBehaviorFactory. diff --git a/src/Prism.Avalonia/Regions/IRegionCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs similarity index 98% rename from src/Prism.Avalonia/Regions/IRegionCollection.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs index 3e553e1..628626c 100644 --- a/src/Prism.Avalonia/Regions/IRegionCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Collections.Specialized; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines a collection of uniquely identified by their Name. diff --git a/src/Prism.Avalonia/Regions/IRegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs similarity index 99% rename from src/Prism.Avalonia/Regions/IRegionManager.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs index f048036..4875ad9 100644 --- a/src/Prism.Avalonia/Regions/IRegionManager.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines an interface to manage a set of regions and to attach regions to objects (typically controls). diff --git a/src/Prism.Avalonia/Regions/IRegionManagerAccessor.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionManagerAccessor.cs similarity index 97% rename from src/Prism.Avalonia/Regions/IRegionManagerAccessor.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionManagerAccessor.cs index e6524ec..850e697 100644 --- a/src/Prism.Avalonia/Regions/IRegionManagerAccessor.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionManagerAccessor.cs @@ -1,7 +1,7 @@ using System; using Avalonia; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides an abstraction on top of the RegionManager static members. diff --git a/src/Prism.Avalonia/Regions/IRegionManagerExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs similarity index 96% rename from src/Prism.Avalonia/Regions/IRegionManagerExtensions.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs index 4ca2821..a311f46 100644 --- a/src/Prism.Avalonia/Regions/IRegionManagerExtensions.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Common Extensions for the RegionManager diff --git a/src/Prism.Avalonia/Regions/IRegionMemberLifetime.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs similarity index 86% rename from src/Prism.Avalonia/Regions/IRegionMemberLifetime.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs index e8d1036..38c6a55 100644 --- a/src/Prism.Avalonia/Regions/IRegionMemberLifetime.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs @@ -1,6 +1,6 @@ -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// When implemented, allows an instance placed in a diff --git a/src/Prism.Avalonia/Regions/IRegionNavigationContentLoader.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs similarity index 96% rename from src/Prism.Avalonia/Regions/IRegionNavigationContentLoader.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs index 6487586..a2553e5 100644 --- a/src/Prism.Avalonia/Regions/IRegionNavigationContentLoader.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Identifies the view in a region that is the target of a navigation request. diff --git a/src/Prism.Avalonia/Regions/IRegionNavigationJournal.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs similarity index 98% rename from src/Prism.Avalonia/Regions/IRegionNavigationJournal.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs index 32590e0..f7709e7 100644 --- a/src/Prism.Avalonia/Regions/IRegionNavigationJournal.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs @@ -1,4 +1,4 @@ -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides journaling of current, back, and forward navigation within regions. diff --git a/src/Prism.Avalonia/Regions/IRegionNavigationJournalEntry.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs similarity index 93% rename from src/Prism.Avalonia/Regions/IRegionNavigationJournalEntry.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs index 85212cf..10c8766 100644 --- a/src/Prism.Avalonia/Regions/IRegionNavigationJournalEntry.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// An entry in an IRegionNavigationJournal representing the URI navigated to. diff --git a/src/Prism.Avalonia/Regions/IRegionNavigationService.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs similarity index 96% rename from src/Prism.Avalonia/Regions/IRegionNavigationService.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs index f402b22..dff55aa 100644 --- a/src/Prism.Avalonia/Regions/IRegionNavigationService.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides navigation for regions. diff --git a/src/Prism.Avalonia/Regions/IRegionViewRegistry.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs similarity index 98% rename from src/Prism.Avalonia/Regions/IRegionViewRegistry.cs rename to src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs index 84de146..8041afd 100644 --- a/src/Prism.Avalonia/Regions/IRegionViewRegistry.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines the interface for the registry of region's content. diff --git a/src/Prism.Avalonia/Regions/IViewsCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs similarity index 94% rename from src/Prism.Avalonia/Regions/IViewsCollection.cs rename to src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs index dea55f3..d7974de 100644 --- a/src/Prism.Avalonia/Regions/IViewsCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Collections.Specialized; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines a view of a collection. diff --git a/src/Prism.Avalonia/Regions/ItemMetadata.cs b/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs similarity index 94% rename from src/Prism.Avalonia/Regions/ItemMetadata.cs rename to src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs index 321ff25..2627597 100644 --- a/src/Prism.Avalonia/Regions/ItemMetadata.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs @@ -1,7 +1,7 @@ using Avalonia; using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines a class that wraps an item and adds metadata for it. @@ -27,7 +27,7 @@ public class ItemMetadata : AvaloniaObject public ItemMetadata(object item) { // check for null - this.Item = item; + Item = item; } static ItemMetadata() @@ -47,7 +47,7 @@ static ItemMetadata() /// The name of the wrapped item. public string Name { - get { return (string)GetValue(NameProperty); } + get { return GetValue(NameProperty); } set { SetValue(NameProperty, value); } } @@ -57,7 +57,7 @@ public string Name /// if the item should be considered active; otherwise . public bool IsActive { - get { return (bool)GetValue(IsActiveProperty); } + get { return GetValue(IsActiveProperty); } set { SetValue(IsActiveProperty, value); } } diff --git a/src/Prism.Avalonia/Regions/ItemsControlRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs similarity index 98% rename from src/Prism.Avalonia/Regions/ItemsControlRegionAdapter.cs rename to src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs index b049cca..dd10658 100644 --- a/src/Prism.Avalonia/Regions/ItemsControlRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Adapter that creates a new and binds all diff --git a/src/Prism.Avalonia/Regions/NavigationAsyncExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs similarity index 98% rename from src/Prism.Avalonia/Regions/NavigationAsyncExtensions.cs rename to src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs index 967059c..889dc62 100644 --- a/src/Prism.Avalonia/Regions/NavigationAsyncExtensions.cs +++ b/src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides additional methods to the interface. @@ -14,7 +14,7 @@ public static class NavigationAsyncExtensions /// The navigation target public static void RequestNavigate(this INavigateAsync navigation, string target) { - RequestNavigate(navigation, target, nr => { }); + navigation.RequestNavigate(target, nr => { }); } /// diff --git a/src/Prism.Avalonia/Regions/NavigationContext.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs similarity index 95% rename from src/Prism.Avalonia/Regions/NavigationContext.cs rename to src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs index ba9bcb9..93e3cd5 100644 --- a/src/Prism.Avalonia/Regions/NavigationContext.cs +++ b/src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Prism.Common; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Encapsulates information about a navigation request. @@ -64,7 +64,7 @@ private void GetNavigationParameters(NavigationParameters navigationParameters) { foreach (KeyValuePair navigationParameter in navigationParameters) { - this.Parameters.Add(navigationParameter.Key, navigationParameter.Value); + Parameters.Add(navigationParameter.Key, navigationParameter.Value); } } } diff --git a/src/Prism.Avalonia/Regions/NavigationParameters.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs similarity index 95% rename from src/Prism.Avalonia/Regions/NavigationParameters.cs rename to src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs index 871e847..655c521 100644 --- a/src/Prism.Avalonia/Regions/NavigationParameters.cs +++ b/src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs @@ -1,6 +1,6 @@ using Prism.Common; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Represents Navigation parameters. diff --git a/src/Prism.Avalonia/Regions/NavigationResult.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs similarity index 87% rename from src/Prism.Avalonia/Regions/NavigationResult.cs rename to src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs index 8167b96..2b84e6d 100644 --- a/src/Prism.Avalonia/Regions/NavigationResult.cs +++ b/src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Represents the result of navigating to a URI. @@ -14,8 +14,8 @@ public class NavigationResult /// The result. public NavigationResult(NavigationContext context, bool? result) { - this.Context = context; - this.Result = result; + Context = context; + Result = result; } /// @@ -25,9 +25,9 @@ public NavigationResult(NavigationContext context, bool? result) /// The error. public NavigationResult(NavigationContext context, Exception error) { - this.Context = context; - this.Error = error; - this.Result = false; + Context = context; + Error = error; + Result = false; } /// diff --git a/src/Prism.Avalonia/Regions/Region.cs b/src/Prism.Avalonia/Navigation/Regions/Region.cs similarity index 91% rename from src/Prism.Avalonia/Regions/Region.cs rename to src/Prism.Avalonia/Navigation/Regions/Region.cs index 2fe7f7d..a32a2f5 100644 --- a/src/Prism.Avalonia/Regions/Region.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Region.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; @@ -8,7 +8,7 @@ using Prism.Ioc; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Implementation of that allows multiple active views. @@ -32,7 +32,7 @@ public Region() { Behaviors = new RegionBehaviorCollection(this); - _sort = Region.DefaultSortComparison; + _sort = DefaultSortComparison; } /// @@ -224,7 +224,7 @@ protected virtual ObservableCollection ItemMetadataCollection /// The that is set on the view if it is a . It will be the current region manager when using this overload. public IRegionManager Add(object view) { - return this.Add(view, null, false); + return Add(view, null, false); } /// @@ -240,7 +240,7 @@ public IRegionManager Add(object view, string viewName) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "viewName")); } - return this.Add(view, viewName, false); + return Add(view, viewName, false); } /// @@ -252,8 +252,8 @@ public IRegionManager Add(object view, string viewName) /// The that is set on the view if it is a . public virtual IRegionManager Add(object view, string viewName, bool createRegionManagerScope) { - IRegionManager manager = createRegionManagerScope ? this.RegionManager.CreateRegionManager() : this.RegionManager; - this.InnerAdd(view, viewName, manager); + IRegionManager manager = createRegionManagerScope ? RegionManager.CreateRegionManager() : RegionManager; + InnerAdd(view, viewName, manager); return manager; } @@ -263,11 +263,11 @@ public virtual IRegionManager Add(object view, string viewName, bool createRegio /// The view to remove. public virtual void Remove(object view) { - ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view); + ItemMetadata itemMetadata = GetItemMetadataOrThrow(view); ItemMetadataCollection.Remove(itemMetadata); - if (view is AvaloniaObject avaloniaObject && Regions.RegionManager.GetRegionManager(avaloniaObject) == this.RegionManager) + if (view is AvaloniaObject avaloniaObject && Regions.RegionManager.GetRegionManager(avaloniaObject) == RegionManager) { avaloniaObject.ClearValue(Regions.RegionManager.RegionManagerProperty); } @@ -290,7 +290,7 @@ public void RemoveAll() /// The view to activate. public virtual void Activate(object view) { - ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view); + ItemMetadata itemMetadata = GetItemMetadataOrThrow(view); if (!itemMetadata.IsActive) { @@ -304,7 +304,7 @@ public virtual void Activate(object view) /// The view to deactivate. public virtual void Deactivate(object view) { - ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view); + ItemMetadata itemMetadata = GetItemMetadataOrThrow(view); if (itemMetadata.IsActive) { @@ -324,7 +324,7 @@ public virtual object GetView(string viewName) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "viewName")); } - ItemMetadata metadata = this.ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName); + ItemMetadata metadata = ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName); if (metadata != null) { @@ -341,7 +341,7 @@ public virtual object GetView(string viewName) /// A callback to execute when the navigation request is completed. public void RequestNavigate(Uri target, Action navigationCallback) { - this.RequestNavigate(target, navigationCallback, null); + RequestNavigate(target, navigationCallback, null); } /// @@ -352,12 +352,12 @@ public void RequestNavigate(Uri target, Action navigationCallb /// The navigation parameters specific to the navigation request. public void RequestNavigate(Uri target, Action navigationCallback, NavigationParameters navigationParameters) { - this.NavigationService.RequestNavigate(target, navigationCallback, navigationParameters); + NavigationService.RequestNavigate(target, navigationCallback, navigationParameters); } private void InnerAdd(object view, string viewName, IRegionManager scopedRegionManager) { - if (this.ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null) + if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null) { throw new InvalidOperationException(Resources.RegionViewExistsException); } @@ -365,9 +365,9 @@ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionM ItemMetadata itemMetadata = new ItemMetadata(view); if (!string.IsNullOrEmpty(viewName)) { - if (this.ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null) + if (ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null) { - throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName)); } itemMetadata.Name = viewName; @@ -378,7 +378,7 @@ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionM Regions.RegionManager.SetRegionManager(avaloniaObject, scopedRegionManager); } - this.ItemMetadataCollection.Add(itemMetadata); + ItemMetadataCollection.Add(itemMetadata); } private ItemMetadata GetItemMetadataOrThrow(object view) @@ -386,7 +386,7 @@ private ItemMetadata GetItemMetadataOrThrow(object view) if (view == null) throw new ArgumentNullException(nameof(view)); - ItemMetadata itemMetadata = this.ItemMetadataCollection.FirstOrDefault(x => x.Item == view); + ItemMetadata itemMetadata = ItemMetadataCollection.FirstOrDefault(x => x.Item == view); if (itemMetadata == null) throw new ArgumentException(Resources.ViewNotInRegionException, nameof(view)); @@ -396,7 +396,7 @@ private ItemMetadata GetItemMetadataOrThrow(object view) private void OnPropertyChanged(string propertyName) { - PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } /// diff --git a/src/Prism.Avalonia/Regions/RegionAdapterBase.cs b/src/Prism.Avalonia/Navigation/Regions/RegionAdapterBase.cs similarity index 92% rename from src/Prism.Avalonia/Regions/RegionAdapterBase.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionAdapterBase.cs index 57aef07..d84d335 100644 --- a/src/Prism.Avalonia/Regions/RegionAdapterBase.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionAdapterBase.cs @@ -1,10 +1,10 @@ using System; using System.Globalization; using Avalonia; +using Prism.Navigation.Regions.Behaviors; using Prism.Properties; -using Prism.Regions.Behaviors; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Base class to facilitate the creation of implementations. @@ -18,7 +18,7 @@ public abstract class RegionAdapterBase : IRegionAdapter where T : class /// The factory used to create the region behaviors to attach to the created regions. protected RegionAdapterBase(IRegionBehaviorFactory regionBehaviorFactory) { - this.RegionBehaviorFactory = regionBehaviorFactory; + RegionBehaviorFactory = regionBehaviorFactory; } /// @@ -37,14 +37,14 @@ public IRegion Initialize(T regionTarget, string regionName) if (regionName == null) throw new ArgumentNullException(nameof(regionName)); - IRegion region = this.CreateRegion(); + IRegion region = CreateRegion(); region.Name = regionName; SetObservableRegionOnHostingControl(region, regionTarget); - this.Adapt(region, regionTarget); - this.AttachBehaviors(region, regionTarget); - this.AttachDefaultBehaviors(region, regionTarget); + Adapt(region, regionTarget); + AttachBehaviors(region, regionTarget); + AttachDefaultBehaviors(region, regionTarget); return region; } @@ -60,7 +60,7 @@ public IRegion Initialize(T regionTarget, string regionName) /// When is not of type . IRegion IRegionAdapter.Initialize(object regionTarget, string regionName) { - return this.Initialize(GetCastedObject(regionTarget), regionName); + return Initialize(GetCastedObject(regionTarget), regionName); } /// @@ -76,7 +76,7 @@ protected virtual void AttachDefaultBehaviors(IRegion region, T regionTarget) if (regionTarget == null) throw new ArgumentNullException(nameof(regionTarget)); - IRegionBehaviorFactory behaviorFactory = this.RegionBehaviorFactory; + IRegionBehaviorFactory behaviorFactory = RegionBehaviorFactory; if (behaviorFactory != null) { AvaloniaObject avaloniaObjectRegionTarget = regionTarget as AvaloniaObject; diff --git a/src/Prism.Avalonia/Regions/RegionAdapterMappings.cs b/src/Prism.Avalonia/Navigation/Regions/RegionAdapterMappings.cs similarity index 99% rename from src/Prism.Avalonia/Regions/RegionAdapterMappings.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionAdapterMappings.cs index 2f210f1..94344ff 100644 --- a/src/Prism.Avalonia/Regions/RegionAdapterMappings.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionAdapterMappings.cs @@ -4,7 +4,7 @@ using Prism.Ioc; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// This class maps with . diff --git a/src/Prism.Avalonia/Regions/RegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs similarity index 91% rename from src/Prism.Avalonia/Regions/RegionBehavior.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs index 85a184b..c6d5e56 100644 --- a/src/Prism.Avalonia/Regions/RegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs @@ -1,7 +1,7 @@ using System; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides a base class for region's behaviors. @@ -21,12 +21,12 @@ public IRegion Region } set { - if (this.IsAttached) + if (IsAttached) { throw new InvalidOperationException(Resources.RegionBehaviorRegionCannotBeSetAfterAttach); } - this.region = value; + region = value; } } @@ -40,7 +40,7 @@ public IRegion Region /// public void Attach() { - if (this.region == null) + if (region == null) { throw new InvalidOperationException(Resources.RegionBehaviorAttachCannotBeCallWithNullRegion); } diff --git a/src/Prism.Avalonia/Regions/RegionBehaviorCollection.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs similarity index 92% rename from src/Prism.Avalonia/Regions/RegionBehaviorCollection.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs index 62f8865..20affda 100644 --- a/src/Prism.Avalonia/Regions/RegionBehaviorCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// A collection of instances, that are stored and retrieved by Key. @@ -27,7 +27,7 @@ public RegionBehaviorCollection(IRegion region) /// The RegionBehavior that's registered with the key. public IRegionBehavior this[string key] { - get { return this.behaviors[key]; } + get { return behaviors[key]; } } /// @@ -48,11 +48,11 @@ public void Add(string key, IRegionBehavior regionBehavior) if (regionBehavior == null) throw new ArgumentNullException(nameof(regionBehavior)); - if (this.behaviors.ContainsKey(key)) + if (behaviors.ContainsKey(key)) throw new ArgumentException("Could not add duplicate behavior with same key.", nameof(key)); - this.behaviors.Add(key, regionBehavior); - regionBehavior.Region = this.region; + behaviors.Add(key, regionBehavior); + regionBehavior.Region = region; regionBehavior.Attach(); } @@ -64,7 +64,7 @@ public void Add(string key, IRegionBehavior regionBehavior) /// public bool ContainsKey(string key) { - return this.behaviors.ContainsKey(key); + return behaviors.ContainsKey(key); } /// diff --git a/src/Prism.Avalonia/Regions/RegionBehaviorFactory.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs similarity index 99% rename from src/Prism.Avalonia/Regions/RegionBehaviorFactory.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs index db15424..32bc09d 100644 --- a/src/Prism.Avalonia/Regions/RegionBehaviorFactory.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs @@ -5,7 +5,7 @@ using Prism.Ioc; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines a factory that allows the registration of the default set of , that will diff --git a/src/Prism.Avalonia/Regions/RegionContext.cs b/src/Prism.Avalonia/Navigation/Regions/RegionContext.cs similarity index 98% rename from src/Prism.Avalonia/Regions/RegionContext.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionContext.cs index e21bccd..29a129a 100644 --- a/src/Prism.Avalonia/Regions/RegionContext.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionContext.cs @@ -2,7 +2,7 @@ using Avalonia; using Prism.Common; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Class that holds methods to Set and Get the RegionContext from a . diff --git a/src/Prism.Avalonia/Regions/RegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs similarity index 97% rename from src/Prism.Avalonia/Regions/RegionManager.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionManager.cs index 14037be..af50d29 100644 --- a/src/Prism.Avalonia/Regions/RegionManager.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs @@ -11,12 +11,13 @@ using Prism.Events; using Prism.Ioc; using Prism.Properties; -using Prism.Regions.Behaviors; using Prism.Ioc.Internals; using Avalonia; using Avalonia.Controls; +using Prism.Navigation.Regions; +using Prism.Navigation.Regions.Behaviors; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// This class is responsible for maintaining a collection of regions and attaching regions to controls. @@ -496,7 +497,7 @@ private class RegionCollection : IRegionCollection public RegionCollection(IRegionManager regionManager) { this.regionManager = regionManager; - this.regions = new List(); + regions = new List(); } public event NotifyCollectionChangedEventHandler CollectionChanged; @@ -505,7 +506,7 @@ public IEnumerator GetEnumerator() { UpdateRegions(); - return this.regions.GetEnumerator(); + return regions.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() @@ -541,16 +542,16 @@ public void Add(IRegion region) throw new InvalidOperationException(Resources.RegionNameCannotBeEmptyException); } - if (this.GetRegionByName(region.Name) != null) + if (GetRegionByName(region.Name) != null) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.RegionNameExistsException, region.Name)); } - this.regions.Add(region); - region.RegionManager = this.regionManager; + regions.Add(region); + region.RegionManager = regionManager; - this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, region, 0)); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, region, 0)); } public bool Remove(string regionName) @@ -563,10 +564,10 @@ public bool Remove(string regionName) if (region != null) { removed = true; - this.regions.Remove(region); + regions.Remove(region); region.RegionManager = null; - this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, region, 0)); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, region, 0)); } return removed; @@ -602,12 +603,12 @@ public void Add(string regionName, IRegion region) private IRegion GetRegionByName(string regionName) { - return this.regions.FirstOrDefault(r => r.Name == regionName); + return regions.FirstOrDefault(r => r.Name == regionName); } private void OnCollectionChanged(NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { - var handler = this.CollectionChanged; + var handler = CollectionChanged; if (handler != null) { diff --git a/src/Prism.Avalonia/Regions/RegionNavigationContentLoader.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs similarity index 99% rename from src/Prism.Avalonia/Regions/RegionNavigationContentLoader.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs index 9492f8f..885fbea 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationContentLoader.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs @@ -8,7 +8,7 @@ using Prism.Ioc.Internals; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Implementation of that relies on a diff --git a/src/Prism.Avalonia/Regions/RegionNavigationEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs similarity index 86% rename from src/Prism.Avalonia/Regions/RegionNavigationEventArgs.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs index 236349a..b52f236 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationEventArgs.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// EventArgs used with the Navigated event. @@ -16,7 +16,7 @@ public RegionNavigationEventArgs(NavigationContext navigationContext) if (navigationContext == null) throw new ArgumentNullException(nameof(navigationContext)); - this.NavigationContext = navigationContext; + NavigationContext = navigationContext; } /// @@ -36,9 +36,9 @@ public Uri Uri { get { - if (this.NavigationContext != null) + if (NavigationContext != null) { - return this.NavigationContext.Uri; + return NavigationContext.Uri; } return null; diff --git a/src/Prism.Avalonia/Regions/RegionNavigationFailedEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs similarity index 89% rename from src/Prism.Avalonia/Regions/RegionNavigationFailedEventArgs.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs index 21fbe51..364159c 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationFailedEventArgs.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// EventArgs used with the NavigationFailed event. @@ -16,7 +16,7 @@ public RegionNavigationFailedEventArgs(NavigationContext navigationContext) if (navigationContext == null) throw new ArgumentNullException(nameof(navigationContext)); - this.NavigationContext = navigationContext; + NavigationContext = navigationContext; } /// @@ -27,7 +27,7 @@ public RegionNavigationFailedEventArgs(NavigationContext navigationContext) public RegionNavigationFailedEventArgs(NavigationContext navigationContext, Exception error) : this(navigationContext) { - this.Error = error; + Error = error; } /// @@ -53,9 +53,9 @@ public Uri Uri { get { - if (this.NavigationContext != null) + if (NavigationContext != null) { - return this.NavigationContext.Uri; + return NavigationContext.Uri; } return null; diff --git a/src/Prism.Avalonia/Regions/RegionNavigationJournal.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs similarity index 74% rename from src/Prism.Avalonia/Regions/RegionNavigationJournal.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs index e8e6171..b092083 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationJournal.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides journaling of current, back, and forward navigation within regions. @@ -36,7 +36,7 @@ public bool CanGoBack { get { - return this.backStack.Count > 0; + return backStack.Count > 0; } } @@ -50,7 +50,7 @@ public bool CanGoForward { get { - return this.forwardStack.Count > 0; + return forwardStack.Count > 0; } } @@ -59,22 +59,22 @@ public bool CanGoForward /// public void GoBack() { - if (this.CanGoBack) + if (CanGoBack) { - IRegionNavigationJournalEntry entry = this.backStack.Peek(); - this.InternalNavigate( + IRegionNavigationJournalEntry entry = backStack.Peek(); + InternalNavigate( entry, result => { if (result) { - if (this.CurrentEntry != null) + if (CurrentEntry != null) { - this.forwardStack.Push(this.CurrentEntry); + forwardStack.Push(CurrentEntry); } - this.backStack.Pop(); - this.CurrentEntry = entry; + backStack.Pop(); + CurrentEntry = entry; } }); } @@ -85,22 +85,22 @@ public void GoBack() /// public void GoForward() { - if (this.CanGoForward) + if (CanGoForward) { - IRegionNavigationJournalEntry entry = this.forwardStack.Peek(); - this.InternalNavigate( + IRegionNavigationJournalEntry entry = forwardStack.Peek(); + InternalNavigate( entry, result => { if (result) { - if (this.CurrentEntry != null) + if (CurrentEntry != null) { - this.backStack.Push(this.CurrentEntry); + backStack.Push(CurrentEntry); } - this.forwardStack.Pop(); - this.CurrentEntry = entry; + forwardStack.Pop(); + CurrentEntry = entry; } }); } @@ -113,14 +113,14 @@ public void GoForward() /// Determine if the view is added to the back stack or excluded from the history. public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory) { - if (!this.isNavigatingInternal) + if (!isNavigatingInternal) { - if (this.CurrentEntry != null) + if (CurrentEntry != null) { - this.backStack.Push(this.CurrentEntry); + backStack.Push(CurrentEntry); } - this.forwardStack.Clear(); + forwardStack.Clear(); if (persistInHistory) CurrentEntry = entry; @@ -134,19 +134,19 @@ public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistIn /// public void Clear() { - this.CurrentEntry = null; - this.backStack.Clear(); - this.forwardStack.Clear(); + CurrentEntry = null; + backStack.Clear(); + forwardStack.Clear(); } private void InternalNavigate(IRegionNavigationJournalEntry entry, Action callback) { - this.isNavigatingInternal = true; - this.NavigationTarget.RequestNavigate( + isNavigatingInternal = true; + NavigationTarget.RequestNavigate( entry.Uri, nr => { - this.isNavigatingInternal = false; + isNavigatingInternal = false; if (nr.Result.HasValue) { diff --git a/src/Prism.Avalonia/Regions/RegionNavigationJournalEntry.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs similarity index 75% rename from src/Prism.Avalonia/Regions/RegionNavigationJournalEntry.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs index dc86650..81e23c3 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationJournalEntry.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs @@ -1,7 +1,7 @@ using System; using System.Globalization; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// An entry in an IRegionNavigationJournal representing the URI navigated to. @@ -20,16 +20,16 @@ public class RegionNavigationJournalEntry : IRegionNavigationJournalEntry public NavigationParameters Parameters { get; set; } /// - /// Returns a that represents this instance. + /// Returns a that represents this instance. /// /// - /// A that represents this instance. + /// A that represents this instance. /// public override string ToString() { - if (this.Uri != null) + if (Uri != null) { - return string.Format(CultureInfo.CurrentCulture, "RegionNavigationJournalEntry:'{0}'", this.Uri.ToString()); + return string.Format(CultureInfo.CurrentCulture, "RegionNavigationJournalEntry:'{0}'", Uri.ToString()); } return base.ToString(); diff --git a/src/Prism.Avalonia/Regions/RegionNavigationService.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs similarity index 99% rename from src/Prism.Avalonia/Regions/RegionNavigationService.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs index 3ffd94c..275a084 100644 --- a/src/Prism.Avalonia/Regions/RegionNavigationService.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -7,7 +7,7 @@ using Prism.Ioc; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Provides navigation for regions. diff --git a/src/Prism.Avalonia/Regions/RegionViewRegistry.cs b/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs similarity index 99% rename from src/Prism.Avalonia/Regions/RegionViewRegistry.cs rename to src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs index 4ca6e7a..df0ff28 100644 --- a/src/Prism.Avalonia/Regions/RegionViewRegistry.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs @@ -7,7 +7,7 @@ using Prism.Ioc; using Prism.Properties; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Defines a registry for the content of the regions used on View Discovery composition. diff --git a/src/Prism.Avalonia/Regions/SelectorRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs similarity index 100% rename from src/Prism.Avalonia/Regions/SelectorRegionAdapter.cs rename to src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs diff --git a/src/Prism.Avalonia/Regions/SingleActiveRegion.cs b/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs similarity index 96% rename from src/Prism.Avalonia/Regions/SingleActiveRegion.cs rename to src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs index 3693103..e6aebe2 100644 --- a/src/Prism.Avalonia/Regions/SingleActiveRegion.cs +++ b/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Region that allows a maximum of one active view at a time. diff --git a/src/Prism.Avalonia/Regions/UpdateRegionsException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs similarity index 100% rename from src/Prism.Avalonia/Regions/UpdateRegionsException.Desktop.cs rename to src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs diff --git a/src/Prism.Avalonia/Regions/UpdateRegionsException.cs b/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs similarity index 100% rename from src/Prism.Avalonia/Regions/UpdateRegionsException.cs rename to src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs diff --git a/src/Prism.Avalonia/Regions/ViewRegisteredEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs similarity index 89% rename from src/Prism.Avalonia/Regions/ViewRegisteredEventArgs.cs rename to src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs index 72c5b0e..e9a4a40 100644 --- a/src/Prism.Avalonia/Regions/ViewRegisteredEventArgs.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Argument class used by the event when a new content is registered. @@ -14,8 +14,8 @@ public class ViewRegisteredEventArgs : EventArgs /// The content which was registered. public ViewRegisteredEventArgs(string regionName, Func getViewDelegate) { - this.GetView = getViewDelegate; - this.RegionName = regionName; + GetView = getViewDelegate; + RegionName = regionName; } /// diff --git a/src/Prism.Avalonia/Regions/ViewRegistrationException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs similarity index 96% rename from src/Prism.Avalonia/Regions/ViewRegistrationException.Desktop.cs rename to src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs index 449c3a3..a92f611 100644 --- a/src/Prism.Avalonia/Regions/ViewRegistrationException.Desktop.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using Prism.Navigation.Regions; namespace Prism.Regions { diff --git a/src/Prism.Avalonia/Regions/ViewRegistrationException.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs similarity index 98% rename from src/Prism.Avalonia/Regions/ViewRegistrationException.cs rename to src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs index db4d868..9d38fcd 100644 --- a/src/Prism.Avalonia/Regions/ViewRegistrationException.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs @@ -1,4 +1,5 @@ using System; +using Prism.Navigation.Regions; namespace Prism.Regions { diff --git a/src/Prism.Avalonia/Regions/ViewsCollection.cs b/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs similarity index 75% rename from src/Prism.Avalonia/Regions/ViewsCollection.cs rename to src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs index 8ab7760..2f92392 100644 --- a/src/Prism.Avalonia/Regions/ViewsCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs @@ -5,7 +5,7 @@ using System.Collections.Specialized; using System.Linq; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Implementation of that takes an of @@ -30,11 +30,11 @@ public class ViewsCollection : IViewsCollection /// A predicate to filter the collection. public ViewsCollection(ObservableCollection list, Predicate filter) { - this.subjectCollection = list; + subjectCollection = list; this.filter = filter; - this.MonitorAllMetadataItems(); - this.subjectCollection.CollectionChanged += this.SourceCollectionChanged; - this.UpdateFilteredItemsList(); + MonitorAllMetadataItems(); + subjectCollection.CollectionChanged += SourceCollectionChanged; + UpdateFilteredItemsList(); } /// @@ -48,14 +48,14 @@ public ViewsCollection(ObservableCollection list, PredicateThe comparison to use. public Comparison SortComparison { - get { return this.sort; } + get { return sort; } set { - if (this.sort != value) + if (sort != value) { - this.sort = value; - this.UpdateFilteredItemsList(); - this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + sort = value; + UpdateFilteredItemsList(); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } } @@ -67,7 +67,7 @@ public Comparison SortComparison /// if is found in the collection; otherwise, . public bool Contains(object value) { - return this.filteredItems.Contains(value); + return filteredItems.Contains(value); } /// @@ -78,7 +78,7 @@ public bool Contains(object value) /// public IEnumerator GetEnumerator() { - return this.filteredItems.GetEnumerator(); + return filteredItems.GetEnumerator(); } /// @@ -89,7 +89,7 @@ public IEnumerator GetEnumerator() /// IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } /// @@ -98,13 +98,13 @@ IEnumerator IEnumerable.GetEnumerator() /// private void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { - NotifyCollectionChangedEventHandler handler = this.CollectionChanged; + NotifyCollectionChangedEventHandler handler = CollectionChanged; if (handler != null) handler(this, e); } private void NotifyReset() { - this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } /// @@ -112,8 +112,8 @@ private void NotifyReset() /// private void ResetAllMonitors() { - this.RemoveAllMetadataMonitors(); - this.MonitorAllMetadataItems(); + RemoveAllMetadataMonitors(); + MonitorAllMetadataItems(); } /// @@ -121,9 +121,9 @@ private void ResetAllMonitors() /// private void MonitorAllMetadataItems() { - foreach (var item in this.subjectCollection) + foreach (var item in subjectCollection) { - this.AddMetadataMonitor(item, this.filter(item)); + AddMetadataMonitor(item, filter(item)); } } @@ -132,12 +132,12 @@ private void MonitorAllMetadataItems() /// private void RemoveAllMetadataMonitors() { - foreach (var item in this.monitoredItems) + foreach (var item in monitoredItems) { - item.Key.MetadataChanged -= this.OnItemMetadataChanged; + item.Key.MetadataChanged -= OnItemMetadataChanged; } - this.monitoredItems.Clear(); + monitoredItems.Clear(); } /// @@ -147,8 +147,8 @@ private void RemoveAllMetadataMonitors() /// private void AddMetadataMonitor(ItemMetadata itemMetadata, bool isInList) { - itemMetadata.MetadataChanged += this.OnItemMetadataChanged; - this.monitoredItems.Add( + itemMetadata.MetadataChanged += OnItemMetadataChanged; + monitoredItems.Add( itemMetadata, new MonitorInfo { @@ -162,8 +162,8 @@ private void AddMetadataMonitor(ItemMetadata itemMetadata, bool isInList) /// private void RemoveMetadataMonitor(ItemMetadata itemMetadata) { - itemMetadata.MetadataChanged -= this.OnItemMetadataChanged; - this.monitoredItems.Remove(itemMetadata); + itemMetadata.MetadataChanged -= OnItemMetadataChanged; + monitoredItems.Remove(itemMetadata); } /// @@ -179,10 +179,10 @@ private void OnItemMetadataChanged(object sender, EventArgs e) // our OnItemMetadataChanged got called back, so it's not unexpected // that we may not have it in our list. MonitorInfo monitorInfo; - bool foundInfo = this.monitoredItems.TryGetValue(itemMetadata, out monitorInfo); + bool foundInfo = monitoredItems.TryGetValue(itemMetadata, out monitorInfo); if (!foundInfo) return; - if (this.filter(itemMetadata)) + if (filter(itemMetadata)) { if (!monitorInfo.IsInList) { @@ -190,7 +190,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e) // as in our list so we can consider this // an Add. monitorInfo.IsInList = true; - this.UpdateFilteredItemsList(); + UpdateFilteredItemsList(); NotifyAdd(itemMetadata.Item); } } @@ -200,7 +200,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e) // tracking list, but should not remove any monitoring in // case it fits our filter in the future. monitorInfo.IsInList = false; - this.RemoveFromFilteredList(itemMetadata.Item); + RemoveFromFilteredList(itemMetadata.Item); } } @@ -214,11 +214,11 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent switch (e.Action) { case NotifyCollectionChangedAction.Add: - this.UpdateFilteredItemsList(); + UpdateFilteredItemsList(); foreach (ItemMetadata itemMetadata in e.NewItems) { - bool isInFilter = this.filter(itemMetadata); - this.AddMetadataMonitor(itemMetadata, isInFilter); + bool isInFilter = filter(itemMetadata); + AddMetadataMonitor(itemMetadata, isInFilter); if (isInFilter) { NotifyAdd(itemMetadata.Item); @@ -228,9 +228,9 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent // If we're sorting we can't predict how // the collection has changed on an add so we // resort to a reset notification. - if (this.sort != null) + if (sort != null) { - this.NotifyReset(); + NotifyReset(); } break; @@ -238,19 +238,19 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent case NotifyCollectionChangedAction.Remove: foreach (ItemMetadata itemMetadata in e.OldItems) { - this.RemoveMetadataMonitor(itemMetadata); - if (this.filter(itemMetadata)) + RemoveMetadataMonitor(itemMetadata); + if (filter(itemMetadata)) { - this.RemoveFromFilteredList(itemMetadata.Item); + RemoveFromFilteredList(itemMetadata.Item); } } break; default: - this.ResetAllMonitors(); - this.UpdateFilteredItemsList(); - this.NotifyReset(); + ResetAllMonitors(); + UpdateFilteredItemsList(); + NotifyReset(); break; } @@ -258,21 +258,21 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent private void NotifyAdd(object item) { - int newIndex = this.filteredItems.IndexOf(item); - this.NotifyAdd(new[] { item }, newIndex); + int newIndex = filteredItems.IndexOf(item); + NotifyAdd(new[] { item }, newIndex); } private void RemoveFromFilteredList(object item) { - int index = this.filteredItems.IndexOf(item); - this.UpdateFilteredItemsList(); - this.NotifyRemove(new[] { item }, index); + int index = filteredItems.IndexOf(item); + UpdateFilteredItemsList(); + NotifyRemove(new[] { item }, index); } private void UpdateFilteredItemsList() { - this.filteredItems = this.subjectCollection.Where(i => this.filter(i)).Select(i => i.Item) - .OrderBy(o => o, new RegionItemComparer(this.SortComparison)).ToList(); + filteredItems = subjectCollection.Where(i => filter(i)).Select(i => i.Item) + .OrderBy(o => o, new RegionItemComparer(SortComparison)).ToList(); } private class MonitorInfo @@ -291,12 +291,12 @@ public RegionItemComparer(Comparison comparer) public override int Compare(object x, object y) { - if (this.comparer == null) + if (comparer == null) { return 0; } - return this.comparer(x, y); + return comparer(x, y); } } diff --git a/src/Prism.Avalonia/PrismApplicationBase.cs b/src/Prism.Avalonia/PrismApplicationBase.cs index 0130649..76856a7 100644 --- a/src/Prism.Avalonia/PrismApplicationBase.cs +++ b/src/Prism.Avalonia/PrismApplicationBase.cs @@ -5,7 +5,7 @@ using Prism.Common; using Prism.Ioc; using Prism.Modularity; -using Prism.Regions; +using Prism.Navigation.Regions; namespace Prism { diff --git a/src/Prism.Avalonia/PrismBootstrapperBase.cs b/src/Prism.Avalonia/PrismBootstrapperBase.cs index 47ae6f7..2503d26 100644 --- a/src/Prism.Avalonia/PrismBootstrapperBase.cs +++ b/src/Prism.Avalonia/PrismBootstrapperBase.cs @@ -4,7 +4,7 @@ using Prism.Common; using Prism.Ioc; using Prism.Modularity; -using Prism.Regions; +using Prism.Navigation.Regions; namespace Prism { diff --git a/src/Prism.Avalonia/PrismInitializationExtensions.cs b/src/Prism.Avalonia/PrismInitializationExtensions.cs index f93d3e7..dc17adb 100644 --- a/src/Prism.Avalonia/PrismInitializationExtensions.cs +++ b/src/Prism.Avalonia/PrismInitializationExtensions.cs @@ -3,9 +3,9 @@ using Prism.Ioc; using Prism.Modularity; using Prism.Mvvm; -using Prism.Regions; -using Prism.Regions.Behaviors; using Prism.Dialogs; +using Prism.Navigation.Regions; +using Prism.Navigation.Regions.Behaviors; namespace Prism { diff --git a/src/Prism.Avalonia/Regions/IConfirmNavigationRequest.cs b/src/Prism.Avalonia/Regions/IConfirmNavigationRequest.cs deleted file mode 100644 index dd2f6af..0000000 --- a/src/Prism.Avalonia/Regions/IConfirmNavigationRequest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace Prism.Regions -{ - /// - /// Provides a way for objects involved in navigation to determine if a navigation request should continue. - /// - public interface IConfirmNavigationRequest : INavigationAware - { - /// - /// Determines whether this instance accepts being navigated away from. - /// - /// The navigation context. - /// The callback to indicate when navigation can proceed. - /// - /// Implementors of this method do not need to invoke the callback before this method is completed, - /// but they must ensure the callback is eventually invoked. - /// - void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback); - } -} diff --git a/src/Prism.Avalonia/Regions/IRegion.cs b/src/Prism.Avalonia/Regions/IRegion.cs deleted file mode 100644 index 5c47c06..0000000 --- a/src/Prism.Avalonia/Regions/IRegion.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.ComponentModel; -using Avalonia; - -namespace Prism.Regions -{ - /// - /// Defines a model that can be used to compose views. - /// - public interface IRegion : INavigateAsync, INotifyPropertyChanged - { - /// - /// Gets a readonly view of the collection of views in the region. - /// - /// An of all the added views. - IViewsCollection Views { get; } - - /// - /// Gets a readonly view of the collection of all the active views in the region. - /// - /// An of all the active views. - IViewsCollection ActiveViews { get; } - - /// - /// Gets or sets a context for the region. This value can be used by the user to share context with the views. - /// - /// The context value to be shared. - object Context { get; set; } - - /// - /// Gets the name of the region that uniquely identifies the region within a . - /// - /// The name of the region. - string Name { get; set; } - - /// - /// Gets or sets the comparison used to sort the views. - /// - /// The comparison to use. - Comparison SortComparison { get; set; } - - ///Adds a new view to the region. - /// - /// Adds a new view to the region. - /// - /// The view to add. - /// The that is set on the view if it is a . It will be the current region manager when using this overload. - IRegionManager Add(object view); - - /// - /// Adds a new view to the region. - /// - /// The view to add. - /// The name of the view. This can be used to retrieve it later by calling . - /// The that is set on the view if it is a . It will be the current region manager when using this overload. - IRegionManager Add(object view, string viewName); - - /// - /// Adds a new view to the region. - /// - /// The view to add. - /// The name of the view. This can be used to retrieve it later by calling . - /// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region. - /// The that is set on the view if it is a . - IRegionManager Add(object view, string viewName, bool createRegionManagerScope); - - /// - /// Removes the specified view from the region. - /// - /// The view to remove. - void Remove(object view); - - /// - /// Removes all views from the region. - /// - void RemoveAll(); - - /// - /// Marks the specified view as active. - /// - /// The view to activate. - void Activate(object view); - - /// - /// Marks the specified view as inactive. - /// - /// The view to deactivate. - void Deactivate(object view); - - /// - /// Returns the view instance that was added to the region using a specific name. - /// - /// The name used when adding the view to the region. - /// Returns the named view or if the view with does not exist in the current region. - object GetView(string viewName); - - /// - /// Gets or sets the that will be passed to the views when adding them to the region, unless the view is added by specifying createRegionManagerScope as . - /// - /// The where this is registered. - /// This is usually used by implementations of and should not be - /// used by the developer explicitly. - IRegionManager RegionManager { get; set; } - - /// - /// Gets the collection of s that can extend the behavior of regions. - /// - IRegionBehaviorCollection Behaviors { get; } - - /// - /// Gets or sets the navigation service. - /// - /// The navigation service. - IRegionNavigationService NavigationService { get; set; } - } -} diff --git a/src/Prism.Avalonia/Regions/RegionMemberLifetimeAttribute.cs b/src/Prism.Avalonia/Regions/RegionMemberLifetimeAttribute.cs deleted file mode 100644 index ad540d3..0000000 --- a/src/Prism.Avalonia/Regions/RegionMemberLifetimeAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Prism.Regions.Behaviors; - -namespace Prism.Regions -{ - /// - /// When is applied to class provides data - /// the can use to determine if the instance should - /// be removed when it is deactivated. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)] - public sealed class RegionMemberLifetimeAttribute : Attribute - { - /// - /// Instantiates an instance of - /// - public RegionMemberLifetimeAttribute() - { - KeepAlive = true; - } - - /// - /// Determines if the region member should be kept-alive - /// when deactivated. - /// - public bool KeepAlive { get; set; } - } -} diff --git a/src/Prism.Avalonia/Regions/SyncActiveStateAttribute.cs b/src/Prism.Avalonia/Regions/SyncActiveStateAttribute.cs deleted file mode 100644 index 8b0d844..0000000 --- a/src/Prism.Avalonia/Regions/SyncActiveStateAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Prism.Regions -{ - /// - /// Defines that a view is synchronized with its parent view's Active state. - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class SyncActiveStateAttribute : Attribute - { - } -} diff --git a/src/Prism.Avalonia/Regions/ViewSortHintAttribute.cs b/src/Prism.Avalonia/Regions/ViewSortHintAttribute.cs deleted file mode 100644 index f500236..0000000 --- a/src/Prism.Avalonia/Regions/ViewSortHintAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Prism.Regions -{ - /// - /// Provides a hint from a view to a region on how to sort the view. - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class ViewSortHintAttribute : Attribute - { - /// - /// Initializes a new instance of the class. - /// - /// The hint to use for sorting. - public ViewSortHintAttribute(string hint) - { - Hint = hint; - } - - /// - /// Gets the hint. - /// - /// The hint to use for sorting. - public string Hint { get; } - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs index 28ea44c..ab0a2d1 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs @@ -1,6 +1,6 @@ using Avalonia; +using Prism.Navigation.Regions.Behaviors; using Prism.Regions; -using Prism.Regions.Behaviors; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs index 86d0de4..00bebc8 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs index 465497d..ee326e6 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs index 029b88a..9c70515 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs @@ -1,5 +1,4 @@ using Avalonia; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehavior.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehavior.cs index 52c3aff..f80e5fc 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehavior.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehavior.cs @@ -1,5 +1,3 @@ -using Prism.Regions; - namespace Prism.Avalonia.Tests.Mocks { public class MockRegionBehavior : IRegionBehavior diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehaviorCollection.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehaviorCollection.cs index ddf7901..bd7803b 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehaviorCollection.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionBehaviorCollection.cs @@ -1,5 +1,4 @@ using System.Collections; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs index 725400f..7a68b6a 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs @@ -1,5 +1,4 @@ using System.Collections; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManagerAccessor.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManagerAccessor.cs index f349d06..9f2470e 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManagerAccessor.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManagerAccessor.cs @@ -1,5 +1,4 @@ using Avalonia; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockViewsCollection.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockViewsCollection.cs index 26036c9..eb3a4f8 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockViewsCollection.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockViewsCollection.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs index 14ebff3..d5ec0a9 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs @@ -9,10 +9,9 @@ using Prism.Events; using Prism.Ioc; using Prism.Modularity; -using Prism.Regions; -using Prism.Regions.Behaviors; using Prism.Dialogs; using Xunit; +using Prism.Navigation.Regions.Behaviors; namespace Prism.Avalonia.Tests { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs index 44ec2bc..94e528e 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs @@ -4,10 +4,9 @@ using Prism.Events; using Prism.Ioc; using Prism.Modularity; -using Prism.Regions; -using Prism.Regions.Behaviors; using Prism.Dialogs; using Xunit; +using Prism.Navigation.Regions.Behaviors; namespace Prism { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs index 2184c3a..1f91564 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs @@ -1,5 +1,4 @@ using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; using Prism.Regions.Behaviors; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs index 065253b..3e1950b 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs @@ -1,5 +1,4 @@ using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; using Prism.Regions.Behaviors; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs index 8444506..644ffe1 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs @@ -1,6 +1,5 @@ using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/DelayedRegionCreationBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/DelayedRegionCreationBehaviorFixture.cs index a294bf1..729b795 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/DelayedRegionCreationBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/DelayedRegionCreationBehaviorFixture.cs @@ -1,7 +1,6 @@ using Avalonia; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs index 8eb78b8..966c2e8 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs @@ -2,7 +2,6 @@ using Avalonia.Input; using Moq; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; using Prism.Regions.Behaviors; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs index 32af35a..83542c0 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs @@ -1,7 +1,6 @@ using System.Collections; using Avalonia.Controls; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; using Prism.Regions.Behaviors; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs index ff16a73..7d171d4 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs @@ -1,7 +1,7 @@ using Moq; using Prism.Avalonia.Tests.Mocks; +using Prism.Navigation.Regions.Behaviors; using Prism.Regions; -using Prism.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SyncRegionContextWithHostBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SyncRegionContextWithHostBehaviorFixture.cs index 13b8238..e15b27c 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SyncRegionContextWithHostBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SyncRegionContextWithHostBehaviorFixture.cs @@ -1,8 +1,7 @@ using Avalonia; using Prism.Avalonia.Tests.Mocks; using Prism.Common; -using Prism.Regions; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs index dec7d1d..2c5e5e1 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs @@ -2,7 +2,6 @@ using System.Linq; using Avalonia.Controls; using Avalonia.Data; -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs index 4c25e5c..f49124c 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs @@ -1,7 +1,6 @@ using Avalonia.Controls; using Moq; using Prism.Ioc; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs index aec79d3..3cdc102 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs @@ -1,6 +1,5 @@ using System; using Moq; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs index b1c1669..fbd4791 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs @@ -1,5 +1,4 @@ using System; -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorCollectionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorCollectionFixture.cs index 601244f..c6faeeb 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorCollectionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorCollectionFixture.cs @@ -1,4 +1,3 @@ -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFactoryFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFactoryFixture.cs index 0afb853..725855a 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFactoryFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFactoryFixture.cs @@ -1,4 +1,3 @@ -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Moq; using Prism.Ioc; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFixture.cs index 981518c..012cc48 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionBehaviorFixture.cs @@ -1,4 +1,3 @@ -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs index 22ef86f..1b347e9 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs @@ -3,7 +3,6 @@ using System.Linq; using Moq; using Prism.Ioc; -using Prism.Regions; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs index 7d96a3b..be471d6 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs @@ -4,7 +4,6 @@ using Moq; using Prism.Avalonia.Tests.Mocks; using Prism.Ioc; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs index 84622cb..ec54346 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs @@ -1,5 +1,4 @@ using Moq; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs index daccf0a..0d75d23 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs @@ -1,5 +1,4 @@ using Moq; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs index a68f1d8..829ab60 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs @@ -5,7 +5,6 @@ using Avalonia.Controls; using Moq; using Prism.Ioc; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs index 953fcbb..2391649 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs @@ -6,7 +6,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions From 1b89912db2d1b62796fd53b0c9ed47900e3b5495 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 18:33:54 -0400 Subject: [PATCH 15/41] Removed region classes that have migrated to Prism.Core library --- .../Navigation/Regions/IRegionAdapter.cs | 16 -- .../Navigation/Regions/IRegionBehavior.cs | 18 -- .../Regions/IRegionBehaviorCollection.cs | 32 ---- .../Regions/IRegionBehaviorFactory.cs | 36 ---- .../IRegionBehaviorFactoryExtensions.cs | 20 --- .../Navigation/Regions/IRegionCollection.cs | 48 ------ .../Navigation/Regions/IRegionManager.cs | 131 --------------- .../Regions/IRegionManagerExtensions.cs | 20 --- .../Regions/IRegionMemberLifetime.cs | 17 -- .../Regions/IRegionNavigationContentLoader.cs | 23 --- .../Regions/IRegionNavigationJournal.cs | 61 ------- .../Regions/IRegionNavigationJournalEntry.cs | 21 --- .../Regions/IRegionNavigationService.cs | 37 ---- .../Navigation/Regions/IRegionViewRegistry.cs | 41 ----- .../Navigation/Regions/IViewsCollection.cs | 18 -- .../Regions/NavigationAsyncExtensions.cs | 103 ------------ .../Navigation/Regions/NavigationContext.cs | 72 -------- .../Navigation/Regions/Region.cs | 18 +- .../Navigation/Regions/RegionBehavior.cs | 57 ------- .../Regions/RegionBehaviorCollection.cs | 92 ---------- .../Regions/RegionBehaviorFactory.cs | 114 ------------- .../Regions/RegionNavigationEventArgs.cs | 48 ------ .../RegionNavigationFailedEventArgs.cs | 65 ------- .../Regions/RegionNavigationJournal.cs | 159 ------------------ .../Regions/RegionNavigationJournalEntry.cs | 38 ----- .../Regions/UpdateRegionsException.cs | 38 ----- .../Regions/ViewRegisteredEventArgs.cs | 31 ---- .../Regions/ViewRegistrationException.cs | 43 ----- 28 files changed, 5 insertions(+), 1412 deletions(-) delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs deleted file mode 100644 index 455b186..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionAdapter.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Defines an interfaces to adapt an object and bind it to a new . - /// - public interface IRegionAdapter - { - /// - /// Adapts an object and binds it to a new . - /// - /// The object to adapt. - /// The name of the region to be created. - /// The new instance of that the is bound to. - IRegion Initialize(object regionTarget, string regionName); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs deleted file mode 100644 index efd0af3..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionBehavior.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Interface for allowing extensible behavior on regions. - /// - public interface IRegionBehavior - { - /// - /// The region that this behavior is extending. - /// - IRegion Region { get; set; } - - /// - /// Attaches the behavior to the specified region. - /// - void Attach(); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs deleted file mode 100644 index a074929..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorCollection.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines the interface for a collection of classes on a Region. - /// - public interface IRegionBehaviorCollection : IEnumerable> - { - /// - /// Adds a to the collection, using the specified key as an indexer. - /// - /// - /// The key that specifies the type of that's added. - /// - /// The to add. - void Add(string key, IRegionBehavior regionBehavior); - - /// - /// Checks if a with the specified key is already present. - /// - /// The key to use to find a particular . - /// - bool ContainsKey(string key); - - /// - /// Gets the with the specified key. - /// - /// The registered - IRegionBehavior this[string key] { get; } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs deleted file mode 100644 index 75def9f..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactory.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Prism.Navigation.Regions -{ - /// - /// Interface for RegionBehaviorFactories. This factory allows the registration of the default set of RegionBehaviors, that will - /// be added to the s of all s, unless overridden on a 'per-region' basis. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "It is more of a factory than a collection")] - public interface IRegionBehaviorFactory : IEnumerable - { - /// - /// Adds a particular type of RegionBehavior if it was not already registered. the string is used to check if the behavior is already present - /// - /// The behavior key that's used to find if a certain behavior is already added. - /// Type of the behavior to add. - void AddIfMissing(string behaviorKey, Type behaviorType); - - /// - /// Determines whether a behavior with the specified key already exists - /// - /// The behavior key. - /// - /// if a behavior with the specified key is present; otherwise, . - /// - bool ContainsKey(string behaviorKey); - - /// - /// Creates an instance of the BehaviorType that's registered using the specified key. - /// - /// The key that's used to register a behavior type. - /// The created behavior. - IRegionBehavior CreateFromKey(string key); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs deleted file mode 100644 index 7665565..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Extension methods for the IRegionBehaviorFactory. - /// - public static class IRegionBehaviorFactoryExtensions - { - /// - /// Adds a particular type of RegionBehavior if it was not already registered. the string is used to check if the behavior is already present - /// - /// Type of the behavior to add. - /// The IRegionBehaviorFactory instance - /// The behavior key that's used to find if a certain behavior is already added. - public static void AddIfMissing(this IRegionBehaviorFactory regionBehaviorFactory, string behaviorKey) where T : IRegionBehavior - { - var behaviorType = typeof(T); - regionBehaviorFactory.AddIfMissing(behaviorKey, behaviorType); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs deleted file mode 100644 index 628626c..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionCollection.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines a collection of uniquely identified by their Name. - /// - public interface IRegionCollection : IEnumerable, INotifyCollectionChanged - { - /// - /// Gets the IRegion with the name received as index. - /// - /// Name of the region to be retrieved. - /// The identified with the requested name. - IRegion this[string regionName] { get; } - - /// - /// Adds a to the collection. - /// - /// Region to be added to the collection. - void Add(IRegion region); - - /// - /// Removes a from the collection. - /// - /// Name of the region to be removed. - /// if the region was removed from the collection, otherwise . - bool Remove(string regionName); - - /// - /// Checks if the collection contains a with the name received as parameter. - /// - /// The name of the region to look for. - /// if the region is contained in the collection, otherwise . - bool ContainsRegionWithName(string regionName); - - /// - /// Adds a region to the with the name received as argument. - /// - /// The name to be given to the region. - /// The region to be added to the . - /// Thrown if is . - /// Thrown if and 's name do not match and the is not . - void Add(string regionName, IRegion region); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs deleted file mode 100644 index 4875ad9..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionManager.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines an interface to manage a set of regions and to attach regions to objects (typically controls). - /// - public interface IRegionManager - { - /// - /// Gets a collection of that identify each region by name. You can use this collection to add or remove regions to the current region manager. - /// - IRegionCollection Regions { get; } - - /// - /// Creates a new region manager. - /// - /// A new region manager that can be used as a different scope from the current region manager. - IRegionManager CreateRegionManager(); - - /// - /// Add a view to the Views collection of a Region. Note that the region must already exist in this . - /// - /// The name of the region to add a view to - /// The view to add to the views collection - /// The RegionManager, to easily add several views. - IRegionManager AddToRegion(string regionName, object view); - - /// - /// Add a view to the Views collection of a Region. Note that the region must already exist in this . - /// - /// The name of the region to add a view to - /// The view to add to the views collection - /// The RegionManager, to easily add several views. - IRegionManager AddToRegion(string regionName, string viewName); - - /// - /// Associate a view with a region, by registering a type. When the region gets displayed - /// this type will be resolved using the ServiceLocator into a concrete instance. The instance - /// will be added to the Views collection of the region - /// - /// The name of the region to associate the view with. - /// The name of the view to register with the . - /// The , for adding several views easily - IRegionManager RegisterViewWithRegion(string regionName, string viewName); - - /// - /// Associate a view with a region, by registering a type. When the region gets displayed - /// this type will be resolved using the ServiceLocator into a concrete instance. The instance - /// will be added to the Views collection of the region - /// - /// The name of the region to associate the view with. - /// The type of the view to register with the . - /// The , for adding several views easily - IRegionManager RegisterViewWithRegion(string regionName, Type viewType); - - /// - /// Associate a view with a region, using a delegate to resolve a concrete instance of the view. - /// When the region gets displayed, this delegate will be called and the result will be added to the - /// views collection of the region. - /// - /// The name of the region to associate the view with. - /// The delegate used to resolve a concrete instance of the view. - /// The , for adding several views easily - IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate); - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - /// The navigation callback. - void RequestNavigate(string regionName, Uri source, Action navigationCallback); - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - void RequestNavigate(string regionName, Uri source); - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - /// The navigation callback. - void RequestNavigate(string regionName, string source, Action navigationCallback); - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - void RequestNavigate(string regionName, string source); - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A Uri that represents the target where the region will navigate. - /// The navigation callback that will be executed after the navigation is completed. - /// An instance of NavigationParameters, which holds a collection of object parameters. - void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters); - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A string that represents the target where the region will navigate. - /// The navigation callback that will be executed after the navigation is completed. - /// An instance of NavigationParameters, which holds a collection of object parameters. - void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters); - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A Uri that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters); - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A string that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs deleted file mode 100644 index a311f46..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionManagerExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Common Extensions for the RegionManager - /// - public static class IRegionManagerExtensions - { - /// - /// Associate a view with a region, by registering a type. When the region get's displayed - /// this type will be resolved using the ServiceLocator into a concrete instance. The instance - /// will be added to the Views collection of the region - /// - /// The type of the view to register with the . - /// The current . - /// The name of the region to associate the view with. - /// The , for adding several views easily - public static IRegionManager RegisterViewWithRegion(this IRegionManager regionManager, string regionName) => - regionManager.RegisterViewWithRegion(regionName, typeof(T)); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs deleted file mode 100644 index 38c6a55..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionMemberLifetime.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Prism.Navigation.Regions.Behaviors; - -namespace Prism.Navigation.Regions -{ - /// - /// When implemented, allows an instance placed in a - /// that uses a to indicate - /// it should be removed when it transitions from an activated to deactivated state. - /// - public interface IRegionMemberLifetime - { - /// - /// Gets a value indicating whether this instance should be kept-alive upon deactivation. - /// - bool KeepAlive { get; } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs deleted file mode 100644 index a2553e5..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationContentLoader.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Identifies the view in a region that is the target of a navigation request. - /// - public interface IRegionNavigationContentLoader - { - /// - /// Gets the content to which the navigation request represented by applies. - /// - /// - /// If none of the items in the region match the target of the navigation request, a new item - /// will be created and added to the region. - /// - /// The region. - /// The context representing the navigation request. - /// The item to be the target of the navigation request. - /// when a new item cannot be created for the navigation request. - object LoadContent(IRegion region, NavigationContext navigationContext); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs deleted file mode 100644 index f7709e7..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournal.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Provides journaling of current, back, and forward navigation within regions. - /// - public interface IRegionNavigationJournal - { - /// - /// Gets a value that indicates whether there is at least one entry in the back navigation history. - /// - /// - /// true if the journal can go back; otherwise, false. - /// - bool CanGoBack { get; } - - /// - /// Gets a value that indicates whether there is at least one entry in the forward navigation history. - /// - /// - /// true if this instance can go forward; otherwise, false. - /// - bool CanGoForward { get; } - - /// - /// Gets the current navigation entry of the content that is currently displayed. - /// - /// The current entry. - IRegionNavigationJournalEntry CurrentEntry { get; } - - /// - /// Gets or sets the target that implements INavigateAsync. - /// - /// The INavigate implementation. - /// - /// This is set by the owner of this journal. - /// - INavigateAsync NavigationTarget { get; set; } - - /// - /// Navigates to the most recent entry in the back navigation history, or does nothing if no entry exists in back navigation. - /// - void GoBack(); - - /// - /// Navigates to the most recent entry in the forward navigation history, or does nothing if no entry exists in forward navigation. - /// - void GoForward(); - - /// - /// Records the navigation to the entry.. - /// - /// The entry to record. - /// Keep Navigation object in memory when OnNavigationFrom is called - void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory); - - /// - /// Clears the journal of current, back, and forward navigation histories. - /// - void Clear(); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs deleted file mode 100644 index 10c8766..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationJournalEntry.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// An entry in an IRegionNavigationJournal representing the URI navigated to. - /// - public interface IRegionNavigationJournalEntry - { - /// - /// Gets or sets the URI. - /// - /// The URI. - Uri Uri { get; set; } - - /// - /// Gets or sets the NavigationParameters instance. - /// - NavigationParameters Parameters { get; set; } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs deleted file mode 100644 index dff55aa..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionNavigationService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Provides navigation for regions. - /// - public interface IRegionNavigationService : INavigateAsync - { - /// - /// Gets or sets the region owning this service. - /// - /// A Region. - IRegion Region { get; set; } - - /// - /// Gets the journal. - /// - /// The journal. - IRegionNavigationJournal Journal { get; } - - /// - /// Raised when the region is about to be navigated to content. - /// - event EventHandler Navigating; - - /// - /// Raised when the region is navigated to content. - /// - event EventHandler Navigated; - - /// - /// Raised when a navigation request fails. - /// - event EventHandler NavigationFailed; - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs b/src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs deleted file mode 100644 index 8041afd..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IRegionViewRegistry.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines the interface for the registry of region's content. - /// - public interface IRegionViewRegistry - { - /// - /// Event triggered when a content is registered to a region name. - /// - /// - /// This event uses weak references to the event handler to prevent this service (typically a singleton) of keeping the - /// target element longer than expected. - /// - event EventHandler ContentRegistered; - - /// - /// Returns the contents associated with a region name. - /// - /// Region name for which contents are requested. - /// Collection of contents associated with the . - IEnumerable GetContents(string regionName); - - /// - /// Registers a content type with a region name. - /// - /// Region name to which the will be registered. - /// Content type to be registered for the . - void RegisterViewWithRegion(string regionName, Type viewType); - - /// - /// Registers a delegate that can be used to retrieve the content associated with a region name. - /// - /// Region name to which the will be registered. - /// Delegate used to retrieve the content associated with the . - void RegisterViewWithRegion(string regionName, Func getContentDelegate); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs b/src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs deleted file mode 100644 index d7974de..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IViewsCollection.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using System.Collections.Specialized; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines a view of a collection. - /// - public interface IViewsCollection : IEnumerable, INotifyCollectionChanged - { - /// - /// Determines whether the collection contains a specific value. - /// - /// The object to locate in the collection. - /// if is found in the collection; otherwise, . - bool Contains(object value); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs deleted file mode 100644 index 889dc62..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/NavigationAsyncExtensions.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Provides additional methods to the interface. - /// - public static class NavigationAsyncExtensions - { - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// The navigation target - public static void RequestNavigate(this INavigateAsync navigation, string target) - { - navigation.RequestNavigate(target, nr => { }); - } - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// The navigation target - /// The callback executed when the navigation request is completed. - public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback) - { - if (navigation == null) - throw new ArgumentNullException(nameof(navigation)); - - if (target == null) - throw new ArgumentNullException(nameof(target)); - - var targetUri = new Uri(target, UriKind.RelativeOrAbsolute); - - navigation.RequestNavigate(targetUri, navigationCallback); - } - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// The navigation target - public static void RequestNavigate(this INavigateAsync navigation, Uri target) - { - if (navigation == null) - throw new ArgumentNullException(nameof(navigation)); - - navigation.RequestNavigate(target, nr => { }); - } - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// The navigation target - /// The callback executed when the navigation request is completed. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback, NavigationParameters navigationParameters) - { - if (navigation == null) - throw new ArgumentNullException(nameof(navigation)); - - if (target == null) - throw new ArgumentNullException(nameof(target)); - - var targetUri = new Uri(target, UriKind.RelativeOrAbsolute); - - navigation.RequestNavigate(targetUri, navigationCallback, navigationParameters); - } - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// A Uri that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public static void RequestNavigate(this INavigateAsync navigation, Uri target, NavigationParameters navigationParameters) - { - if (navigation == null) - throw new ArgumentNullException(nameof(navigation)); - - navigation.RequestNavigate(target, nr => { }, navigationParameters); - } - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation object. - /// A string that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public static void RequestNavigate(this INavigateAsync navigation, string target, NavigationParameters navigationParameters) - { - if (navigation == null) - throw new ArgumentNullException(nameof(navigation)); - - if (target == null) - throw new ArgumentNullException(nameof(target)); - - navigation.RequestNavigate(new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, navigationParameters); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs deleted file mode 100644 index 93e3cd5..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/NavigationContext.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using Prism.Common; - -namespace Prism.Navigation.Regions -{ - /// - /// Encapsulates information about a navigation request. - /// - public class NavigationContext - { - /// - /// Initializes a new instance of the class for a region name and a - /// . - /// - /// The navigation service. - /// The Uri. - public NavigationContext(IRegionNavigationService navigationService, Uri uri) : this(navigationService, uri, null) - { - } - - /// - /// Initializes a new instance of the class for a region name and a - /// . - /// - /// The navigation service. - /// The navigation parameters. - /// The Uri. - public NavigationContext(IRegionNavigationService navigationService, Uri uri, NavigationParameters navigationParameters) - { - NavigationService = navigationService; - Uri = uri; - Parameters = uri != null ? UriParsingHelper.ParseQuery(uri) : null; - GetNavigationParameters(navigationParameters); - } - - /// - /// Gets the region navigation service. - /// - /// The navigation service. - public IRegionNavigationService NavigationService { get; private set; } - - /// - /// Gets the navigation URI. - /// - /// The navigation URI. - public Uri Uri { get; private set; } - - /// - /// Gets the extracted from the URI and the object parameters passed in navigation. - /// - /// The URI query. - public NavigationParameters Parameters { get; private set; } - - private void GetNavigationParameters(NavigationParameters navigationParameters) - { - if (Parameters == null || NavigationService == null || NavigationService.Region == null) - { - Parameters = new NavigationParameters(); - return; - } - - if (navigationParameters != null) - { - foreach (KeyValuePair navigationParameter in navigationParameters) - { - Parameters.Add(navigationParameter.Key, navigationParameter.Value); - } - } - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/Region.cs b/src/Prism.Avalonia/Navigation/Regions/Region.cs index a32a2f5..1bf0c3a 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Region.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Region.cs @@ -10,9 +10,7 @@ namespace Prism.Navigation.Regions { - /// - /// Implementation of that allows multiple active views. - /// + /// Implementation of that allows multiple active views. public class Region : IRegion { private ObservableCollection _itemMetadataCollection; @@ -35,19 +33,13 @@ public Region() _sort = DefaultSortComparison; } - /// - /// Occurs when a property value changes. - /// + /// Occurs when a property value changes. public event PropertyChangedEventHandler PropertyChanged; - /// - /// Gets the collection of s that can extend the behavior of regions. - /// - public IRegionBehaviorCollection Behaviors { get; private set; } + /// Gets the collection of s that can extend the behavior of regions. + public IRegionBehaviorCollection Behaviors { get; } - /// - /// Gets or sets a context for the region. This value can be used by the user to share context with the views. - /// + /// Gets or sets a context for the region. This value can be used by the user to share context with the views. /// The context value to be shared. public object Context { diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs deleted file mode 100644 index c6d5e56..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionBehavior.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Prism.Properties; - -namespace Prism.Navigation.Regions -{ - /// - /// Provides a base class for region's behaviors. - /// - public abstract class RegionBehavior : IRegionBehavior - { - private IRegion region; - - /// - /// Behavior's attached region. - /// - public IRegion Region - { - get - { - return region; - } - set - { - if (IsAttached) - { - throw new InvalidOperationException(Resources.RegionBehaviorRegionCannotBeSetAfterAttach); - } - - region = value; - } - } - - /// - /// Returns if the behavior is attached to a region, otherwise. - /// - public bool IsAttached { get; private set; } - - /// - /// Attaches the behavior to the region. - /// - public void Attach() - { - if (region == null) - { - throw new InvalidOperationException(Resources.RegionBehaviorAttachCannotBeCallWithNullRegion); - } - - IsAttached = true; - OnAttach(); - } - - /// - /// Override this method to perform the logic after the behavior has been attached. - /// - protected abstract void OnAttach(); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs deleted file mode 100644 index 20affda..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorCollection.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Prism.Navigation.Regions -{ - /// - /// A collection of instances, that are stored and retrieved by Key. - /// - public class RegionBehaviorCollection : IRegionBehaviorCollection - { - private readonly IRegion region; - private readonly Dictionary behaviors = new Dictionary(); - - /// - /// Initializes a new instance of the class and associates it with a region. - /// - /// The region to associate the behavior collection with. - public RegionBehaviorCollection(IRegion region) - { - this.region = region; - } - - /// - /// Gets the with the specified key. - /// - /// The RegionBehavior that's registered with the key. - public IRegionBehavior this[string key] - { - get { return behaviors[key]; } - } - - /// - /// Adds a to the collection, using the specified key as an indexer. - /// - /// The key that specifies the type of that's added. - /// The to add. - /// - /// Thrown is the parameter is Null, - /// or if the parameter is Null. - /// - /// Thrown if a behavior with the specified Key parameter already exists. - public void Add(string key, IRegionBehavior regionBehavior) - { - if (key == null) - throw new ArgumentNullException(nameof(key)); - - if (regionBehavior == null) - throw new ArgumentNullException(nameof(regionBehavior)); - - if (behaviors.ContainsKey(key)) - throw new ArgumentException("Could not add duplicate behavior with same key.", nameof(key)); - - behaviors.Add(key, regionBehavior); - regionBehavior.Region = region; - - regionBehavior.Attach(); - } - - /// - /// Checks if a with the specified key is already present. - /// - /// The key to use to find a particular . - /// - public bool ContainsKey(string key) - { - return behaviors.ContainsKey(key); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// A that can be used to iterate through the collection. - /// - public IEnumerator> GetEnumerator() - { - return behaviors.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return behaviors.GetEnumerator(); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs b/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs deleted file mode 100644 index 32bc09d..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionBehaviorFactory.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using Prism.Ioc; -using Prism.Properties; - -namespace Prism.Navigation.Regions -{ - /// - /// Defines a factory that allows the registration of the default set of , that will - /// be added to the of all s, unless overridden on a 'per-region' basis. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "It is more of a factory than a collection")] - public class RegionBehaviorFactory : IRegionBehaviorFactory - { - private readonly IContainerProvider _container; - private readonly Dictionary _registeredBehaviors = new Dictionary(); - - /// - /// Initializes a new instance of . - /// - /// used to create the instance of the behavior from its . - public RegionBehaviorFactory(IContainerExtension container) - { - _container = container; - } - - /// - /// Adds a particular type of RegionBehavior if it was not already registered. The string is used to check if the behavior is already present - /// - /// The behavior key that's used to find if a certain behavior is already added. - /// Type of the behavior to add. - public void AddIfMissing(string behaviorKey, Type behaviorType) - { - if (behaviorKey == null) - { - throw new ArgumentNullException(nameof(behaviorKey)); - } - - if (behaviorType == null) - { - throw new ArgumentNullException(nameof(behaviorType)); - } - - // Check if the type is a IRegionBehavior - if (!typeof(IRegionBehavior).IsAssignableFrom(behaviorType)) - { - throw new ArgumentException( - string.Format(Thread.CurrentThread.CurrentCulture, Resources.CanOnlyAddTypesThatInheritIFromRegionBehavior, behaviorType.Name), nameof(behaviorType)); - } - - // Only add the behaviorKey if it doesn't already exists. - if (_registeredBehaviors.ContainsKey(behaviorKey)) - { - return; - } - - _registeredBehaviors.Add(behaviorKey, behaviorType); - } - - /// - /// Creates an instance of the behavior that is registered using the specified key. - /// - /// The key that is used to register a behavior type. - /// A new instance of the behavior. - public IRegionBehavior CreateFromKey(string key) - { - if (!ContainsKey(key)) - { - throw new ArgumentException( - string.Format(Thread.CurrentThread.CurrentCulture, Resources.TypeWithKeyNotRegistered, key), nameof(key)); - } - - return (IRegionBehavior)_container.Resolve(_registeredBehaviors[key]); - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// A that can be used to iterate through the collection. - /// - /// 1 - public IEnumerator GetEnumerator() - { - return _registeredBehaviors.Keys.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - /// 2 - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - /// Determines whether a behavior with the specified key already exists. - /// - /// The behavior key. - /// - /// if a behavior with the specified key is present; otherwise, . - /// - public bool ContainsKey(string behaviorKey) - { - return _registeredBehaviors.ContainsKey(behaviorKey); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs deleted file mode 100644 index b52f236..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationEventArgs.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// EventArgs used with the Navigated event. - /// - public class RegionNavigationEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The navigation context. - public RegionNavigationEventArgs(NavigationContext navigationContext) - { - if (navigationContext == null) - throw new ArgumentNullException(nameof(navigationContext)); - - NavigationContext = navigationContext; - } - - /// - /// Gets the navigation context. - /// - /// The navigation context. - public NavigationContext NavigationContext { get; private set; } - - /// - /// Gets the navigation URI - /// - /// The URI. - /// - /// This is a convenience accessor around NavigationContext.Uri. - /// - public Uri Uri - { - get - { - if (NavigationContext != null) - { - return NavigationContext.Uri; - } - - return null; - } - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs deleted file mode 100644 index 364159c..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationFailedEventArgs.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// EventArgs used with the NavigationFailed event. - /// - public class RegionNavigationFailedEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The navigation context. - public RegionNavigationFailedEventArgs(NavigationContext navigationContext) - { - if (navigationContext == null) - throw new ArgumentNullException(nameof(navigationContext)); - - NavigationContext = navigationContext; - } - - /// - /// Initializes a new instance of the class. - /// - /// The navigation context. - /// The error. - public RegionNavigationFailedEventArgs(NavigationContext navigationContext, Exception error) - : this(navigationContext) - { - Error = error; - } - - /// - /// Gets the navigation context. - /// - /// The navigation context. - public NavigationContext NavigationContext { get; private set; } - - /// - /// Gets the error. - /// - /// The , or if the failure was not caused by an exception. - public Exception Error { get; private set; } - - /// - /// Gets the navigation URI - /// - /// The URI. - /// - /// This is a convenience accessor around NavigationContext.Uri. - /// - public Uri Uri - { - get - { - if (NavigationContext != null) - { - return NavigationContext.Uri; - } - - return null; - } - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs deleted file mode 100644 index b092083..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournal.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Prism.Navigation.Regions -{ - /// - /// Provides journaling of current, back, and forward navigation within regions. - /// - public class RegionNavigationJournal : IRegionNavigationJournal - { - private Stack backStack = new Stack(); - private Stack forwardStack = new Stack(); - - private bool isNavigatingInternal; - - /// - /// Gets or sets the target that implements INavigate. - /// - /// The INavigate implementation. - /// - /// This is set by the owner of this journal. - /// - public INavigateAsync NavigationTarget { get; set; } - - /// - /// Gets the current navigation entry of the content that is currently displayed. - /// - /// The current entry. - public IRegionNavigationJournalEntry CurrentEntry { get; private set; } - - /// - /// Gets a value that indicates whether there is at least one entry in the back navigation history. - /// - /// true if the journal can go back; otherwise, false. - public bool CanGoBack - { - get - { - return backStack.Count > 0; - } - } - - /// - /// Gets a value that indicates whether there is at least one entry in the forward navigation history. - /// - /// - /// true if this instance can go forward; otherwise, false. - /// - public bool CanGoForward - { - get - { - return forwardStack.Count > 0; - } - } - - /// - /// Navigates to the most recent entry in the back navigation history, or does nothing if no entry exists in back navigation. - /// - public void GoBack() - { - if (CanGoBack) - { - IRegionNavigationJournalEntry entry = backStack.Peek(); - InternalNavigate( - entry, - result => - { - if (result) - { - if (CurrentEntry != null) - { - forwardStack.Push(CurrentEntry); - } - - backStack.Pop(); - CurrentEntry = entry; - } - }); - } - } - - /// - /// Navigates to the most recent entry in the forward navigation history, or does nothing if no entry exists in forward navigation. - /// - public void GoForward() - { - if (CanGoForward) - { - IRegionNavigationJournalEntry entry = forwardStack.Peek(); - InternalNavigate( - entry, - result => - { - if (result) - { - if (CurrentEntry != null) - { - backStack.Push(CurrentEntry); - } - - forwardStack.Pop(); - CurrentEntry = entry; - } - }); - } - } - - /// - /// Records the navigation to the entry.. - /// - /// The entry to record. - /// Determine if the view is added to the back stack or excluded from the history. - public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory) - { - if (!isNavigatingInternal) - { - if (CurrentEntry != null) - { - backStack.Push(CurrentEntry); - } - - forwardStack.Clear(); - - if (persistInHistory) - CurrentEntry = entry; - else - CurrentEntry = null; - } - } - - /// - /// Clears the journal of current, back, and forward navigation histories. - /// - public void Clear() - { - CurrentEntry = null; - backStack.Clear(); - forwardStack.Clear(); - } - - private void InternalNavigate(IRegionNavigationJournalEntry entry, Action callback) - { - isNavigatingInternal = true; - NavigationTarget.RequestNavigate( - entry.Uri, - nr => - { - isNavigatingInternal = false; - - if (nr.Result.HasValue) - { - callback(nr.Result.Value); - } - }, - entry.Parameters); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs deleted file mode 100644 index 81e23c3..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationJournalEntry.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Globalization; - -namespace Prism.Navigation.Regions -{ - /// - /// An entry in an IRegionNavigationJournal representing the URI navigated to. - /// - public class RegionNavigationJournalEntry : IRegionNavigationJournalEntry - { - /// - /// Gets or sets the URI. - /// - /// The URI. - public Uri Uri { get; set; } - - /// - /// Gets or sets the NavigationParameters instance. - /// - public NavigationParameters Parameters { get; set; } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - if (Uri != null) - { - return string.Format(CultureInfo.CurrentCulture, "RegionNavigationJournalEntry:'{0}'", Uri.ToString()); - } - - return base.ToString(); - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs b/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs deleted file mode 100644 index 267c451..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; - -namespace Prism.Regions -{ - /// - /// Represents errors that occured during the regions' update. - /// - public partial class UpdateRegionsException : Exception - { - /// - /// Initializes a new instance of the - /// - public UpdateRegionsException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public UpdateRegionsException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference - /// to the inner exception that is the cause of this exception. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified. - public UpdateRegionsException(string message, Exception inner) - : base(message, inner) - { - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs deleted file mode 100644 index e9a4a40..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/ViewRegisteredEventArgs.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Argument class used by the event when a new content is registered. - /// - public class ViewRegisteredEventArgs : EventArgs - { - /// - /// Initializes the ViewRegisteredEventArgs class. - /// - /// The region name to which the content was registered. - /// The content which was registered. - public ViewRegisteredEventArgs(string regionName, Func getViewDelegate) - { - GetView = getViewDelegate; - RegionName = regionName; - } - - /// - /// Gets the region name to which the content was registered. - /// - public string RegionName { get; private set; } - - /// - /// Gets the content which was registered. - /// - public Func GetView { get; private set; } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs deleted file mode 100644 index 9d38fcd..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Prism.Navigation.Regions; - -namespace Prism.Regions -{ - /// - /// Exception that's thrown when something goes wrong while Registering a View with a region name in the class. - /// - public partial class ViewRegistrationException : Exception - { - // TODO: Find updated links as these are dead... - // - // For guidelines regarding the creation of new exception types, see - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp - // and - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp - // - - /// - /// Initializes a new instance of the class. - /// - public ViewRegistrationException() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The exception message. - public ViewRegistrationException(string message) : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The exception message. - /// The inner exception. - public ViewRegistrationException(string message, Exception inner) : base(message, inner) - { - } - } -} From 9593cb52eff7ce9377238e918e564240e90ac57b Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 18:39:04 -0400 Subject: [PATCH 16/41] Updated Prism.DryIoc.Avalonia PrismApplication and PrismBootstrapper --- src/Prism.DryIoc.Avalonia/PrismApplication.cs | 4 +++- src/Prism.DryIoc.Avalonia/PrismBootstrapper.cs | 15 +++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Prism.DryIoc.Avalonia/PrismApplication.cs b/src/Prism.DryIoc.Avalonia/PrismApplication.cs index 02bf746..953ae77 100644 --- a/src/Prism.DryIoc.Avalonia/PrismApplication.cs +++ b/src/Prism.DryIoc.Avalonia/PrismApplication.cs @@ -1,6 +1,8 @@ using System; using DryIoc; +using Prism.Container.DryIoc; using Prism.Ioc; +using ExceptionExtensions = System.ExceptionExtensions; namespace Prism.DryIoc { @@ -21,7 +23,7 @@ public abstract class PrismApplication : PrismApplicationBase /// A new . protected override IContainerExtension CreateContainerExtension() { - return new DryIocContainerExtension(new Container(CreateContainerRules())); + return new DryIocContainerExtension(CreateContainerRules()); } /// diff --git a/src/Prism.DryIoc.Avalonia/PrismBootstrapper.cs b/src/Prism.DryIoc.Avalonia/PrismBootstrapper.cs index 19d5a52..e9d0b02 100644 --- a/src/Prism.DryIoc.Avalonia/PrismBootstrapper.cs +++ b/src/Prism.DryIoc.Avalonia/PrismBootstrapper.cs @@ -1,27 +1,22 @@ using System; using DryIoc; +using Prism.Container.DryIoc; using Prism.Ioc; namespace Prism.DryIoc { - /// - /// Base bootstrapper class that uses as it's container. - /// + /// Base bootstrapper class that uses as it's container. public abstract class PrismBootstrapper : PrismBootstrapperBase { - /// - /// Create to alter behavior of - /// + /// Create to alter behavior of /// An instance of protected virtual Rules CreateContainerRules() => DryIocContainerExtension.DefaultRules; - /// - /// Create a new used by Prism. - /// + /// Create a new used by Prism. /// A new . protected override IContainerExtension CreateContainerExtension() { - return new DryIocContainerExtension(new Container(CreateContainerRules())); + return new DryIocContainerExtension(CreateContainerRules()); } /// From 7738503fcf555537bea263455f1f3405b201b102 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 21:31:19 -0400 Subject: [PATCH 17/41] Removed Region classes that migrated to Prism.Core. Updated to use IRegionAware instead of INavigationAware --- src/Prism.Avalonia/Common/UriParsingHelper.cs | 54 -------------- .../Extensions/AvaloniaObjectExtensions.cs | 17 +++++ .../Extensions/DependencyObjectExtensions.cs | 29 -------- .../Regions/NavigationParameters.cs | 24 ------ .../Navigation/Regions/NavigationResult.cs | 51 ------------- .../Navigation/Regions/Region.cs | 58 ++++++--------- .../Navigation/Regions/RegionManager.cs | 74 +------------------ .../Regions/RegionNavigationContentLoader.cs | 8 +- .../Regions/RegionNavigationService.cs | 40 +++------- 9 files changed, 59 insertions(+), 296 deletions(-) delete mode 100644 src/Prism.Avalonia/Common/UriParsingHelper.cs create mode 100644 src/Prism.Avalonia/Extensions/AvaloniaObjectExtensions.cs delete mode 100644 src/Prism.Avalonia/Extensions/DependencyObjectExtensions.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs diff --git a/src/Prism.Avalonia/Common/UriParsingHelper.cs b/src/Prism.Avalonia/Common/UriParsingHelper.cs deleted file mode 100644 index c824741..0000000 --- a/src/Prism.Avalonia/Common/UriParsingHelper.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using Prism.Navigation.Regions; - -namespace Prism.Common -{ - /// - /// Helper class for parsing instances. - /// - public static class UriParsingHelper - { - /// - /// Gets the query part of . - /// - /// The Uri. - public static string GetQuery(Uri uri) - { - return EnsureAbsolute(uri).Query; - } - - /// - /// Gets the AbsolutePath part of . - /// - /// The Uri. - public static string GetAbsolutePath(Uri uri) - { - return EnsureAbsolute(uri).AbsolutePath; - } - - /// - /// Parses the query of into a dictionary. - /// - /// The URI. - public static NavigationParameters ParseQuery(Uri uri) - { - var query = GetQuery(uri); - - return new NavigationParameters(query); - } - - private static Uri EnsureAbsolute(Uri uri) - { - if (uri.IsAbsoluteUri) - { - return uri; - } - - if ((uri != null) && !uri.OriginalString.StartsWith("/", StringComparison.Ordinal)) - { - return new Uri("http://localhost/" + uri, UriKind.Absolute); - } - return new Uri("http://localhost" + uri, UriKind.Absolute); - } - } -} diff --git a/src/Prism.Avalonia/Extensions/AvaloniaObjectExtensions.cs b/src/Prism.Avalonia/Extensions/AvaloniaObjectExtensions.cs new file mode 100644 index 0000000..5120719 --- /dev/null +++ b/src/Prism.Avalonia/Extensions/AvaloniaObjectExtensions.cs @@ -0,0 +1,17 @@ +using Avalonia; +using Avalonia.Controls; + +namespace Prism +{ + /// AvaloniaObject Extensions. + /// Equivalent to WPF's DependencyObject + internal static partial class AvaloniaObjectExtensions + { + /// Determines if a has a binding set. + /// The to use to search for the property. + /// The property to search. + /// true if there is an active binding, otherwise false. + public static bool HasBinding(this Control instance, AvaloniaProperty property) + => instance.GetBindingObservable(property) != null; + } +} diff --git a/src/Prism.Avalonia/Extensions/DependencyObjectExtensions.cs b/src/Prism.Avalonia/Extensions/DependencyObjectExtensions.cs deleted file mode 100644 index 4b9c973..0000000 --- a/src/Prism.Avalonia/Extensions/DependencyObjectExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Avalonia; -using Avalonia.Controls; - -namespace Prism -{ - internal static partial class AvaloniaObjectExtensions - { - /// - /// Determines if a has a binding set - /// - /// The to use to search for the property - /// The property to search - /// true if there is an active binding, otherwise false - public static bool HasBinding(this Control instance, AvaloniaProperty property) - => instance.GetBindingObservable(property) != null; - } - - internal static partial class DependencyObjectExtensions - { - /// - /// Determines if a has a binding set - /// - /// The to use to search for the property - /// The property to search - /// true if there is an active binding, otherwise false - public static bool HasBinding(this Control instance, AvaloniaProperty property) - => instance.GetBindingObservable(property) != null; - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs deleted file mode 100644 index 655c521..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/NavigationParameters.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Prism.Common; - -namespace Prism.Navigation.Regions -{ - /// - /// Represents Navigation parameters. - /// - /// - /// This class can be used to to pass object parameters during Navigation. - /// - public class NavigationParameters : ParametersBase - { - /// - /// Initializes a new instance of the class. - /// - public NavigationParameters() : base() { } - - /// - /// Constructs a list of parameters - /// - /// Query string to be parsed - public NavigationParameters(string query) : base(query) { } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs b/src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs deleted file mode 100644 index 2b84e6d..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/NavigationResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Represents the result of navigating to a URI. - /// - public class NavigationResult - { - /// - /// Initializes a new instance of the class. - /// - /// The context. - /// The result. - public NavigationResult(NavigationContext context, bool? result) - { - Context = context; - Result = result; - } - - /// - /// Initializes a new instance of the class. - /// - /// The context. - /// The error. - public NavigationResult(NavigationContext context, Exception error) - { - Context = context; - Error = error; - Result = false; - } - - /// - /// Gets the result. - /// - /// The result. - public bool? Result { get; private set; } - - /// - /// Gets an exception that occurred while navigating. - /// - /// The exception. - public Exception Error { get; private set; } - - /// - /// Gets the navigation context. - /// - /// The navigation context. - public NavigationContext Context { get; private set; } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/Region.cs b/src/Prism.Avalonia/Navigation/Regions/Region.cs index 1bf0c3a..7f68c5a 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Region.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Region.cs @@ -199,15 +199,21 @@ protected virtual ObservableCollection ItemMetadataCollection { get { - if (_itemMetadataCollection == null) - { - _itemMetadataCollection = new ObservableCollection(); - } - + _itemMetadataCollection ??= new ObservableCollection(); return _itemMetadataCollection; } } + /// Adds a new view to the region. + /// Adds a new view to the region. + /// The view to add. + /// The that is set on the view if it is a . It will be the current region manager when using this overload. + public IRegionManager Add(string viewName) + { + var view = ContainerLocator.Container.Resolve(viewName); + return Add(view, viewName, false); + } + /// Adds a new view to the region. /// /// Adds a new view to the region. @@ -219,9 +225,7 @@ public IRegionManager Add(object view) return Add(view, null, false); } - /// - /// Adds a new view to the region. - /// + /// Adds a new view to the region. /// The view to add. /// The name of the view. This can be used to retrieve it later by calling . /// The that is set on the view if it is a . It will be the current region manager when using this overload. @@ -235,9 +239,7 @@ public IRegionManager Add(object view, string viewName) return Add(view, viewName, false); } - /// - /// Adds a new view to the region. - /// + /// Adds a new view to the region. /// The view to add. /// The name of the view. This can be used to retrieve it later by calling . /// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region. @@ -249,9 +251,7 @@ public virtual IRegionManager Add(object view, string viewName, bool createRegio return manager; } - /// - /// Removes the specified view from the region. - /// + /// Removes the specified view from the region. /// The view to remove. public virtual void Remove(object view) { @@ -265,9 +265,7 @@ public virtual void Remove(object view) } } - /// - /// Removes all views from the region. - /// + /// Removes all views from the region. public void RemoveAll() { foreach (var view in Views) @@ -276,9 +274,7 @@ public void RemoveAll() } } - /// - /// Marks the specified view as active. - /// + /// Marks the specified view as active. /// The view to activate. public virtual void Activate(object view) { @@ -290,9 +286,7 @@ public virtual void Activate(object view) } } - /// - /// Marks the specified view as inactive. - /// + /// Marks the specified view as inactive. /// The view to deactivate. public virtual void Deactivate(object view) { @@ -304,9 +298,7 @@ public virtual void Deactivate(object view) } } - /// - /// Returns the view instance that was added to the region using a specific name. - /// + /// Returns the view instance that was added to the region using a specific name. /// The name used when adding the view to the region. /// Returns the named view or if the view with does not exist in the current region. public virtual object GetView(string viewName) @@ -326,9 +318,7 @@ public virtual object GetView(string viewName) return null; } - /// - /// Initiates navigation to the specified target. - /// + /// Initiates navigation to the specified target. /// The target. /// A callback to execute when the navigation request is completed. public void RequestNavigate(Uri target, Action navigationCallback) @@ -336,13 +326,11 @@ public void RequestNavigate(Uri target, Action navigationCallb RequestNavigate(target, navigationCallback, null); } - /// - /// Initiates navigation to the specified target. - /// + /// Initiates navigation to the specified target. /// The target. /// A callback to execute when the navigation request is completed. /// The navigation parameters specific to the navigation request. - public void RequestNavigate(Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) { NavigationService.RequestNavigate(target, navigationCallback, navigationParameters); } @@ -354,7 +342,7 @@ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionM throw new InvalidOperationException(Resources.RegionViewExistsException); } - ItemMetadata itemMetadata = new ItemMetadata(view); + var itemMetadata = new ItemMetadata(view); if (!string.IsNullOrEmpty(viewName)) { if (ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null) @@ -388,7 +376,7 @@ private ItemMetadata GetItemMetadataOrThrow(object view) private void OnPropertyChanged(string propertyName) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } /// diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs index af50d29..652b38e 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -342,7 +342,7 @@ public IRegionManager RegisterViewWithRegion(string regionName, string targetNam /// The name of the region to associate the view with. /// The delegate used to resolve a concrete instance of the view. /// The , for adding several views easily - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { var regionViewRegistry = ContainerLocator.Container.Resolve(); @@ -372,40 +372,6 @@ public void RequestNavigate(string regionName, Uri source, Action - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - public void RequestNavigate(string regionName, Uri source) - { - RequestNavigate(regionName, source, nr => { }); - } - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - /// The navigation callback. - public void RequestNavigate(string regionName, string source, Action navigationCallback) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - RequestNavigate(regionName, new Uri(source, UriKind.RelativeOrAbsolute), navigationCallback); - } - - /// - /// Navigates the specified region manager. - /// - /// The name of the region to call Navigate on. - /// The URI of the content to display. - public void RequestNavigate(string regionName, string source) - { - RequestNavigate(regionName, source, nr => { }); - } - /// /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters. /// @@ -413,7 +379,7 @@ public void RequestNavigate(string regionName, string source) /// A Uri that represents the target where the region will navigate. /// The navigation callback that will be executed after the navigation is completed. /// An instance of NavigationParameters, which holds a collection of object parameters. - public void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters) { if (navigationCallback == null) throw new ArgumentNullException(nameof(navigationCallback)); @@ -428,40 +394,6 @@ public void RequestNavigate(string regionName, Uri target, Action - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A string that represents the target where the region will navigate. - /// The navigation callback that will be executed after the navigation is completed. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters) - { - RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), navigationCallback, navigationParameters); - } - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A Uri that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters) - { - RequestNavigate(regionName, target, nr => { }, navigationParameters); - } - - /// - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing an instance of NavigationParameters, which holds a collection of object parameters. - /// - /// The name of the region where the navigation will occur. - /// A string that represents the target where the region will navigate. - /// An instance of NavigationParameters, which holds a collection of object parameters. - public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters) - { - RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, navigationParameters); - } - /// /// Provides a new item for the region based on the supplied candidate target contract name. /// diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs index 885fbea..2d7f6dc 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationContentLoader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -56,7 +56,7 @@ public object LoadContent(IRegion region, NavigationContext navigationContext) candidates.Where( v => { - if (v is INavigationAware navigationAware && !navigationAware.IsNavigationTarget(navigationContext)) + if (v is IRegionAware navigationAware && !navigationAware.IsNavigationTarget(navigationContext)) { return false; } @@ -66,7 +66,7 @@ public object LoadContent(IRegion region, NavigationContext navigationContext) return true; } - navigationAware = control.DataContext as INavigationAware; + navigationAware = control.DataContext as IRegionAware; return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext); }); @@ -169,7 +169,7 @@ protected virtual IEnumerable GetCandidatesFromRegion(IRegion region, st private IEnumerable GetCandidatesFromRegionViews(IRegion region, string candidateNavigationContract) { - return region.Views.Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract)); + return region.Views.Where(v => v is not null && ViewIsMatch(v.GetType(), candidateNavigationContract)); } private static bool ViewIsMatch(Type viewType, string navigationSegment) diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs index 275a084..7ca44c9 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionNavigationService.cs @@ -9,9 +9,7 @@ namespace Prism.Navigation.Regions { - /// - /// Provides navigation for regions. - /// + /// Provides navigation for regions. public class RegionNavigationService : IRegionNavigationService { private readonly IContainerProvider _container; @@ -32,21 +30,15 @@ public RegionNavigationService(IContainerExtension container, IRegionNavigationC Journal.NavigationTarget = this; } - /// - /// Gets or sets the region. - /// + /// Gets or sets the region. /// The region. public IRegion Region { get; set; } - /// - /// Gets the journal. - /// + /// Gets the journal. /// The journal. public IRegionNavigationJournal Journal { get; private set; } - /// - /// Raised when the region is about to be navigated to content. - /// + /// Raised when the region is about to be navigated to content. public event EventHandler Navigating; private void RaiseNavigating(NavigationContext navigationContext) @@ -54,9 +46,7 @@ private void RaiseNavigating(NavigationContext navigationContext) Navigating?.Invoke(this, new RegionNavigationEventArgs(navigationContext)); } - /// - /// Raised when the region is navigated to content. - /// + /// Raised when the region is navigated to content. public event EventHandler Navigated; private void RaiseNavigated(NavigationContext navigationContext) @@ -64,9 +54,7 @@ private void RaiseNavigated(NavigationContext navigationContext) Navigated?.Invoke(this, new RegionNavigationEventArgs(navigationContext)); } - /// - /// Raised when a navigation request fails. - /// + /// Raised when a navigation request fails. public event EventHandler NavigationFailed; private void RaiseNavigationFailed(NavigationContext navigationContext, Exception error) @@ -74,9 +62,7 @@ private void RaiseNavigationFailed(NavigationContext navigationContext, Exceptio NavigationFailed?.Invoke(this, new RegionNavigationFailedEventArgs(navigationContext, error)); } - /// - /// Initiates navigation to the specified target. - /// + /// Initiates navigation to the specified target. /// The target. /// A callback to execute when the navigation request is completed. [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is marshalled to callback")] @@ -85,13 +71,11 @@ public void RequestNavigate(Uri target, Action navigationCallb RequestNavigate(target, navigationCallback, null); } - /// - /// Initiates navigation to the specified target. - /// + /// Initiates navigation to the specified target. /// The target. /// A callback to execute when the navigation request is completed. /// The navigation parameters specific to the navigation request. - public void RequestNavigate(Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) { if (navigationCallback == null) throw new ArgumentNullException(nameof(navigationCallback)); @@ -106,7 +90,7 @@ public void RequestNavigate(Uri target, Action navigationCallb } } - private void DoNavigate(Uri source, Action navigationCallback, NavigationParameters navigationParameters) + private void DoNavigate(Uri source, Action navigationCallback, INavigationParameters navigationParameters) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -234,7 +218,7 @@ private void ExecuteNavigation(NavigationContext navigationContext, object[] act Journal.RecordNavigation(journalEntry, persistInHistory); // The view can be informed of navigation - Action action = (n) => n.OnNavigatedTo(navigationContext); + Action action = (n) => n.OnNavigatedTo(navigationContext); MvvmHelpers.ViewAndViewModelAction(view, action); navigationCallback(new NavigationResult(navigationContext, true)); @@ -269,7 +253,7 @@ private static void NotifyActiveViewsNavigatingFrom(NavigationContext navigation InvokeOnNavigationAwareElements(activeViews, (n) => n.OnNavigatedFrom(navigationContext)); } - private static void InvokeOnNavigationAwareElements(IEnumerable items, Action invocation) + private static void InvokeOnNavigationAwareElements(IEnumerable items, Action invocation) { foreach (var item in items) { From 9914ab0fdf1b2f897ea2a05fcd5b391b485500b7 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 21:52:57 -0400 Subject: [PATCH 18/41] RegionViewRegistry to use IContainerProvider --- .../Navigation/Regions/RegionViewRegistry.cs | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs b/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs index df0ff28..142cf17 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionViewRegistry.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Reflection; @@ -15,67 +15,67 @@ namespace Prism.Navigation.Regions public class RegionViewRegistry : IRegionViewRegistry { private readonly IContainerProvider _container; - private readonly ListDictionary> _registeredContent = new ListDictionary>(); + private readonly ListDictionary> _registeredContent = new ListDictionary>(); private readonly WeakDelegatesManager _contentRegisteredListeners = new WeakDelegatesManager(); - /// - /// Creates a new instance of the class. - /// + /// Creates a new instance of the class. /// used to create the instance of the views from its . public RegionViewRegistry(IContainerExtension container) { _container = container; } - /// - /// Occurs whenever a new view is registered. - /// + /// Occurs whenever a new view is registered. public event EventHandler ContentRegistered { add => _contentRegisteredListeners.AddListener(value); remove => _contentRegisteredListeners.RemoveListener(value); } - /// - /// Returns the contents registered for a region. - /// + /// Returns the contents registered for a region. /// Name of the region which content is being requested. + /// The to use to get the View. /// Collection of contents registered for the region. - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { - List items = new List(); - foreach (Func getContentDelegate in _registeredContent[regionName]) + var items = new List(); + foreach (Func getContentDelegate in _registeredContent[regionName]) { - items.Add(getContentDelegate()); + items.Add(getContentDelegate(container)); } return items; } - /// - /// Registers a content type with a region name. - /// + /// Registers a content type with a region name. /// Region name to which the will be registered. /// Content type to be registered for the . public void RegisterViewWithRegion(string regionName, Type viewType) { - RegisterViewWithRegion(regionName, () => CreateInstance(viewType)); + RegisterViewWithRegion(regionName, _ => CreateInstance(viewType)); } - /// - /// Registers a delegate that can be used to retrieve the content associated with a region name. - /// + /// Registers a delegate that can be used to retrieve the content associated with a region name. /// Region name to which the will be registered. /// Delegate used to retrieve the content associated with the . - public void RegisterViewWithRegion(string regionName, Func getContentDelegate) + public void RegisterViewWithRegion(string regionName, Func getContentDelegate) { _registeredContent.Add(regionName, getContentDelegate); OnContentRegistered(new ViewRegisteredEventArgs(regionName, getContentDelegate)); } /// - /// Creates an instance of a registered view . + /// Associate a view with a region, by registering a type. When the region get's displayed + /// this type will be resolved using the ServiceLocator into a concrete instance. The instance + /// will be added to the Views collection of the region /// + /// The name of the region to associate the view with. + /// The type of the view to register with the + /// The , for adding several views easily + public void RegisterViewWithRegion(string regionName, string targetName) => + RegisterViewWithRegion(regionName, c => c.Resolve(targetName)); + + /// Creates an instance of a registered view . /// Type of the registered view. /// Instance of the registered view. protected virtual object CreateInstance(Type type) From 0e305314c5032abc75139be428b54e4534113a4c Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 22:06:50 -0400 Subject: [PATCH 19/41] Migrated Regions to Prism.Core --- .../Regions/SelectorRegionAdapter.cs | 7 ++- .../Navigation/Regions/SingleActiveRegion.cs | 3 +- .../Regions/UpdateRegionsException.Desktop.cs | 22 ------- .../ViewRegistrationException.Desktop.cs | 24 -------- .../Navigation/Regions/ViewsCollection.cs | 59 +++++-------------- 5 files changed, 22 insertions(+), 93 deletions(-) delete mode 100644 src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs diff --git a/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs index 4b1734a..3d465c7 100644 --- a/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs @@ -1,11 +1,11 @@ -// TODO: Feature currently disabled +// TODO: Feature currently disabled /* using Prism.Regions.Behaviors; using System; using Avalonia.Controls.Primitives; -using System.Windows.Controls.Primitives; +using Avalonia.Styling; -namespace Prism.Regions +namespace Prism.Navigation.Regions { /// /// Adapter that creates a new and binds all @@ -50,6 +50,7 @@ protected override void AttachBehaviors(IRegion region, Selector regionTarget) // Add the behavior that syncs the items source items with the rest of the items region.Behaviors.Add(SelectorItemsSourceSyncBehavior.BehaviorKey, new SelectorItemsSourceSyncBehavior() { + /////HostControl = regionTarget HostControl = regionTarget.SelectedItem as Avalonia.AvaloniaObject // TODO: Verify '.SelectedItem ...' }); diff --git a/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs b/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs index e6aebe2..0b44f93 100644 --- a/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs +++ b/src/Prism.Avalonia/Navigation/Regions/SingleActiveRegion.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; namespace Prism.Navigation.Regions { @@ -21,6 +21,7 @@ public override void Activate(object view) { base.Deactivate(currentActiveView); } + base.Activate(view); } } diff --git a/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs deleted file mode 100644 index a0bf0de..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/UpdateRegionsException.Desktop.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Prism.Regions -{ - /// - /// Represents errors that occured during the regions' update. - /// - [Serializable] - public partial class UpdateRegionsException - { - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - protected UpdateRegionsException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs deleted file mode 100644 index a92f611..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/ViewRegistrationException.Desktop.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Runtime.Serialization; -using Prism.Navigation.Regions; - -namespace Prism.Regions -{ - /// - /// Exception that's thrown when something goes wrong while Registering a View with a region name in the class. - /// - [Serializable] - public partial class ViewRegistrationException - { - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - protected ViewRegistrationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs b/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs index 2f92392..1b2965b 100644 --- a/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ViewsCollection.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -23,9 +23,7 @@ public class ViewsCollection : IViewsCollection private Comparison sort; private List filteredItems = new List(); - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. /// The list to wrap and filter. /// A predicate to filter the collection. public ViewsCollection(ObservableCollection list, Predicate filter) @@ -37,14 +35,10 @@ public ViewsCollection(ObservableCollection list, Predicate - /// Occurs when the collection changes. - /// + /// Occurs when the collection changes. public event NotifyCollectionChangedEventHandler CollectionChanged; - /// - /// Gets or sets the comparison used to sort the views. - /// + /// Gets or sets the comparison used to sort the views. /// The comparison to use. public Comparison SortComparison { @@ -60,9 +54,7 @@ public Comparison SortComparison } } - /// - /// Determines whether the collection contains a specific value. - /// + /// Determines whether the collection contains a specific value. /// The object to locate in the collection. /// if is found in the collection; otherwise, . public bool Contains(object value) @@ -70,9 +62,7 @@ public bool Contains(object value) return filteredItems.Contains(value); } - /// - ///Returns an enumerator that iterates through the collection. - /// + ///Returns an enumerator that iterates through the collection.summary> /// ///A that can be used to iterate through the collection. /// @@ -81,9 +71,7 @@ public IEnumerator GetEnumerator() return filteredItems.GetEnumerator(); } - /// - ///Returns an enumerator that iterates through a collection. - /// + ///Returns an enumerator that iterates through a collection.summary> /// ///An object that can be used to iterate through the collection. /// @@ -92,14 +80,11 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } - /// - /// Used to invoked the event. - /// + /// Used to invoked the event. /// private void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { - NotifyCollectionChangedEventHandler handler = CollectionChanged; - if (handler != null) handler(this, e); + CollectionChanged?.Invoke(this, e); } private void NotifyReset() @@ -107,18 +92,14 @@ private void NotifyReset() OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } - /// - /// Removes all monitoring of underlying MetadataItems and re-adds them. - /// + /// Removes all monitoring of underlying MetadataItems and re-adds them. private void ResetAllMonitors() { RemoveAllMetadataMonitors(); MonitorAllMetadataItems(); } - /// - /// Adds all underlying MetadataItems to the list from the subjectCollection - /// + /// Adds all underlying MetadataItems to the list from the subjectCollection private void MonitorAllMetadataItems() { foreach (var item in subjectCollection) @@ -127,9 +108,7 @@ private void MonitorAllMetadataItems() } } - /// - /// Removes all monitored items from our monitoring list. - /// + /// Removes all monitored items from our monitoring list. private void RemoveAllMetadataMonitors() { foreach (var item in monitoredItems) @@ -140,9 +119,7 @@ private void RemoveAllMetadataMonitors() monitoredItems.Clear(); } - /// - /// Adds handler to monitor the MetadataItem and adds it to our monitoring list. - /// + /// Adds handler to monitor the MetadataItem and adds it to our monitoring list. /// /// private void AddMetadataMonitor(ItemMetadata itemMetadata, bool isInList) @@ -156,9 +133,7 @@ private void AddMetadataMonitor(ItemMetadata itemMetadata, bool isInList) }); } - /// - /// Unhooks from the MetadataItem change event and removes from our monitoring list. - /// + /// Unhooks from the MetadataItem change event and removes from our monitoring list. /// private void RemoveMetadataMonitor(ItemMetadata itemMetadata) { @@ -166,9 +141,7 @@ private void RemoveMetadataMonitor(ItemMetadata itemMetadata) monitoredItems.Remove(itemMetadata); } - /// - /// Invoked when any of the underlying ItemMetadata items we're monitoring changes. - /// + /// Invoked when any of the underlying ItemMetadata items we're monitoring changes. /// /// private void OnItemMetadataChanged(object sender, EventArgs e) @@ -272,7 +245,7 @@ private void RemoveFromFilteredList(object item) private void UpdateFilteredItemsList() { filteredItems = subjectCollection.Where(i => filter(i)).Select(i => i.Item) - .OrderBy(o => o, new RegionItemComparer(SortComparison)).ToList(); + .OrderBy(o => o, new RegionItemComparer(SortComparison)).ToList(); } private class MonitorInfo From a4871ddde748da9fd713c22fb1778c74604021e7 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 22:29:19 -0400 Subject: [PATCH 20/41] Region migrated to Prism.Core --- .../Behaviors/AutoPopulateRegionBehavior.cs | 6 +-- .../Navigation/Regions/IJournalAware.cs | 14 ------- .../Navigation/Regions/INavigateAsync.cs | 37 ------------------- .../NavigationAsyncExtensionsFixture.cs | 2 +- 4 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs index 1a21622..52657c0 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs @@ -1,6 +1,6 @@ -using System; +using System; using System.Collections.Generic; -using Prism.Navigation.Regions; +using Prism.Ioc; namespace Prism.Navigation.Regions.Behaviors { @@ -93,7 +93,7 @@ public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e) if (e.RegionName == Region.Name) { - AddViewIntoRegion(e.GetView()); + AddViewIntoRegion(e.GetView(ContainerLocator.Container)); } } } diff --git a/src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs b/src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs deleted file mode 100644 index 446aa4f..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/IJournalAware.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Prism.Navigation.Regions -{ - /// - /// Provides a way for objects involved in navigation to opt-out of being added to the IRegionNavigationJournal backstack. - /// - public interface IJournalAware - { - /// - /// Determines if the current object is going to be added to the navigation journal's backstack. - /// - /// True, add to backstack. False, remove from backstack. - bool PersistInHistory(); - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs b/src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs deleted file mode 100644 index ac02fa3..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/INavigateAsync.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace Prism.Navigation.Regions -{ - /// - /// Provides methods to perform navigation. - /// - /// - /// Convenience overloads for the methods in this interface can be found as extension methods on the - /// class. - /// - public interface INavigateAsync - { - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation target - /// The callback executed when the navigation request is completed. - /// - /// Convenience overloads for this method can be found as extension methods on the - /// class. - /// - void RequestNavigate(Uri target, Action navigationCallback); - - /// - /// Initiates navigation to the target specified by the . - /// - /// The navigation target - /// The callback executed when the navigation request is completed. - /// The navigation parameters specific to the navigation request. - /// - /// Convenience overloads for this method can be found as extension methods on the - /// class. - /// - void RequestNavigate(Uri target, Action navigationCallback, NavigationParameters navigationParameters); - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs index 3cdc102..cff448b 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using Moq; using Xunit; From ce2a50e03ccc3e3ff60b3a64a52fba4511867c57 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 22:46:47 -0400 Subject: [PATCH 21/41] Region to Prism.Core migration --- .../Navigation/Regions/AllActiveRegion.cs | 2 +- .../Regions/ContentControlRegionAdapter.cs | 3 +- .../Navigation/Regions/INavigationAware.cs | 29 ++--------- .../Navigation/Regions/ItemMetadata.cs | 52 ++++++------------- .../Regions/ItemsControlRegionAdapter.cs | 8 ++- .../Navigation/Regions/RegionManager.cs | 2 - 6 files changed, 27 insertions(+), 69 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs b/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs index 92441b2..4f43a6a 100644 --- a/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs +++ b/src/Prism.Avalonia/Navigation/Regions/AllActiveRegion.cs @@ -1,4 +1,4 @@ -using System; +using System; using Prism.Properties; namespace Prism.Navigation.Regions diff --git a/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs index b9af439..f2a10cf 100644 --- a/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ContentControlRegionAdapter.cs @@ -1,5 +1,4 @@ -using Avalonia.Controls; -using Avalonia.Data; +using Avalonia.Controls; using Prism.Properties; using System; using System.Collections.Specialized; diff --git a/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs b/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs index b0c0cbe..94e2eb3 100644 --- a/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs +++ b/src/Prism.Avalonia/Navigation/Regions/INavigationAware.cs @@ -1,29 +1,8 @@ -namespace Prism.Navigation.Regions +namespace Prism.Navigation.Regions { - /// - /// Provides a way for objects involved in navigation to be notified of navigation activities. - /// - public interface INavigationAware + /// Provides a way for objects involved in navigation to be notified of navigation activities. + /// Provides compatibility for Legacy Prism.Avalonia apps. + public interface INavigationAware : IRegionAware { - /// - /// Called when the implementer has been navigated to. - /// - /// The navigation context. - void OnNavigatedTo(NavigationContext navigationContext); - - /// - /// Called to determine if this instance can handle the navigation request. - /// - /// The navigation context. - /// - /// if this instance accepts the navigation request; otherwise, . - /// - bool IsNavigationTarget(NavigationContext navigationContext); - - /// - /// Called when the implementer is being navigated away from. - /// - /// The navigation context. - void OnNavigatedFrom(NavigationContext navigationContext); } } diff --git a/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs b/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs index 2627597..85e32d6 100644 --- a/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ItemMetadata.cs @@ -1,5 +1,5 @@ +using System; using Avalonia; -using System; namespace Prism.Navigation.Regions { @@ -8,21 +8,13 @@ namespace Prism.Navigation.Regions /// public class ItemMetadata : AvaloniaObject { - /// - /// The name of the wrapped item. - /// - public static readonly StyledProperty NameProperty = - AvaloniaProperty.Register("Name"); + /// The name of the wrapped item. + public static readonly StyledProperty NameProperty = AvaloniaProperty.Register(nameof(Name)); - /// - /// Value indicating whether the wrapped item is considered active. - /// - public static readonly StyledProperty IsActiveProperty = - AvaloniaProperty.Register("IsActive"); + /// Value indicating whether the wrapped item is considered active. + public static readonly StyledProperty IsActiveProperty = AvaloniaProperty.Register(nameof(IsActive)); - /// - /// Initializes a new instance of . - /// + /// Initializes a new instance of . /// The item to wrap. public ItemMetadata(object item) { @@ -35,15 +27,11 @@ static ItemMetadata() IsActiveProperty.Changed.Subscribe(args => StyledPropertyChanged(args?.Sender, args)); } - /// - /// Gets the wrapped item. - /// + /// Gets the wrapped item. /// The wrapped item. public object Item { get; private set; } - /// - /// Gets or sets a name for the wrapped item. - /// + /// Gets or sets a name for the wrapped item. /// The name of the wrapped item. public string Name { @@ -51,9 +39,7 @@ public string Name set { SetValue(NameProperty, value); } } - /// - /// Gets or sets a value indicating whether the wrapped item is considered active. - /// + /// Gets or sets a value indicating whether the wrapped item is considered active. /// if the item should be considered active; otherwise . public bool IsActive { @@ -61,27 +47,19 @@ public bool IsActive set { SetValue(IsActiveProperty, value); } } - /// - /// Occurs when metadata on the item changes. - /// + /// Occurs when metadata on the item changes. public event EventHandler MetadataChanged; - /// - /// Explicitly invokes to notify listeners. - /// + /// Explicitly invokes to notify listeners. public void InvokeMetadataChanged() { - EventHandler metadataChangedHandler = MetadataChanged; - if (metadataChangedHandler != null) metadataChangedHandler(this, EventArgs.Empty); + MetadataChanged?.Invoke(this, EventArgs.Empty); } - private static void StyledPropertyChanged(AvaloniaObject dependencyObject, AvaloniaPropertyChangedEventArgs args) + private static void StyledPropertyChanged(AvaloniaObject avaloniaObject, AvaloniaPropertyChangedEventArgs args) { - ItemMetadata itemMetadata = dependencyObject as ItemMetadata; - if (itemMetadata != null) - { - itemMetadata.InvokeMetadataChanged(); - } + var itemMetadata = avaloniaObject as ItemMetadata; + itemMetadata?.InvokeMetadataChanged(); } } } diff --git a/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs index dd10658..f3859d7 100644 --- a/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/ItemsControlRegionAdapter.cs @@ -1,4 +1,4 @@ -using System; +using System; using Avalonia.Controls; using Prism.Properties; @@ -32,8 +32,9 @@ protected override void Adapt(IRegion region, ItemsControl regionTarget) if (regionTarget == null) throw new ArgumentNullException(nameof(regionTarget)); - // In Avalonia, Items will never be null + // NOTE: In Avalonia, Items will never be null bool itemsSourceIsSet = regionTarget.ItemCount > 0; + itemsSourceIsSet = itemsSourceIsSet || regionTarget.HasBinding(ItemsControl.ItemsSourceProperty); if (itemsSourceIsSet) { @@ -47,6 +48,9 @@ protected override void Adapt(IRegion region, ItemsControl regionTarget) { region.Add(childItem); } + + // Control must be empty before setting ItemsSource + regionTarget.Items.Clear(); } // Avalonia v11-Preview5 needs IRegion implement IList. Enforcing it to return AvaloniaList fixes this. diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs index 652b38e..ff76a2e 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using System.ComponentModel; using System.Globalization; using System.Linq; using System.Reflection; @@ -14,7 +13,6 @@ using Prism.Ioc.Internals; using Avalonia; using Avalonia.Controls; -using Prism.Navigation.Regions; using Prism.Navigation.Regions.Behaviors; namespace Prism.Navigation.Regions From 5e92ae0ac3ec2e0d9c4f8b1366da44b46b02b39f Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 23:08:34 -0400 Subject: [PATCH 22/41] Behavior cleanup, migrating to Prism v9.0.271 --- ...ndRegionContextToAvaloniaObjectBehavior.cs | 131 +++++++++--------- .../ClearChildViewsRegionBehavior.cs | 12 +- .../DelayedRegionCreationBehavior.cs | 1 - .../Behaviors/DestructibleRegionBehavior.cs | 2 - .../RegionCreationException.Desktop.cs | 22 --- .../Behaviors/RegionCreationException.cs | 38 ----- 6 files changed, 68 insertions(+), 138 deletions(-) delete mode 100644 src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs delete mode 100644 src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs index 012b3f8..89a183b 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs @@ -1,6 +1,5 @@ -using Avalonia; +using Avalonia; using Prism.Common; -using Prism.Navigation.Regions; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; @@ -8,101 +7,95 @@ namespace Prism.Navigation.Regions.Behaviors { /// - /// Defines a behavior that forwards the + /// Defines a behavior that forwards the /// to the views in the region. /// - public class BindRegionContextToAvaloniaObjectBehavior : IRegionBehavior - { - /// - /// The key of this behavior. - /// - public const string BehaviorKey = "ContextToAvaloniaObject"; + public class BindRegionContextToDependencyObjectBehavior : IRegionBehavior +{ + /// The key of this behavior. + public const string BehaviorKey = "ContextToDependencyObject"; - /// - /// Behavior's attached region. - /// - public IRegion Region { get; set; } + /// Behavior's attached region. + public IRegion Region { get; set; } - /// - /// Attaches the behavior to the specified region. - /// - public void Attach() - { - Region.Views.CollectionChanged += Views_CollectionChanged; - Region.PropertyChanged += Region_PropertyChanged; - SetContextToViews(Region.Views, Region.Context); - AttachNotifyChangeEvent(Region.Views); - } + /// Attaches the behavior to the specified region. + public void Attach() + { + Region.Views.CollectionChanged += Views_CollectionChanged; + Region.PropertyChanged += Region_PropertyChanged; + SetContextToViews(Region.Views, Region.Context); + AttachNotifyChangeEvent(Region.Views); + } - private static void SetContextToViews(IEnumerable views, object context) + private static void SetContextToViews(IEnumerable views, object context) + { + foreach (var view in views) { - foreach (var view in views) + AvaloniaObject avaloniaObjectView = view as AvaloniaObject; + if (avaloniaObjectView != null) { - AvaloniaObject AvaloniaObjectView = view as AvaloniaObject; - if (AvaloniaObjectView != null) - { - ObservableObject contextWrapper = RegionContext.GetObservableContext(AvaloniaObjectView); - contextWrapper.Value = context; - } + ObservableObject contextWrapper = RegionContext.GetObservableContext(avaloniaObjectView); + contextWrapper.Value = context; } } + } - private void AttachNotifyChangeEvent(IEnumerable views) + private void AttachNotifyChangeEvent(IEnumerable views) + { + foreach (var view in views) { - foreach (var view in views) + var avaloniaObject = view as AvaloniaObject; + if (avaloniaObject != null) { - var AvaloniaObject = view as AvaloniaObject; - if (AvaloniaObject != null) - { - ObservableObject viewRegionContext = RegionContext.GetObservableContext(AvaloniaObject); - viewRegionContext.PropertyChanged += ViewRegionContext_OnPropertyChangedEvent; - } + ObservableObject viewRegionContext = RegionContext.GetObservableContext(avaloniaObject); + viewRegionContext.PropertyChanged += ViewRegionContext_OnPropertyChangedEvent; } } + } - private void DetachNotifyChangeEvent(IEnumerable views) + private void DetachNotifyChangeEvent(IEnumerable views) + { + foreach (var view in views) { - foreach (var view in views) + var avaloniaObject = view as AvaloniaObject; + if (avaloniaObject != null) { - var AvaloniaObject = view as AvaloniaObject; - if (AvaloniaObject != null) - { - ObservableObject viewRegionContext = RegionContext.GetObservableContext(AvaloniaObject); - viewRegionContext.PropertyChanged -= ViewRegionContext_OnPropertyChangedEvent; - } + ObservableObject viewRegionContext = RegionContext.GetObservableContext(avaloniaObject); + viewRegionContext.PropertyChanged -= ViewRegionContext_OnPropertyChangedEvent; } } + } - private void ViewRegionContext_OnPropertyChangedEvent(object sender, PropertyChangedEventArgs args) + private void ViewRegionContext_OnPropertyChangedEvent(object sender, PropertyChangedEventArgs args) + { + if (args.PropertyName == "Value") { - if (args.PropertyName == "Value") - { - var context = (ObservableObject)sender; - Region.Context = context.Value; - } + var context = (ObservableObject)sender; + Region.Context = context.Value; } + } - private void Views_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + private void Views_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) { - if (e.Action == NotifyCollectionChangedAction.Add) - { - SetContextToViews(e.NewItems, Region.Context); - AttachNotifyChangeEvent(e.NewItems); - } - else if (e.Action == NotifyCollectionChangedAction.Remove && Region.Context != null) - { - DetachNotifyChangeEvent(e.OldItems); - SetContextToViews(e.OldItems, null); + SetContextToViews(e.NewItems, Region.Context); + AttachNotifyChangeEvent(e.NewItems); + } + else if (e.Action == NotifyCollectionChangedAction.Remove && Region.Context != null) + { + DetachNotifyChangeEvent(e.OldItems); + SetContextToViews(e.OldItems, null); - } } + } - private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e) + private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "Context") { - if (e.PropertyName == "Context") - { - SetContextToViews(Region.Views, Region.Context); - } + SetContextToViews(Region.Views, Region.Context); } } } +} diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs index 296c77e..ab3442f 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; using Avalonia.Controls; using Prism.Navigation.Regions; using System; @@ -27,7 +27,7 @@ public class ClearChildViewsRegionBehavior : RegionBehavior AvaloniaProperty.RegisterAttached("ClearChildViews", typeof(ClearChildViewsRegionBehavior)); /// - /// Gets the ClearChildViews attached property from an . + /// Gets the ClearChildViews attached property from a . /// /// The object from which to get the value. /// The value of the ClearChildViews attached property in the target specified. @@ -36,11 +36,11 @@ public static bool GetClearChildViews(AvaloniaObject target) if (target == null) throw new ArgumentNullException(nameof(target)); - return (bool)target.GetValue(ClearChildViewsProperty); + return (bool)target.GetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty); } /// - /// Sets the ClearChildViews attached property in a . + /// Sets the ClearChildViews attached property in a . /// /// The object in which to set the value. /// The value of to set in the target object's ClearChildViews attached property. @@ -49,11 +49,11 @@ public static void SetClearChildViews(AvaloniaObject target, bool value) if (target == null) throw new ArgumentNullException(nameof(target)); - target.SetValue(ClearChildViewsProperty, value); + target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value); } /// - /// Subscribes to the 's PropertyChanged method to monitor its RegionManager property. + /// Subscribes to the 's PropertyChanged method to monitor its property. /// protected override void OnAttach() { diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs index 3011f0f..b20e641 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs @@ -5,7 +5,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Threading; -using Prism.Navigation.Regions; using Prism.Properties; namespace Prism.Navigation.Regions.Behaviors diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs index 06cbe9f..47252c3 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Specialized; using Prism.Common; -using Prism.Navigation; -using Prism.Navigation.Regions; namespace Prism.Navigation.Regions.Behaviors { diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs deleted file mode 100644 index d92d038..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.Desktop.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Prism.Regions.Behaviors -{ - /// - /// - /// - [Serializable] - public partial class RegionCreationException - { - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - protected RegionCreationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs deleted file mode 100644 index 57ffc0d..0000000 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionCreationException.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; - -namespace Prism.Regions.Behaviors -{ - /// - /// Represents errors that occured during region creation. - /// - public partial class RegionCreationException : Exception - { - /// - /// Initializes a new instance of the - /// - public RegionCreationException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public RegionCreationException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference - /// to the inner exception that is the cause of this exception. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified. - public RegionCreationException(string message, Exception inner) - : base(message, inner) - { - } - } -} From 016190870eec4febbd9356e912b5da8f930bc17b Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 23:24:21 -0400 Subject: [PATCH 23/41] Region Behavior sync for Prism.Core v9.0.271-pre --- .../Regions/Behaviors/IHostAwareRegionBehavior.cs | 3 +-- .../Regions/Behaviors/RegionActiveAwareBehavior.cs | 13 ++++++------- .../Behaviors/RegionManagerRegistrationBehavior.cs | 4 +--- .../Behaviors/RegionMemberLifetimeBehavior.cs | 11 +++++------ .../Behaviors/SyncRegionContextWithHostBehavior.cs | 5 ++--- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs index eebe7ac..3bfb34a 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs @@ -1,5 +1,4 @@ -using Avalonia; -using Prism.Navigation.Regions; +using Avalonia; namespace Prism.Navigation.Regions.Behaviors { diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs index 95a73f5..7eb8bc2 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs @@ -4,14 +4,13 @@ using Avalonia; using Avalonia.Controls; using Prism.Common; -using Prism.Navigation.Regions; namespace Prism.Navigation.Regions.Behaviors { /// - /// Behavior that monitors a object and + /// Behavior that monitors a object and /// changes the value for the property when - /// an object that implements gets added or removed + /// an object that implements gets added or removed /// from the collection. /// /// @@ -82,13 +81,13 @@ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs private void InvokeOnSynchronizedActiveAwareChildren(object item, Action invocation) { - var dependencyObjectView = item as AvaloniaObject; + var avaloniaObjectView = item as AvaloniaObject; - if (dependencyObjectView != null) + if (avaloniaObjectView != null) { - // We are assuming that any scoped region managers are attached directly to the + // We are assuming that any scoped region managers are attached directly to the // view. - var regionManager = RegionManager.GetRegionManager(dependencyObjectView); + var regionManager = RegionManager.GetRegionManager(avaloniaObjectView); // If the view's RegionManager attached property is different from the region's RegionManager, // then the view's region manager is a scoped region manager. diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs index d621101..cbe7c72 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs @@ -1,10 +1,9 @@ -using System; +using System; using System.ComponentModel; using Prism.Properties; using Avalonia; using Avalonia.Controls; using Avalonia.VisualTree; -using Prism.Navigation.Regions; namespace Prism.Navigation.Regions.Behaviors { @@ -54,7 +53,6 @@ public AvaloniaObject HostControl { throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach); } - hostControl = value; } } diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs index 16627f7..63e1ce3 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs @@ -4,7 +4,6 @@ using System.Linq; using Avalonia.Controls; using Prism.Common; -using Prism.Navigation.Regions; namespace Prism.Navigation.Regions.Behaviors { @@ -20,7 +19,7 @@ namespace Prism.Navigation.Regions.Behaviors /// or the (in that order) to determine if it should be kept /// alive on removal. ///

- /// If the item in the collection is a , it will + /// If the item in the collection is a , it will /// also check it's DataContext for or the . ///

/// The order of checks are: @@ -43,7 +42,7 @@ public class RegionMemberLifetimeBehavior : RegionBehavior /// protected override void OnAttach() { - Region.ActiveViews.CollectionChanged += OnActiveViewsChanged; + Region.ActiveViews.CollectionChanged += sOnActiveViewsChanged; } private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e) @@ -90,10 +89,10 @@ private static RegionMemberLifetimeAttribute GetItemOrContextLifetimeAttribute(o return lifetimeAttribute; } - var Control = inactiveView as Control; - if (Control != null && Control.DataContext != null) + var control = inactiveView as Control; + if (control != null && control.DataContext != null) { - var dataContext = Control.DataContext; + var dataContext = control.DataContext; var contextLifetimeAttribute = GetCustomAttributes(dataContext.GetType()).FirstOrDefault(); return contextLifetimeAttribute; diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs index c9c2ea0..ae0ae01 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs @@ -1,7 +1,6 @@ -using System; +using System; using Avalonia; using Prism.Common; -using Prism.Navigation.Regions; using Prism.Properties; namespace Prism.Navigation.Regions.Behaviors @@ -11,7 +10,7 @@ namespace Prism.Navigation.Regions.Behaviors /// the control that hosts the Region. It does this by setting the /// Dependency Property on the host control. /// - /// This behavior allows the usage of two way databinding of the RegionContext from XAML. + /// This behavior allows the usage of two way data binding of the RegionContext from XAML. /// public class SyncRegionContextWithHostBehavior : RegionBehavior, IHostAwareRegionBehavior { From ce5c3b382878b4b614a70e750b7032de7c4d1eef Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 10 Apr 2024 23:35:14 -0400 Subject: [PATCH 24/41] Generic repo cleanup from Prism.Navigation.Region migration --- .../Regions/Behaviors/RegionMemberLifetimeBehavior.cs | 2 +- .../Behaviors/SelectorItemsSourceSyncBehavior.cs | 4 ++-- .../Behaviors/SyncRegionContextWithHostBehavior.cs | 1 + .../Navigation/Regions/SelectorRegionAdapter.cs | 2 +- src/Prism.Avalonia/Properties/AssemblyInfo.cs | 11 ++--------- .../Mocks/MockHostAwareRegionBehavior.cs | 3 +-- .../Prism.Avalonia.Tests/Mocks/MockSortableViews.cs | 4 +--- .../Regions/AllActiveRegionFixture.cs | 3 +-- .../Behaviors/AutoPopulateRegionBehaviorFixture.cs | 4 ++-- ...indRegionContextToAvaloniaObjectBehaviorFixture.cs | 4 ++-- .../Behaviors/RegionActiveAwareBehaviorFixture.cs | 4 ++-- .../RegionManagerRegistrationBehaviorFixture.cs | 4 ++-- .../SelectorItemsSourceSyncRegionBehaviorFixture.cs | 6 +++--- .../Regions/ItemsControlRegionAdapterFixture.cs | 4 ++-- .../Regions/NavigationContextFixture.cs | 5 +---- .../Regions/NavigationParametersFixture.cs | 2 +- .../Regions/RegionAdapterMappingsFixture.cs | 4 ++-- .../Regions/RegionViewRegistryFixture.cs | 4 ++-- .../Regions/SelectorRegionAdapterFixture.cs | 6 +++--- .../Regions/SingleActiveRegionFixture.cs | 2 +- 20 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs index 63e1ce3..a09a6b4 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs @@ -42,7 +42,7 @@ public class RegionMemberLifetimeBehavior : RegionBehavior /// protected override void OnAttach() { - Region.ActiveViews.CollectionChanged += sOnActiveViewsChanged; + Region.ActiveViews.CollectionChanged += OnActiveViewsChanged; } private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs index 77149d2..9fc909f 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs @@ -1,4 +1,4 @@ -// TODO: 2022-07-08 - Feature disabled until a workaround can be created +// TODO: 2022-07-08 - Feature disabled until a workaround can be created // Consider using Avalonia.Styling.IStylable or Avalonia.Styling.Selector // in place of WPF's `Selector` object or AvaloniaObject. // This theory is untested and causes issues on code such as, `hostControl.Items` @@ -20,7 +20,7 @@ using Avalonia.Data; using System.Windows.Controls.Primitives; -namespace Prism.Regions.Behaviors +namespace Prism.Navigation.Regions.Behaviors { ///

/// Defines the attached behavior that keeps the items of the host control in synchronization with the . diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs index ae0ae01..93385e8 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs @@ -49,6 +49,7 @@ public AvaloniaObject HostControl { throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach); } + hostControl = value; } } diff --git a/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs b/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs index 3d465c7..a55ec6a 100644 --- a/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs +++ b/src/Prism.Avalonia/Navigation/Regions/SelectorRegionAdapter.cs @@ -1,6 +1,6 @@ // TODO: Feature currently disabled /* -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using System; using Avalonia.Controls.Primitives; using Avalonia.Styling; diff --git a/src/Prism.Avalonia/Properties/AssemblyInfo.cs b/src/Prism.Avalonia/Properties/AssemblyInfo.cs index 4d4b6e9..d24a6af 100644 --- a/src/Prism.Avalonia/Properties/AssemblyInfo.cs +++ b/src/Prism.Avalonia/Properties/AssemblyInfo.cs @@ -5,15 +5,8 @@ [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] -// ----- Legacy ----- -[assembly: XmlnsDefinition("http://www.codeplex.com/prism", "Prism.Regions")] -[assembly: XmlnsDefinition("http://www.codeplex.com/prism", "Prism.Regions.Behaviors")] -[assembly: XmlnsDefinition("http://www.codeplex.com/prism", "Prism.Mvvm")] -[assembly: XmlnsDefinition("http://www.codeplex.com/prism", "Prism.Interactivity")] -// ----- Legacy ----- - -[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Regions")] -[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Regions.Behaviors")] +[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Navigation.Regions")] +[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Navigation.Regions.Behaviors")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Mvvm")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Interactivity")] [assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Dialogs")] diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs index ab0a2d1..0b33b4e 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockHostAwareRegionBehavior.cs @@ -1,6 +1,5 @@ -using Avalonia; +using Avalonia; using Prism.Navigation.Regions.Behaviors; -using Prism.Regions; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockSortableViews.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockSortableViews.cs index 24dc817..9d49f94 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockSortableViews.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockSortableViews.cs @@ -1,6 +1,4 @@ -using Prism.Regions; - -namespace Prism.Avalonia.Tests.Mocks +namespace Prism.Avalonia.Tests.Mocks { [ViewSortHint("01")] internal class MockSortableView1 diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/AllActiveRegionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/AllActiveRegionFixture.cs index 3141498..5a6a720 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/AllActiveRegionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/AllActiveRegionFixture.cs @@ -1,5 +1,4 @@ -using Prism.Regions; -using Xunit; +using Xunit; namespace Prism.Avalonia.Tests.Regions { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs index 1f91564..3947469 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs @@ -1,5 +1,5 @@ -using Prism.Avalonia.Tests.Mocks; -using Prism.Regions.Behaviors; +using Prism.Avalonia.Tests.Mocks; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs index 3e1950b..fbded17 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehaviorFixture.cs @@ -1,5 +1,5 @@ -using Prism.Avalonia.Tests.Mocks; -using Prism.Regions.Behaviors; +using Prism.Avalonia.Tests.Mocks; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs index 966c2e8..e6f8e97 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs @@ -1,8 +1,8 @@ -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Input; using Moq; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs index 83542c0..5b89487 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs @@ -1,7 +1,7 @@ -using System.Collections; +using System.Collections; using Avalonia.Controls; using Prism.Avalonia.Tests.Mocks; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs index a0a652e..b24867f 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs @@ -1,4 +1,4 @@ -// This feature is currently disabled +// This feature is currently disabled // See, Prism.Avalonia.Regions.Behaviors.SelectorItemsSourceSyncBehavior.cs for more info. /* using System; @@ -7,8 +7,8 @@ using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Data; -using Prism.Regions; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions; +using Prism.Navigation.Regions.Behaviors; using Prism.Avalonia.Tests.Mocks; using Xunit; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs index 4977567..c8342a7 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs @@ -1,4 +1,4 @@ -// TODO: 2022-07-12 +// TODO: 2022-07-12 // REF: https://github.com/AvaloniaUI/Avalonia/issues/7553 // Cannot perform the following. Check out, ContentControlRegionAdapterFixture.cs // However, ItemsControl.Items is `IEnumerable` and doesn't play nicely. @@ -10,7 +10,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using Prism.Regions; +using Prism.Navigation.Regions; using Prism.Avalonia.Tests.Mocks; using Avalonia.Controls; using Avalonia.Data; diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationContextFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationContextFixture.cs index 76f2b1d..30122cd 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationContextFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationContextFixture.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using Moq; -using Prism.Regions; +using Moq; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs index fcc6013..1296466 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs @@ -1,5 +1,5 @@ using System.Linq; -using Prism.Regions; +using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterMappingsFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterMappingsFixture.cs index a80316f..b6a8d35 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterMappingsFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterMappingsFixture.cs @@ -1,4 +1,4 @@ -using Prism.Regions; +using Prism.Navigation.Regions; using Prism.Avalonia.Tests.Mocks; using Avalonia.Controls; using Moq; @@ -49,7 +49,7 @@ public void ShouldGetRegisteredMapping_UsingGenericControlAndAdapter() containerMock.Setup(c => c.Resolve(typeof(MockRegionAdapter))) .Returns(regionAdapter); ContainerLocator.ResetContainer(); - ContainerLocator.SetContainerExtension(() => containerMock.Object); + ContainerLocator.SetContainerExtension(containerMock.Object); regionAdapterMappings.RegisterMapping(); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs index 0cb2537..db28b89 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs @@ -4,7 +4,7 @@ using Prism.Avalonia.Tests.Mocks.Views; using Prism.Avalonia.Tests.Mvvm; using Prism.Ioc; -using Prism.Regions; +using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions @@ -82,7 +82,7 @@ public void ShouldRaiseEventWhenAddingContent() Assert.NotNull(listener.onViewRegisteredArguments); Assert.NotNull(listener.onViewRegisteredArguments.GetView); - var result = listener.onViewRegisteredArguments.GetView(); + var result = listener.onViewRegisteredArguments.GetView(containerMock.Object); Assert.NotNull(result); Assert.IsType(result); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs index 7ef0e25..27b2f12 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs @@ -1,10 +1,10 @@ -// TODO: 2022-07-13 +// TODO: 2022-07-13 // Feature, SelectorRegionAdapter, is currently disabled. /* using System; using Avalonia.Controls; -using Prism.Regions; -using Prism.Regions.Behaviors; +using Prism.Navigation.Regions; +using Prism.Navigation.Regions.Behaviors; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs index 0a544c1..8a5d410 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs @@ -1,4 +1,4 @@ -using Prism.Regions; +using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions From a9ceff1da055bc7d368fd58ac7551ae99eac9882 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 08:01:31 -0400 Subject: [PATCH 25/41] General cleanup i.e. `Prism.Region` -> `Prism.Navigation.Region`, `DependencyObject` -> `AvaloniaObject` --- .../Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs | 5 +++-- .../Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs | 2 +- .../Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs | 2 +- .../Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs index 89a183b..c9aac44 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs @@ -10,9 +10,10 @@ namespace Prism.Navigation.Regions.Behaviors /// Defines a behavior that forwards the /// to the views in the region. /// - public class BindRegionContextToDependencyObjectBehavior : IRegionBehavior -{ + public class BindRegionContextToAvaloniaObjectBehavior : IRegionBehavior + { /// The key of this behavior. + /// This SHOULD be ''ContextToAvaloniaObject'. public const string BehaviorKey = "ContextToDependencyObject"; /// Behavior's attached region. diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs index d5ec0a9..af7fc92 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismApplicationBaseFixture.cs @@ -166,7 +166,7 @@ public void ConfigureDefaultRegionBehaviorsShouldAddAutoPopulateRegionBehavior() } [Fact] - public void ConfigureDefaultRegionBehaviorsShouldBindRegionContextToDependencyObjectBehavior() + public void ConfigureDefaultRegionBehaviorsShouldBindRegionContextToAvaloniaObjectBehavior() { Assert.True(application.DefaultRegionBehaviorTypes.ContainsKey(BindRegionContextToAvaloniaObjectBehavior.BehaviorKey)); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs index 94e528e..9501539 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/PrismBootstrapperBaseFixture.cs @@ -161,7 +161,7 @@ public void ConfigureDefaultRegionBehaviorsShouldAddAutoPopulateRegionBehavior() } [Fact] - public void ConfigureDefaultRegionBehaviorsShouldBindRegionContextToDependencyObjectBehavior() + public void ConfigureDefaultRegionBehaviorsShouldBindRegionContextToAvaloniaObjectBehavior() { Assert.True(bootstrapper.DefaultRegionBehaviorTypes.ContainsKey(BindRegionContextToAvaloniaObjectBehavior.BehaviorKey)); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs index 7d171d4..ff23aae 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs @@ -1,7 +1,7 @@ -using Moq; +using Moq; using Prism.Avalonia.Tests.Mocks; using Prism.Navigation.Regions.Behaviors; -using Prism.Regions; +using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors From 20916fcdb66688aa2b3a35dbb6fbd32d35d1bcdb Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 08:18:14 -0400 Subject: [PATCH 26/41] Cleanup of Prism.Navigation.Region.Behaviors --- ...ndRegionContextToAvaloniaObjectBehavior.cs | 2 +- .../Navigation/Regions/RegionManager.cs | 4 ++-- ...egionManagerRegistrationBehaviorFixture.cs | 12 +++++------ .../RegionMemberLifetimeBehaviorFixture.cs | 20 ++++++++----------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs index c9aac44..27da651 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/BindRegionContextToAvaloniaObjectBehavior.cs @@ -13,7 +13,7 @@ namespace Prism.Navigation.Regions.Behaviors public class BindRegionContextToAvaloniaObjectBehavior : IRegionBehavior { /// The key of this behavior. - /// This SHOULD be ''ContextToAvaloniaObject'. + /// TODO (DS 2024-04-11): This SHOULD be ''ContextToAvaloniaObject'. public const string BehaviorKey = "ContextToDependencyObject"; /// Behavior's attached region. diff --git a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs index ff76a2e..b12b2ed 100644 --- a/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs +++ b/src/Prism.Avalonia/Navigation/Regions/RegionManager.cs @@ -371,12 +371,12 @@ public void RequestNavigate(string regionName, Uri source, Action - /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters. + /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of , which holds a collection of object parameters. /// /// The name of the region where the navigation will occur. /// A Uri that represents the target where the region will navigate. /// The navigation callback that will be executed after the navigation is completed. - /// An instance of NavigationParameters, which holds a collection of object parameters. + /// An instance of , which holds a collection of object parameters. public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters) { if (navigationCallback == null) diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs index 5b89487..4c8da50 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs @@ -246,8 +246,8 @@ public IRegionManager RegisterViewWithRegion(string regionName, Type viewType) throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) - { + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + { throw new NotImplementedException(); } @@ -271,22 +271,22 @@ public void RequestNavigate(string regionName, string source) throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs index ff23aae..cb5b38b 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs @@ -1,7 +1,6 @@ using Moq; using Prism.Avalonia.Tests.Mocks; using Prism.Navigation.Regions.Behaviors; -using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions.Behaviors @@ -18,10 +17,10 @@ public RegionMemberLifetimeBehaviorFixture() protected virtual void Arrange() { - this.Region = new Region(); - this.Behavior = new RegionMemberLifetimeBehavior(); - this.Behavior.Region = this.Region; - this.Behavior.Attach(); + Region = new Region(); + Behavior = new RegionMemberLifetimeBehavior(); + Behavior.Region = Region; + Behavior.Attach(); } [Fact] @@ -244,20 +243,17 @@ public class RegionMemberNotKeptAlive public class RegionMemberKeptAlive { } - - } - public class RegionMemberLifetimeBehaviorAgainstSingleActiveRegionFixture : RegionMemberLifetimeBehaviorFixture { protected override void Arrange() { - this.Region = new SingleActiveRegion(); - this.Behavior = new RegionMemberLifetimeBehavior(); - this.Behavior.Region = this.Region; - this.Behavior.Attach(); + Region = new SingleActiveRegion(); + Behavior = new RegionMemberLifetimeBehavior(); + Behavior.Region = Region; + Behavior.Attach(); } } } From efe7b7c677f9c723443141a59ac3bcbfd30a8bdb Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 09:07:37 -0400 Subject: [PATCH 27/41] Upgraded Region Mocks to Prism.Core v9.0.271-pre --- .../ExceptionExtensionsFixture.cs | 148 --------- .../Mocks/MockPresentationRegion.cs | 21 +- .../Prism.Avalonia.Tests/Mocks/MockRegion.cs | 8 +- .../Mocks/MockRegionAdapter.cs | 2 +- .../Mocks/MockRegionManager.cs | 17 +- .../Regions/NavigationParametersFixture.cs | 291 ------------------ 6 files changed, 27 insertions(+), 460 deletions(-) delete mode 100644 tests/Avalonia/Prism.Avalonia.Tests/ExceptionExtensionsFixture.cs delete mode 100644 tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs diff --git a/tests/Avalonia/Prism.Avalonia.Tests/ExceptionExtensionsFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/ExceptionExtensionsFixture.cs deleted file mode 100644 index 29eecb5..0000000 --- a/tests/Avalonia/Prism.Avalonia.Tests/ExceptionExtensionsFixture.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using Xunit; - -namespace Prism.Avalonia.Tests -{ - public class ExceptionExtensionsFixture - { - [Fact] - // Note, this test cannot be run twice in the same test run, because the registeration is static - // and we're not supplying an 'Unregister' method - public void CanRegisterFrameworkExceptionTypes() - { - Assert.False(ExceptionExtensions.IsFrameworkExceptionRegistered(typeof(MockException))); - - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(MockException)); - - Assert.True(ExceptionExtensions.IsFrameworkExceptionRegistered(typeof(MockException))); - } - - [Fact] - public void CanGetRootException() - { - Exception caughtException = null; - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(FrameworkException1)); - - try - { - try - { - throw new RootException(); - } - catch (Exception ex) - { - - throw new FrameworkException1(ex); - } - } - catch (Exception ex) - { - caughtException = ex; - } - - Assert.NotNull(caughtException); - - Exception exception = caughtException.GetRootException(); - - Assert.IsType(exception); - } - - [Fact] - public void CanCompensateForInnerFrameworkExceptionType() - { - Exception caughtException = null; - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(FrameworkException2)); - - try - { - try - { - try - { - throw new RootException(); - } - catch (Exception ex) - { - - throw new FrameworkException2(ex); - } - } - catch (Exception ex) - { - - throw new NonFrameworkException(ex); - } - } - catch (Exception ex) - { - caughtException = ex; - } - - Assert.NotNull(caughtException); - - Exception exception = caughtException.GetRootException(); - Assert.IsType(exception); - } - - [Fact] - public void GetRootExceptionReturnsTopExceptionWhenNoUserExceptionFound() - { - Exception caughtException = null; - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(FrameworkException1)); - ExceptionExtensions.RegisterFrameworkExceptionType(typeof(FrameworkException2)); - - try - { - try - { - throw new FrameworkException1(null); - } - catch (Exception ex) - { - - throw new FrameworkException2(ex); - } - } - catch (Exception ex) - { - caughtException = ex; - } - - Assert.NotNull(caughtException); - - Exception exception = caughtException.GetRootException(); - Assert.IsType(exception); - } - - private class MockException : Exception - { - } - - private class FrameworkException2 : Exception - { - public FrameworkException2(Exception innerException) - : base("", innerException) - { - } - } - - private class FrameworkException1 : Exception - { - public FrameworkException1(Exception innerException) : base("", innerException) - { - } - } - - private class RootException : Exception - { - } - - private class NonFrameworkException : Exception - { - public NonFrameworkException(Exception innerException) - : base("", innerException) - { - } - } - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs index 00bebc8..b7b4ee4 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockPresentationRegion.cs @@ -1,4 +1,4 @@ -using System.ComponentModel; +using System.ComponentModel; namespace Prism.Avalonia.Tests.Mocks { @@ -11,6 +11,9 @@ public MockPresentationRegion() { Behaviors = new MockRegionBehaviorCollection(); } + + public IRegionManager Add(string viewName) => throw new NotImplementedException(); + public IRegionManager Add(object view) { MockViews.Items.Add(view); @@ -74,7 +77,7 @@ public object Context } } - public NavigationParameters NavigationParameters + public INavigationParameters NavigationParameters { get { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); } @@ -83,11 +86,11 @@ public NavigationParameters NavigationParameters private string name; public string Name { - get { return this.name; } + get { return name; } set { - this.name = value; - this.OnPropertyChange("Name"); + name = value; + OnPropertyChange("Name"); } } @@ -95,10 +98,7 @@ public string Name public void OnPropertyChange(string propertyName) { - if (PropertyChanged != null) - { - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public bool Navigate(Uri source) @@ -111,7 +111,7 @@ public void RequestNavigate(Uri target, Action navigationCallb throw new NotImplementedException(); } - public void RequestNavigate(Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } @@ -127,7 +127,6 @@ public IRegionNavigationService NavigationService set { throw new System.NotImplementedException(); } } - public Comparison SortComparison { get diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs index ee326e6..5760933 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs @@ -1,4 +1,4 @@ -using System.ComponentModel; +using System.ComponentModel; namespace Prism.Avalonia.Tests.Mocks { @@ -26,7 +26,7 @@ public object Context set { throw new System.NotImplementedException(); } } - public NavigationParameters NavigationParameters + public INavigationParameters NavigationParameters { get { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); } @@ -34,6 +34,8 @@ public NavigationParameters NavigationParameters public string Name { get; set; } + public IRegionManager Add(string viewName) => throw new NotImplementedException(); + public IRegionManager Add(object view) { this.views.Add(view); @@ -87,7 +89,7 @@ public void RequestNavigate(System.Uri target, System.Action n throw new System.NotImplementedException(); } - public void RequestNavigate(System.Uri target, System.Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(System.Uri target, System.Action navigationCallback, INavigationParameters navigationParameters) { throw new System.NotImplementedException(); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs index 9c70515..5025720 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionAdapter.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; namespace Prism.Avalonia.Tests.Mocks { diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs index 7a68b6a..944c599 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; namespace Prism.Avalonia.Tests.Mocks { @@ -33,7 +33,7 @@ public IRegionManager RegisterViewWithRegion(string regionName, Type viewType) throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { throw new NotImplementedException(); } @@ -58,22 +58,22 @@ public void RequestNavigate(string regionName, string source) throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } @@ -92,6 +92,11 @@ public IRegionManager RegisterViewWithRegion(string regionName, string viewName) { throw new NotImplementedException(); } + + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + { + throw new NotImplementedException(); + } } internal class MockRegionCollection : List, IRegionCollection diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs deleted file mode 100644 index 1296466..0000000 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationParametersFixture.cs +++ /dev/null @@ -1,291 +0,0 @@ -using System.Linq; -using Prism.Navigation.Regions; -using Xunit; - -namespace Prism.Avalonia.Tests.Regions -{ - public class NavigationParametersFixture - { - const string _uri = "?id=3&name=brian"; - const string _uriWithNoQuestionMarkDelimiter = "id=3&name=brian"; - const string _uriWithArray = "color=red&color=white&color=blue"; - const string _uriWithJQueryArray = "color[]=red&color[]=white&color[]=blue"; - - [Fact] - public void ParametersParsedFromQuery() - { - var parameters = new NavigationParameters(_uri); - Assert.Equal(2, parameters.Count); - Assert.True(parameters.ContainsKey("id")); - Assert.Equal("3", parameters["id"]); - Assert.True(parameters.ContainsKey("name")); - Assert.Equal("brian", parameters["name"]); - } - - [Fact] - public void ParametersParsedFromQueryWithNoQuestionMarkDelimiter() - { - var parameters = new NavigationParameters(_uriWithNoQuestionMarkDelimiter); - Assert.Equal(2, parameters.Count); - Assert.True(parameters.ContainsKey("id")); - Assert.Equal("3", parameters["id"]); - Assert.True(parameters.ContainsKey("name")); - Assert.Equal("brian", parameters["name"]); - } - - [Fact] - public void ParametersParsedFromQueryWithArray() - { - var parameters = new NavigationParameters(_uriWithArray); - Assert.Equal(3, parameters.Count); - Assert.Contains("color", parameters.Keys.ToArray()); - } - - [Fact] - public void ParametersParsedFromQueryWithJQueryArray() - { - var parameters = new NavigationParameters(_uriWithJQueryArray); - Assert.Equal(3, parameters.Count); - Assert.Contains("color[]", parameters.Keys.ToArray()); - } - - [Fact] - public void EmptyNavigationParametersWhenGivenNull() - { - var parameters = new NavigationParameters(null); - Assert.NotNull(parameters); - Assert.Equal(0, parameters.Count); - } - - [Fact] - public void EmptyNavigationParametersWhenGivenSpace() - { - var parameters = new NavigationParameters(" "); - Assert.NotNull(parameters); - Assert.Equal(0, parameters.Count); - } - - [Fact] - public void EmptyNavigationParametersWhenGivenNoValue() - { - var parameters = new NavigationParameters("id"); - Assert.NotNull(parameters); - Assert.Equal(0, parameters.Count); - } - - [Fact] - public void ParametersHaveNoKeysWhenEmpty() - { - var parameters = new NavigationParameters(); - Assert.Empty(parameters.Keys); - } - - [Fact] - public void CountIsZeroWhenParametersAreEmpty() - { - var parameters = new NavigationParameters(); - Assert.Equal(0, parameters.Count); - } - - [Fact] - public void CountReturnsNumberOfParameters() - { - var parameters = new NavigationParameters($"{_uri}&{_uriWithArray}"); - Assert.Equal(5, parameters.Count); - } - - [Fact] - public void GetValueReturnsDefaultWhenGivenInvalidKey() - { - var parameters = new NavigationParameters(); - var result = parameters.GetValue("id"); - Assert.Equal(default(int), result); - } - - [Fact] - public void TryGetValueReturnsDefaultWhenGivenInvalidKey() - { - var parameters = new NavigationParameters(); - int value; - var result = parameters.TryGetValue("id", out value); - Assert.False(result); - Assert.Equal(default(int), value); - } - - [Fact] - public void GetValueReturnsDefaultWhenParameterValueIsNull() - { - var parameters = new NavigationParameters(); - parameters.Add("value", null); - var result = parameters.GetValue("value"); - Assert.Equal(0, result); - } - - [Fact] - public void TryGetValueReturnsDefaultWhenParameterValueIsNull() - { - var parameters = new NavigationParameters(); - parameters.Add("value", null); - int value; - var result = parameters.TryGetValue("value", out value); - Assert.True(result); - Assert.Equal(0, value); - } - - [Fact] - public void GetValueReturnsTypedParameterWhenParametersParsedFromQuery() - { - var parameters = new NavigationParameters(_uri); - var result = parameters.GetValue("id"); - Assert.IsType(result); - Assert.Equal(3, result); - } - - [Fact] - public void TryGetValueReturnsTypedParameterWhenParametersParsedFromQuery() - { - var parameters = new NavigationParameters(_uri); - int value; - var result = parameters.TryGetValue("id", out value); - Assert.True(result); - Assert.Equal(3, value); - } - - [Fact] - public void GetValueReturnsNullWhenParameterValueIsNull() - { - var parameters = new NavigationParameters(); - parameters.Add("value", null); - var result = parameters.GetValue("value"); - Assert.Null(result); - } - - [Fact] - public void GetValuesReturnsEmptyArrayWhenGivenNoKey() - { - var parameters = new NavigationParameters(); - var result = parameters.GetValues(null); - Assert.Empty(result); - } - - [Fact] - public void GetValuesReturnsEmptyArrayWhenGivenEmptyKey() - { - var parameters = new NavigationParameters(); - var result = parameters.GetValues(string.Empty); - Assert.Empty(result); - } - - [Fact] - public void GetValuesReturnsEmptyArrayWhenParametersParsedFromQueryWithInvalidKey() - { - var parameters = new NavigationParameters(_uriWithArray); - var result = parameters.GetValues("id"); - Assert.Empty(result); - } - - [Fact] - public void GetValuesReturnsArrayWhenParametersParsedFromQuery() - { - var parameters = new NavigationParameters(_uriWithArray); - var result = parameters.GetValues("color"); - Assert.Equal(3, result.Count()); - Assert.Contains("red", result); - Assert.Contains("white", result); - Assert.Contains("blue", result); - } - - [Fact] - public void GetValuesReturnsArrayWhenNotUsingQuery() - { - var parameters = new NavigationParameters(); - parameters.Add("id", new Person()); - parameters.Add("id", new Person()); - parameters.Add("id", null); - var result = parameters.GetValues("id").ToArray(); - Assert.Equal(3, result.Count()); - Assert.IsType(result[0]); - Assert.IsType(result[1]); - Assert.Null(result[2]); - } - - [Fact] - public void GetValuesConvertsValuesToStringWhenGivenUriQuery() - { - var parameters = new NavigationParameters(_uriWithArray); - var result = parameters.GetValues("color").ToArray(); - Assert.Equal(3, result.Count()); - - Assert.IsType(result[0]); - Assert.IsType(result[1]); - Assert.IsType(result[2]); - } - - [Fact] - public void GetValuesConvertsValuesToIntWhenGivenUriQuery() - { - var parameters = new NavigationParameters("id=1&id=2&id=3"); - var result = parameters.GetValues("id").ToArray(); - Assert.Equal(3, result.Count()); - Assert.IsType(result[0]); - Assert.IsType(result[1]); - Assert.IsType(result[2]); - } - - [Fact] - public void GetValueUseParentClassAsTypeParameter() - { - var parameters = new NavigationParameters(); - parameters.Add("id", new Child()); - - Assert.NotNull(parameters.GetValue("id")); - } - - [Fact] - public void TryGetValueUseParentClassAsTypeParameter() - { - var parameters = new NavigationParameters(); - parameters.Add("id", new Child()); - - Person value; - var result = parameters.TryGetValue("id", out value); - Assert.True(result); - Assert.IsType(value); - } - - [Fact] - public void GetValuesUseParentClassAsTypeParameter() - { - var parameters = new NavigationParameters(); - parameters.Add("id", new Child()); - parameters.Add("id", new Child()); - parameters.Add("id", new Person()); - - var result = parameters.GetValues("id").ToArray(); - - Assert.Equal(3, result.Count()); - Assert.NotNull(result[0]); - Assert.NotNull(result[1]); - Assert.NotNull(result[2]); - } - - [Fact] - public void ToStringWorksWithNullParameterValues() - { - var parameters = new NavigationParameters(); - parameters.Add("id1", 1); - parameters.Add("id2", null); - parameters.Add("id3", 3); - - var result = parameters.ToString(); - - Assert.Equal("?id1=1&id2=&id3=3", result); - } - } - - public class Person - { } - - public class Child : Person - { } -} From d80f91cbccdf5e57242fcfc066204b5e35295603 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 09:23:07 -0400 Subject: [PATCH 28/41] Cleaned up Region Behavior tests --- .../Mocks/MockRegionManager.cs | 5 ----- .../AutoPopulateRegionBehaviorFixture.cs | 18 ++++++++++++++---- .../RegionMemberLifetimeBehaviorFixture.cs | 6 +++--- .../ContentControlRegionAdapterFixture.cs | 4 +--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs index 944c599..8442fee 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegionManager.cs @@ -92,11 +92,6 @@ public IRegionManager RegisterViewWithRegion(string regionName, string viewName) { throw new NotImplementedException(); } - - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) - { - throw new NotImplementedException(); - } } internal class MockRegionCollection : List, IRegionCollection diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs index 3947469..f728859 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs @@ -1,4 +1,5 @@ -using Prism.Avalonia.Tests.Mocks; +using Moq; +using Prism.Avalonia.Tests.Mocks; using Prism.Navigation.Regions.Behaviors; using Xunit; @@ -9,6 +10,7 @@ public class AutoPopulateRegionBehaviorFixture [Fact] public void ShouldGetViewsFromRegistryOnAttach() { + ContainerLocator.SetContainerExtension(Mock.Of()); var region = new MockPresentationRegion() { Name = "MyRegion" }; var viewFactory = new MockRegionContentRegistry(); var view = new object(); @@ -28,6 +30,7 @@ public void ShouldGetViewsFromRegistryOnAttach() [Fact] public void ShouldGetViewsFromRegistryWhenRegisteringItAfterAttach() { + ContainerLocator.SetContainerExtension(Mock.Of()); var region = new MockPresentationRegion() { Name = "MyRegion" }; var viewFactory = new MockRegionContentRegistry(); var behavior = new AutoPopulateRegionBehavior(viewFactory) @@ -60,6 +63,8 @@ public void NullRegionThrows() [Fact] public void CanAttachBeforeSettingName() { + ContainerLocator.SetContainerExtension(Mock.Of()); + ContainerLocator.SetContainerExtension(Mock.Of()); var region = new MockPresentationRegion() { Name = null }; var viewFactory = new MockRegionContentRegistry(); var view = new object(); @@ -88,7 +93,7 @@ private class MockRegionContentRegistry : IRegionViewRegistry public event EventHandler ContentRegistered; - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { GetContentsCalled = true; this.GetContentsArgumentRegionName = regionName; @@ -97,7 +102,7 @@ public IEnumerable GetContents(string regionName) public void RaiseContentRegistered(string regionName, object view) { - this.ContentRegistered(this, new ViewRegisteredEventArgs(regionName, () => view)); + this.ContentRegistered(this, new ViewRegisteredEventArgs(regionName, _ => view)); } public void RegisterViewWithRegion(string regionName, Type viewType) @@ -105,7 +110,12 @@ public void RegisterViewWithRegion(string regionName, Type viewType) throw new NotImplementedException(); } - public void RegisterViewWithRegion(string regionName, Func getContentDelegate) + public void RegisterViewWithRegion(string regionName, Func getContentDelegate) + { + throw new NotImplementedException(); + } + + public void RegisterViewWithRegion(string regionName, string targetName) { throw new NotImplementedException(); } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs index cb5b38b..0c7d948 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs @@ -161,11 +161,11 @@ public virtual void RemovesRegionItemIfDataContextReturnsKeepAliveFalse() public virtual void RemovesOnlyDeactivatedItemsInRegionBasedOnDataContextKeepAlive() { // Arrange - var retionItemDataContextToKeepAlive = new Mock(); - retionItemDataContextToKeepAlive.Setup(i => i.KeepAlive).Returns(true); + var regionItemDataContextToKeepAlive = new Mock(); + regionItemDataContextToKeepAlive.Setup(i => i.KeepAlive).Returns(true); var regionItemToKeepAlive = new MockFrameworkElement(); - regionItemToKeepAlive.DataContext = retionItemDataContextToKeepAlive.Object; + regionItemToKeepAlive.DataContext = regionItemDataContextToKeepAlive.Object; Region.Add(regionItemToKeepAlive); Region.Activate(regionItemToKeepAlive); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs index 2c5e5e1..a060f40 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ContentControlRegionAdapterFixture.cs @@ -1,6 +1,4 @@ -using System; -using System.Linq; -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Data; using Prism.Avalonia.Tests.Mocks; using Xunit; From ae7a3a31c525dd28cfb18a9b2b87af497a9a4858 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 11:00:17 -0400 Subject: [PATCH 29/41] Updated Region fixtures for Prism.Core --- Upgrading-Prism.md | 7 +++ .../ItemsControlRegionAdapterFixture.cs | 1 + .../LocatorNavigationTargetHandlerFixture.cs | 26 +++++++--- .../NavigationAsyncExtensionsFixture.cs | 12 +++-- .../Regions/RegionAdapterBaseFixture.cs | 3 +- .../Regions/RegionFixture.cs | 37 ++++++++++--- .../Regions/RegionManagerFixture.cs | 36 ++++++++----- .../RegionManagerRequestNavigateFixture.cs | 16 +++--- .../Regions/RegionNavigationJournalFixture.cs | 52 +++++++++---------- 9 files changed, 121 insertions(+), 69 deletions(-) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index 4a59c81..ac019af 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -112,6 +112,13 @@ As we all know, not everything is straight forward between these two XAML techno | RegionManagerRequestNavigateFixture.cs | RegionViewRegistryFixture.cs +### Future Feature Work To Add + +| Project | Class | +|-|-| +| Prism.Avalonia.Tests | ItemsControlRegionAdapterFixture +| Prism.Avalonia.Tests | SelectorRegionAdapterFixture + ## Upgrading from Prism 7.2 to 8.1 * Basis of comparison: [Prism Library v7.2.0.1422...v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs index c8342a7..55b0ea0 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ItemsControlRegionAdapterFixture.cs @@ -36,6 +36,7 @@ public void AdapterAssociatesItemsControlWithRegion() [StaFact] public void AdapterAssignsARegionThatHasAllViewsActive() { + ContainerLocator.SetContainerExtension(Mock.Of()); var control = new ItemsControl(); IRegionAdapter adapter = new ItemsControlRegionAdapter(null); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs index f49124c..a78dad1 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs @@ -1,7 +1,8 @@ -using Avalonia.Controls; +using Avalonia.Controls; using Moq; using Prism.Ioc; using Xunit; +using static Prism.Avalonia.Tests.Regions.LocatorNavigationTargetHandlerFixture; namespace Prism.Avalonia.Tests.Regions { @@ -12,6 +13,7 @@ public void WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView() { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -34,23 +36,21 @@ public void WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView() public void WhenRegionHasMultipleViews_ThenViewsWithMatchingTypeNameAreConsidered() { // Arrange + var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); var view1 = new TestView(); - var view2 = "view"; + var view2 = new Test2View(); region.Add(view1); region.Add(view2); - var navigationContext = new NavigationContext(null, new Uri(view2.GetType().Name, UriKind.Relative)); - var navigationTargetHandler = new TestRegionNavigationContentLoader(containerMock.Object); - // Act var returnedView = navigationTargetHandler.LoadContent(region, navigationContext); - // Assert Assert.Same(view2, returnedView); } @@ -60,11 +60,12 @@ public void WhenRegionHasMultipleViews_ThenViewsWithMatchingFullTypeNameAreConsi { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); var view1 = new TestView(); - var view2 = "view"; + var view2 = new Test2View(); region.Add(view1); region.Add(view2); @@ -85,6 +86,7 @@ public void WhenViewExistsAndImplementsINavigationAware_ThenViewIsQueriedForNavi { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -113,6 +115,7 @@ public void WhenViewExistsAndHasDataContextThatImplementsINavigationAware_ThenDa { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -143,6 +146,7 @@ public void WhenNoCurrentMatchingViewExists_ThenReturnsNewlyCreatedInstanceWithS { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -167,6 +171,7 @@ public void WhenViewExistsAndImplementsINavigationAware_ThenViewIsQueriedForNavi { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -200,6 +205,7 @@ public void WhenViewExistsAndHasDataContextThatImplementsINavigationAware_ThenDa { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -235,6 +241,8 @@ public void WhenViewExistsAndHasDataContextThatImplementsINavigationAware_ThenDa public void WhenViewCannotBeCreated_ThenThrowsAnException() { var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); + containerMock.Setup(sl => sl.Resolve(typeof(object), typeof(TestView).Name)).Throws(); var region = new Region(); @@ -257,6 +265,7 @@ public void WhenViewAddedByHandlerDoesNotImplementINavigationAware_ThenReturnsVi { // Arrange var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -299,6 +308,7 @@ public void WhenRequestingContentForNullRegion_ThenThrows() public void WhenRequestingContentForNullContext_ThenThrows() { var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); var region = new Region(); @@ -320,6 +330,8 @@ public TestRegionNavigationContentLoader(IContainerExtension container) } public class TestView { } + + public class Test2View { } } public class ActivationException : Exception diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs index cff448b..ca769c2 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/NavigationAsyncExtensionsFixture.cs @@ -1,5 +1,4 @@ -using System; -using Moq; +using Moq; using Xunit; namespace Prism.Avalonia.Tests.Regions @@ -40,7 +39,8 @@ public void WhenNavigatingWithARelativeStringTarget_ThenNavigatesToRelativeUri() .Setup(nv => nv.RequestNavigate( It.Is(u => !u.IsAbsoluteUri && u.OriginalString == "relative"), - It.Is>(c => c != null))) + It.Is>(c => c != null), + It.IsAny())) .Verifiable(); string target = "relative"; @@ -58,7 +58,8 @@ public void WhenNavigatingWithAnAbsoluteStringTarget_ThenNavigatesToAbsoluteUri( .Setup(nv => nv.RequestNavigate( It.Is(u => u.IsAbsoluteUri && u.Host == "test" && u.AbsolutePath == "/path"), - It.Is>(c => c != null))) + It.Is>(c => c != null), + It.IsAny())) .Verifiable(); string target = "http://test/path"; @@ -91,7 +92,8 @@ public void WhenNavigatingWithAUri_ThenNavigatesToUriWithCallback() .Setup(nv => nv.RequestNavigate( target, - It.Is>(c => c != null))) + It.Is>(c => c != null), + It.IsAny())) .Verifiable(); navigateMock.Object.RequestNavigate(target); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs index fbd4791..0e3d06d 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionAdapterBaseFixture.cs @@ -1,5 +1,4 @@ -using System; -using Prism.Avalonia.Tests.Mocks; +using Prism.Avalonia.Tests.Mocks; using Xunit; namespace Prism.Avalonia.Tests.Regions diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs index 1b347e9..15b0e80 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Specialized; using System.Linq; using Moq; @@ -13,6 +13,7 @@ public class RegionFixture [Fact] public void WhenRegionConstructed_SortComparisonIsDefault() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); Assert.NotNull(region.SortComparison); @@ -22,6 +23,7 @@ public void WhenRegionConstructed_SortComparisonIsDefault() [Fact] public void CanAddContentToRegion() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); Assert.Empty(region.Views.Cast()); @@ -61,6 +63,7 @@ public void RemoveInexistentViewThrows() [Fact] public void RegionExposesCollectionOfContainedViews() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object view = new object(); @@ -77,6 +80,7 @@ public void RegionExposesCollectionOfContainedViews() [Fact] public void CanAddAndRetrieveNamedViewInstance() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object myView = new object(); region.Add(myView, "MyView"); @@ -102,6 +106,7 @@ public void AddingDuplicateNamedViewThrows() [Fact] public void AddNamedViewIsAlsoListedInViewsCollection() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object myView = new object(); @@ -134,6 +139,7 @@ public void GetViewWithNullOrEmptyStringThrows() [Fact] public void AddNamedViewWithNullOrEmptyStringNameThrows() { + ContainerLocator.SetContainerExtension(Mock.Of()); var ex = Assert.Throws(() => { IRegion region = new Region(); @@ -146,6 +152,7 @@ public void AddNamedViewWithNullOrEmptyStringNameThrows() [Fact] public void GetViewReturnsNullAfterRemovingViewFromRegion() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object myView = new object(); region.Add(myView, "MyView"); @@ -170,6 +177,7 @@ public void AddViewPassesSameScopeByDefaultToView() [Fact] public void AddViewPassesSameScopeByDefaultToNamedView() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new MockRegionManager(); IRegion region = new Region(); region.RegionManager = regionManager; @@ -181,8 +189,9 @@ public void AddViewPassesSameScopeByDefaultToNamedView() } [Fact] - public void AddViewPassesDiferentScopeWhenAdding() + public void AddViewPassesDifferentScopeWhenAdding() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new MockRegionManager(); IRegion region = new Region(); region.RegionManager = regionManager; @@ -196,6 +205,7 @@ public void AddViewPassesDiferentScopeWhenAdding() [Fact] public void CreatingNewScopesAsksTheRegionManagerForNewInstance() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new MockRegionManager(); IRegion region = new Region(); region.RegionManager = regionManager; @@ -209,6 +219,7 @@ public void CreatingNewScopesAsksTheRegionManagerForNewInstance() [Fact] public void AddViewReturnsExistingRegionManager() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new MockRegionManager(); IRegion region = new Region(); region.RegionManager = regionManager; @@ -286,6 +297,7 @@ public void ActivateNullViewThrows() [Fact] public void AddViewRaisesCollectionViewEvent() { + ContainerLocator.SetContainerExtension(Mock.Of()); bool viewAddedCalled = false; IRegion region = new Region(); @@ -305,6 +317,7 @@ public void AddViewRaisesCollectionViewEvent() [Fact] public void ViewAddedEventPassesTheViewAddedInTheEventArgs() { + ContainerLocator.SetContainerExtension(Mock.Of()); object viewAdded = null; IRegion region = new Region(); @@ -326,6 +339,7 @@ public void ViewAddedEventPassesTheViewAddedInTheEventArgs() [Fact] public void RemoveViewFiresViewRemovedEvent() { + ContainerLocator.SetContainerExtension(Mock.Of()); bool viewRemoved = false; IRegion region = new Region(); @@ -347,6 +361,7 @@ public void RemoveViewFiresViewRemovedEvent() [Fact] public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs() { + ContainerLocator.SetContainerExtension(Mock.Of()); object removedView = null; IRegion region = new Region(); @@ -409,6 +424,7 @@ public void AddingSameViewTwiceThrows() [Fact] public void RemovingViewAlsoRemovesItFromActiveViews() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object model = new object(); region.Add(model); @@ -423,6 +439,7 @@ public void RemovingViewAlsoRemovesItFromActiveViews() [Fact] public void ShouldGetNotificationWhenContextChanges() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); bool contextChanged = false; region.PropertyChanged += (s, args) => { if (args.PropertyName == "Context") contextChanged = true; }; @@ -467,7 +484,7 @@ public IRegionManager RegisterViewWithRegion(string regionName, Type viewType) throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { throw new NotImplementedException(); } @@ -492,22 +509,22 @@ public void RequestNavigate(string regionName, string source) throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, Action navigationCallback, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, Uri target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } - public void RequestNavigate(string regionName, string target, NavigationParameters navigationParameters) + public void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters) { throw new NotImplementedException(); } @@ -559,7 +576,7 @@ public void NavigateDelegatesToIRegionNavigationService() var containerMock = new Mock(); containerMock.Setup(x => x.Resolve(typeof(IRegionNavigationService))).Returns(mockRegionNavigationService.Object); ContainerLocator.ResetContainer(); - ContainerLocator.SetContainerExtension(() => containerMock.Object); + ContainerLocator.SetContainerExtension(containerMock.Object); // Act region.RequestNavigate(uri, navigationCallback, navigationParameters); @@ -576,6 +593,7 @@ public void NavigateDelegatesToIRegionNavigationService() [Fact] public void WhenViewsWithSortHintsAdded_RegionSortsViews() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region(); object view1 = new ViewOrder1(); @@ -595,6 +613,7 @@ public void WhenViewsWithSortHintsAdded_RegionSortsViews() [StaFact] public void WhenViewHasBeenRemovedAndRegionManagerPropertyCleared_ThenItCanBeAddedAgainToARegion() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new Region { RegionManager = new MockRegionManager() }; var view = new MockFrameworkElement(); @@ -618,8 +637,10 @@ public void WhenViewHasBeenRemovedAndRegionManagerPropertyCleared_ThenItCanBeAdd [ViewSortHint("C")] private class ViewOrder1 { }; + [ViewSortHint("A")] private class ViewOrder2 { }; + [ViewSortHint("B")] private class ViewOrder3 { }; } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs index be471d6..44434a7 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Specialized; using Moq; @@ -70,6 +70,7 @@ public void AddPassesItselfAsTheRegionManagerOfTheRegion() { Name = "region" }; + regionManager.Regions.Add(region); Assert.Same(regionManager, region.RegionManager); @@ -93,8 +94,8 @@ public void CanRemoveRegion() { Name = "TestRegion" }; - regionManager.Regions.Add(region); + regionManager.Regions.Add(region); regionManager.Regions.Remove("TestRegion"); Assert.False(regionManager.Regions.ContainsRegionWithName("TestRegion")); @@ -108,8 +109,8 @@ public void ShouldRemoveRegionManagerWhenRemoving() { Name = "TestRegion" }; - regionManager.Regions.Add(region); + regionManager.Regions.Add(region); regionManager.Regions.Remove("TestRegion"); Assert.Null(region.RegionManager); @@ -155,7 +156,6 @@ public void ShouldSetObservableRegionContextWhenRegionContextChanges() var region = new MockPresentationRegion(); var view = new MockDependencyObject(); - // NOTE: AvaloniaObject performs `Dispatcher.UIThread.VerifyAccess()`, if it's FALSE the InheritanceParent returns NULL. var observableObject = RegionContext.GetObservableContext(view); bool propertyChangedCalled = false; @@ -232,6 +232,7 @@ public void OnUpdatingRegions(object sender, EventArgs e) [Fact] public void WhenAddingRegions_ThenRegionsCollectionNotifiesUpdate() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new RegionManager(); var region1 = new Region { Name = "region1" }; @@ -260,6 +261,7 @@ public void WhenAddingRegions_ThenRegionsCollectionNotifiesUpdate() [Fact] public void WhenRemovingRegions_ThenRegionsCollectionNotifiesUpdate() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new RegionManager(); var region1 = new Region { Name = "region1" }; @@ -291,6 +293,7 @@ public void WhenRemovingRegions_ThenRegionsCollectionNotifiesUpdate() [Fact] public void WhenRemovingNonExistingRegion_ThenRegionsCollectionDoesNotNotifyUpdate() { + ContainerLocator.SetContainerExtension(Mock.Of()); var regionManager = new RegionManager(); var region1 = new Region { Name = "region1" }; @@ -316,6 +319,7 @@ public void CanAddViewToRegion() { Name = "RegionName" }; + regionManager.Regions.Add(region); regionManager.AddToRegion("RegionName", view1); @@ -341,9 +345,10 @@ public void CanRegisterViewType() viewType = type; return null; }; + var containerMock = new Mock(); containerMock.Setup(c => c.Resolve(typeof(IRegionViewRegistry))).Returns(mockRegionContentRegistry); - ContainerLocator.SetContainerExtension(() => containerMock.Object); + ContainerLocator.SetContainerExtension(containerMock.Object); var regionManager = new RegionManager(); @@ -378,7 +383,7 @@ public void CanRegisterViewTypeGeneric() var containerMock = new Mock(); containerMock.Setup(c => c.Resolve(typeof(IRegionViewRegistry))).Returns(mockRegionContentRegistry); ContainerLocator.ResetContainer(); - ContainerLocator.SetContainerExtension(() => containerMock.Object); + ContainerLocator.SetContainerExtension(containerMock.Object); var regionManager = new RegionManager(); @@ -402,18 +407,19 @@ public void CanRegisterDelegate() var mockRegionContentRegistry = new MockRegionContentRegistry(); string regionName = null; - Func contentDelegate = null; + Func contentDelegate = null; + Func expectedDelegate = _ => true; - Func expectedDelegate = () => true; mockRegionContentRegistry.RegisterContentWithDelegate = (name, usedDelegate) => { regionName = name; contentDelegate = usedDelegate; return null; }; + var containerMock = new Mock(); containerMock.Setup(c => c.Resolve(typeof(IRegionViewRegistry))).Returns(mockRegionContentRegistry); - ContainerLocator.SetContainerExtension(() => containerMock.Object); + ContainerLocator.SetContainerExtension(containerMock.Object); var regionManager = new RegionManager(); @@ -461,26 +467,30 @@ internal class FrameworkException : Exception public FrameworkException(Exception inner) : base(string.Empty, inner) { - } } internal class MockRegionContentRegistry : IRegionViewRegistry { public Func RegisterContentWithViewType; - public Func, object> RegisterContentWithDelegate; + public Func, object> RegisterContentWithDelegate; public event EventHandler ContentRegistered; - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { return null; } + public void RegisterViewWithRegion(string regionName, string targetName) + { + throw new NotImplementedException(); + } + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Type viewType) { RegisterContentWithViewType?.Invoke(regionName, viewType); } - void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) { RegisterContentWithDelegate?.Invoke(regionName, getContentDelegate); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs index ec54346..8a31b4f 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionManagerRequestNavigateFixture.cs @@ -52,33 +52,33 @@ public void WhenNonExistentRegion_ReturnNavigationResultFalse() result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); } [Fact] public void DelegatesCallToRegion_RegionSource() { regionManager.RequestNavigate(region, source); - mockRegion.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>())); + mockRegion.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), It.IsAny())); } [Fact] public void DelegatesCallToRegion_RegionTarget() { regionManager.RequestNavigate(region, sourceUri); - mockRegion.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>())); + mockRegion.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), It.IsAny())); } [Fact] @@ -99,14 +99,14 @@ public void DelegatesCallToRegion_RegionSourceUriParameters() public void DelegatesCallToRegion_RegionSourceCallback() { regionManager.RequestNavigate(region, source, callback); - mockRegion.Verify((r) => r.RequestNavigate(sourceUri, callback)); + mockRegion.Verify((r) => r.RequestNavigate(sourceUri, callback, It.IsAny())); } [Fact] public void DelegatesCallToRegion_RegionTargetCallback() { regionManager.RequestNavigate(region, sourceUri, callback); - mockRegion.Verify((r) => r.RequestNavigate(sourceUri, callback)); + mockRegion.Verify((r) => r.RequestNavigate(sourceUri, callback, It.IsAny())); } [Fact] diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs index 0d75d23..1217da8 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationJournalFixture.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Xunit; namespace Prism.Avalonia.Tests.Regions @@ -129,13 +129,13 @@ public void GoBackNavigatesBack() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -174,13 +174,13 @@ public void GoBackDoesNotChangeStateWhenNavigationFails() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -219,13 +219,13 @@ public void GoBackMultipleTimesNavigatesBack() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -265,13 +265,13 @@ public void GoForwardNavigatesForward() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); target.GoBack(); @@ -313,13 +313,13 @@ public void GoForwardDoesNotChangeStateWhenNavigationFails() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); target.GoBack(); @@ -360,13 +360,13 @@ public void GoForwardMultipleTimesNavigatesForward() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); target.GoBack(); @@ -411,13 +411,13 @@ public void WhenNavigationToNewUri_ThenCanNoLongerNavigateForward() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); @@ -459,16 +459,16 @@ public void WhenSavePreviousFalseDoNotRecordEntry() mockNavigationTarget .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget .Setup(x => x.RequestNavigate(uri4, It.IsAny>(), null)) - .Callback, NavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); Assert.Equal(entry4, target.CurrentEntry); From 73e6860f3522b2b6894de7a1b9f51eb0d7cc86e5 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 11:06:41 -0400 Subject: [PATCH 30/41] Updated RegionNavigationServiceFixture to use RequestNavigate NavigationResult of `Success` instead of `Result` --- Upgrading-Prism.md | 4 +- .../RegionNavigationServiceFixture.new.cs | 62 ++++++++++--------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index ac019af..cbc1e6b 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -38,7 +38,9 @@ As we all know, not everything is straight forward between these two XAML techno ### Changes * `Samples` folder renamed to `e2e` -* Prism.Dialogs - _See section for more info_ +* Prism.Dialogs + * _Various updates, see section before for more info_ +* `NavigationResult` returns the property `Success` instead of `Result` #### Dialogs diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs index 829ab60..25346c7 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionNavigationServiceFixture.new.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -38,7 +38,7 @@ public void WhenNavigating_ViewIsActivated() // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -74,7 +74,7 @@ public void WhenNavigatingWithQueryString_ViewIsActivated() // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -114,7 +114,7 @@ public void WhenNavigatingAndViewCannotBeAcquired_ThenNavigationResultHasError() new Uri(otherType.GetType().Name, UriKind.Relative), nr => { - error = nr.Error; + error = nr.Exception; }); // Verify @@ -146,9 +146,9 @@ public void WhenNavigatingWithNullUri_Throws() target.RequestNavigate((Uri)null, nr => navigationResult = nr); // Verify - Assert.False(navigationResult.Result.Value); - Assert.NotNull(navigationResult.Error); - Assert.IsType(navigationResult.Error); + Assert.False(navigationResult.Success); + Assert.NotNull(navigationResult.Exception); + Assert.IsType(navigationResult.Exception); } [Fact] @@ -189,12 +189,12 @@ public void WhenNavigatingAndDataContextImplementsINavigationAware_ThenNavigated // Prepare var region = new Region(); - Mock mockFrameworkElement = new Mock(); + Mock mockControl = new Mock(); Mock mockINavigationAwareDataContext = new Mock(); mockINavigationAwareDataContext.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true); - mockFrameworkElement.Object.DataContext = mockINavigationAwareDataContext.Object; + mockControl.Object.DataContext = mockINavigationAwareDataContext.Object; - var view = mockFrameworkElement.Object; + var view = mockControl.Object; region.Add(view); var navigationUri = new Uri(view.GetType().Name, UriKind.Relative); @@ -224,15 +224,15 @@ public void WhenNavigatingAndBothViewAndDataContextImplementINavigationAware_The // Prepare var region = new Region(); - Mock mockFrameworkElement = new Mock(); - Mock mockINavigationAwareView = mockFrameworkElement.As(); + Mock mockControl = new Mock(); + Mock mockINavigationAwareView = mockControl.As(); mockINavigationAwareView.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true); Mock mockINavigationAwareDataContext = new Mock(); mockINavigationAwareDataContext.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true); - mockFrameworkElement.Object.DataContext = mockINavigationAwareDataContext.Object; + mockControl.Object.DataContext = mockINavigationAwareDataContext.Object; - var view = mockFrameworkElement.Object; + var view = mockControl.Object; region.Add(view); var navigationUri = new Uri(view.GetType().Name, UriKind.Relative); @@ -277,6 +277,7 @@ public void WhenNavigating_NavigationIsRecordedInJournal() containerMock.Setup(x => x.Resolve(typeof(IRegionNavigationJournalEntry))).Returns(journalEntry); IContainerExtension container = containerMock.Object; + ContainerLocator.SetContainerExtension(container); RegionNavigationContentLoader contentLoader = new RegionNavigationContentLoader(container); var journalMock = new Mock(); @@ -432,7 +433,7 @@ public void WhenRequestNavigateAwayAcceptsThroughCallback_ThenNavigationProceeds // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1Mock.VerifyAll(); @@ -477,7 +478,7 @@ public void WhenRequestNavigateAwayRejectsThroughCallback_ThenNavigationDoesNotP // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1Mock.VerifyAll(); @@ -564,7 +565,7 @@ public void WhenRequestNavigateAwayOnDataContextAcceptsThroughCallback_ThenNavig // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1DataContextMock.VerifyAll(); @@ -611,7 +612,7 @@ public void WhenRequestNavigateAwayOnDataContextRejectsThroughCallback_ThenNavig // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1DataContextMock.VerifyAll(); @@ -659,8 +660,8 @@ public void WhenViewAcceptsNavigationOutAfterNewIncomingRequestIsReceived_ThenOr bool firstNavigation = false; bool secondNavigation = false; - target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Result.Value); - target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Result.Value); + target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Success); + target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Success); Assert.Equal(2, confirmationRequests.Count); @@ -714,8 +715,8 @@ public void WhenViewModelAcceptsNavigationOutAfterNewIncomingRequestIsReceived_T bool firstNavigation = false; bool secondNavigation = false; - target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Result.Value); - target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Result.Value); + target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Success); + target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Success); Assert.Equal(2, confirmationRequests.Count); @@ -729,6 +730,7 @@ public void WhenViewModelAcceptsNavigationOutAfterNewIncomingRequestIsReceived_T [Fact] public void BeforeNavigating_NavigatingEventIsRaised() { + ContainerLocator.SetContainerExtension(Mock.Of()); // Prepare object view = new object(); Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative); @@ -763,7 +765,7 @@ public void BeforeNavigating_NavigatingEventIsRaised() // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -807,7 +809,7 @@ public void WhenNavigationSucceeds_NavigatedIsRaised() // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -847,7 +849,7 @@ public void WhenTargetViewCreationThrowsWithAsyncConfirmation_ThenExceptionIsPro navigationCallback(true); Assert.NotNull(result); - Assert.Same(targetException, result.Error); + Assert.Same(targetException, result.Exception); } [Fact] @@ -999,7 +1001,7 @@ public void WhenNavigatingWithNoRegionSet_ThenMarshallExceptionToCallback() RegionNavigationService target = new RegionNavigationService(container, contentLoader, journal); Exception error = null; - target.RequestNavigate(navigationUri, nr => error = nr.Error); + target.RequestNavigate(navigationUri, nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1018,7 +1020,7 @@ public void WhenNavigatingWithNullUri_ThenMarshallExceptionToCallback() }; Exception error = null; - target.RequestNavigate(null, nr => error = nr.Error); + target.RequestNavigate(null, nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1058,7 +1060,7 @@ public void WhenNavigationFailsBecauseTheContentViewCannotBeRetrieved_ThenNaviga // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Success); // Verify Assert.False(isNavigationSuccessful.Value); @@ -1117,7 +1119,7 @@ public void WhenNavigationFailsBecauseActiveViewRejectsIt_ThenNavigationFailedIs // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify view1Mock.VerifyAll(); @@ -1179,7 +1181,7 @@ public void WhenNavigationFailsBecauseDataContextForActiveViewRejectsIt_ThenNavi // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify viewModel1Mock.VerifyAll(); From 0bcd2829ccd3b2e9ddaf138874b87929ce2b2621 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 11:24:09 -0400 Subject: [PATCH 31/41] Updated Navigation Region tests fixtures (successful system build) --- .../ClearChildViewsRegionBehavior.cs | 8 +- .../RegionManagerRegistrationBehavior.cs | 6 +- .../SelectorItemsSourceSyncBehavior.cs | 2 +- .../Navigation/Regions/Region.cs | 2 +- .../Mocks/MockDependencyObject.cs | 3 +- .../Regions/RegionViewRegistryFixture.cs | 96 ++----------------- .../Regions/SelectorRegionAdapterFixture.cs | 12 ++- .../Regions/SingleActiveRegionFixture.cs | 4 +- .../Regions/ViewsCollectionFixture.cs | 9 +- 9 files changed, 35 insertions(+), 107 deletions(-) diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs index ab3442f..94ffbd8 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs @@ -64,12 +64,12 @@ private static void ClearChildViews(IRegion region) { foreach (var view in region.Views) { - AvaloniaObject dependencyObject = view as AvaloniaObject; - if (dependencyObject != null) + AvaloniaObject avaloniaObject = view as AvaloniaObject; + if (avaloniaObject != null) { - if (GetClearChildViews(dependencyObject)) + if (GetClearChildViews(avaloniaObject)) { - dependencyObject.ClearValue(RegionManager.RegionManagerProperty); + avaloniaObject.ClearValue(RegionManager.RegionManagerProperty); } } } diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs index cbe7c72..8a7f1c5 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs @@ -126,16 +126,16 @@ public void OnUpdatingRegions(object sender, EventArgs e) TryRegisterRegion(); } - private IRegionManager FindRegionManager(AvaloniaObject dependencyObject) + private IRegionManager FindRegionManager(AvaloniaObject avaloniaObject) { - var regionmanager = RegionManagerAccessor.GetRegionManager(dependencyObject); + var regionmanager = RegionManagerAccessor.GetRegionManager(avaloniaObject); if (regionmanager != null) { return regionmanager; } //TODO: this is should be ok in Avalonia. I have to test it - AvaloniaObject parent = ((dependencyObject as Visual)?.GetVisualParent() ?? null) as AvaloniaObject; + AvaloniaObject parent = ((avaloniaObject as Visual)?.GetVisualParent() ?? null) as AvaloniaObject; if (parent != null) { return FindRegionManager(parent); diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs index 9fc909f..11cc9fe 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs @@ -18,7 +18,7 @@ using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Data; -using System.Windows.Controls.Primitives; +using Avalonia.Controls.Primitives; namespace Prism.Navigation.Regions.Behaviors { diff --git a/src/Prism.Avalonia/Navigation/Regions/Region.cs b/src/Prism.Avalonia/Navigation/Regions/Region.cs index 7f68c5a..f445c3f 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Region.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Region.cs @@ -207,7 +207,7 @@ protected virtual ObservableCollection ItemMetadataCollection /// Adds a new view to the region. /// Adds a new view to the region. /// The view to add. - /// The that is set on the view if it is a . It will be the current region manager when using this overload. + /// The that is set on the view if it is a . It will be the current region manager when using this overload. public IRegionManager Add(string viewName) { var view = ContainerLocator.Container.Resolve(viewName); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockDependencyObject.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockDependencyObject.cs index f55ae46..e069e3e 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockDependencyObject.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockDependencyObject.cs @@ -1,8 +1,9 @@ -using Avalonia; +using Avalonia; namespace Prism.Avalonia.Tests.Mocks { /// MockAvaloniaObject. + /// TODO: Rename to MockAvaloniaObject. public class MockDependencyObject : AvaloniaObject { } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs index db28b89..2cd1e3e 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/RegionViewRegistryFixture.cs @@ -1,60 +1,17 @@ using Avalonia.Controls; -using Avalonia.Markup.Xaml; using Moq; -using Prism.Avalonia.Tests.Mocks.Views; using Prism.Avalonia.Tests.Mvvm; -using Prism.Ioc; -using Prism.Navigation.Regions; using Xunit; namespace Prism.Avalonia.Tests.Regions { public class RegionViewRegistryFixture { - [Fact] - public void CanNotRegisterWhenMissingDataTemplateDataType() - { - // Created for Avalonia v11.0.0-pre4 - // See, https://github.com/AvaloniaUI/Avalonia/pull/8221 - var xaml = GenerateUserControlWithListView(useCompileBindings: false, useDataTemplateDataType: false); - var userCtrl = (MockBindingsView)AvaloniaRuntimeXamlLoader.Load(xaml); - - var containerMock = new Mock(); - containerMock.Setup(c => c.Resolve(typeof(MockBindingsView))).Returns(userCtrl); - var registry = new RegionViewRegistry(containerMock.Object); - - registry.RegisterViewWithRegion("MyRegion", typeof(MockBindingsView)); - var result = registry.GetContents("MyRegion"); - - Assert.NotNull(result); - Assert.Single(result); - Assert.IsType(result.ElementAt(0)); - } - - [Fact] - public void CanRegisterWhenDataTemplateDataTypeIsProvided() - { - // Created for Avalonia v11.0.0-pre4 - // See, https://github.com/AvaloniaUI/Avalonia/pull/8221 - var xaml = GenerateUserControlWithListView(useDataTemplateDataType: true); - var userCtrl = (MockBindingsView)AvaloniaRuntimeXamlLoader.Load(xaml); - - var containerMock = new Mock(); - containerMock.Setup(c => c.Resolve(typeof(MockBindingsView))).Returns(userCtrl); - var registry = new RegionViewRegistry(containerMock.Object); - - registry.RegisterViewWithRegion("MyRegion", typeof(MockBindingsView)); - var result = registry.GetContents("MyRegion"); - - Assert.NotNull(result); - Assert.Single(result); - Assert.IsType(result.ElementAt(0)); - } - [Fact] public void CanRegisterContentAndRetrieveIt() { var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); containerMock.Setup(c => c.Resolve(typeof(MockContentObject))).Returns(new MockContentObject()); var registry = new RegionViewRegistry(containerMock.Object); @@ -90,6 +47,7 @@ public void ShouldRaiseEventWhenAddingContent() [Fact] public void CanRegisterContentAsDelegateAndRetrieveIt() { + ContainerLocator.SetContainerExtension(Mock.Of()); var registry = new RegionViewRegistry(null); var content = new MockContentObject(); @@ -132,7 +90,7 @@ public void OnRegisterErrorShouldGiveClearException() { Assert.Contains("Dont do this", ex.Message); Assert.Contains("R1", ex.Message); - Assert.Equal("Dont do this", ex.InnerException?.Message); + Assert.Equal("Dont do this", ex.InnerException.Message); } catch (Exception) { @@ -159,13 +117,13 @@ public void RegisterViewWithRegion_ShouldHaveViewModel_ByDefault() ViewModelLocatorFixture.ResetViewModelLocationProvider(); var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); containerMock.Setup(c => c.Resolve(typeof(Mocks.Views.Mock))).Returns(new Mocks.Views.Mock()); containerMock.Setup(c => c.Resolve(typeof(Mocks.ViewModels.MockViewModel))).Returns(new Mocks.ViewModels.MockViewModel()); var registry = new RegionViewRegistry(containerMock.Object); registry.RegisterViewWithRegion("MyRegion", typeof(Mocks.Views.Mock)); - // TODO: AutowireViewModel is not kicking off. var result = registry.GetContents("MyRegion"); Assert.NotNull(result); Assert.Single(result); @@ -182,6 +140,7 @@ public void RegisterViewWithRegion_ShouldNotHaveViewModel_OnOptOut() ViewModelLocatorFixture.ResetViewModelLocationProvider(); var containerMock = new Mock(); + ContainerLocator.SetContainerExtension(containerMock.Object); containerMock.Setup(c => c.Resolve(typeof(Mocks.Views.MockOptOut))).Returns(new Mocks.Views.MockOptOut()); containerMock.Setup(c => c.Resolve(typeof(Mocks.ViewModels.MockOptOutViewModel))).Returns(new Mocks.ViewModels.MockOptOutViewModel()); var registry = new RegionViewRegistry(containerMock.Object); @@ -197,49 +156,6 @@ public void RegisterViewWithRegion_ShouldNotHaveViewModel_OnOptOut() Assert.Null(view.DataContext); } - private string GenerateUserControlWithListView(bool useCompileBindings = true, bool useDataTemplateDataType = true) - { - var xaml = @" - - - - "; - - if (useDataTemplateDataType) - xaml += @" - "; - else - xaml += @" - "; - - xaml += @" - - - - - -"; - return xaml; - } - private void FailWithFrameworkException(object sender, ViewRegisteredEventArgs e) { try @@ -264,7 +180,6 @@ private class MockContentObject private class MySubscriberClass { public ViewRegisteredEventArgs onViewRegisteredArguments; - public void OnContentRegistered(object sender, ViewRegisteredEventArgs e) { onViewRegisteredArguments = e; @@ -276,6 +191,7 @@ private class FrameworkException : Exception public FrameworkException(Exception innerException) : base("", innerException) { + } } } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs index 27b2f12..d6b38fd 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SelectorRegionAdapterFixture.cs @@ -3,6 +3,7 @@ /* using System; using Avalonia.Controls; +using Moq; using Prism.Navigation.Regions; using Prism.Navigation.Regions.Behaviors; using Xunit; @@ -14,6 +15,7 @@ public class SelectorRegionAdapterFixture [StaFact] public void AdapterAddsSelectorItemsSourceSyncBehavior() { + ContainerLocator.SetContainerExtension(Mock.Of()); var control = new ListBox(); IRegionAdapter adapter = new TestableSelectorRegionAdapter(); @@ -26,6 +28,7 @@ public void AdapterAddsSelectorItemsSourceSyncBehavior() [StaFact] public async Task AdapterDoesNotPreventRegionFromBeingGarbageCollected() { + ContainerLocator.SetContainerExtension(Mock.Of()); var selector = new ListBox(); object model = new object(); IRegionAdapter adapter = new SelectorRegionAdapter(null); @@ -33,14 +36,14 @@ public async Task AdapterDoesNotPreventRegionFromBeingGarbageCollected() var region = adapter.Initialize(selector, "Region1"); region.Add(model); - WeakReference regionWeakReference = new WeakReference(region); - WeakReference controlWeakReference = new WeakReference(selector); + var regionWeakReference = new WeakReference(region); + var controlWeakReference = new WeakReference(selector); Assert.True(regionWeakReference.IsAlive); Assert.True(controlWeakReference.IsAlive); region = null; selector = null; - await Task.delay(50); + await Task.Delay(50); GC.Collect(); GC.Collect(); @@ -51,6 +54,7 @@ public async Task AdapterDoesNotPreventRegionFromBeingGarbageCollected() [StaFact] public void ActivatingTheViewShouldUpdateTheSelectedItem() { + ContainerLocator.SetContainerExtension(Mock.Of()); var selector = new ListBox(); var view1 = new object(); var view2 = new object(); @@ -75,6 +79,7 @@ public void ActivatingTheViewShouldUpdateTheSelectedItem() [StaFact] public void DeactivatingTheSelectedViewShouldUpdateTheSelectedItem() { + ContainerLocator.SetContainerExtension(Mock.Of()); var selector = new ListBox(); var view1 = new object(); IRegionAdapter adapter = new SelectorRegionAdapter(null); @@ -97,6 +102,7 @@ public TestableSelectorRegionAdapter() { } + protected override IRegion CreateRegion() { return new Region(); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs index 8a5d410..2df2817 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/SingleActiveRegionFixture.cs @@ -1,4 +1,5 @@ -using Prism.Navigation.Regions; +using Moq; +using Prism.Ioc; using Xunit; namespace Prism.Avalonia.Tests.Regions @@ -8,6 +9,7 @@ public class SingleActiveRegionFixture [Fact] public void ActivatingNewViewDeactivatesCurrent() { + ContainerLocator.SetContainerExtension(Mock.Of()); IRegion region = new SingleActiveRegion(); var view = new object(); region.Add(view); diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs index 2391649..ea3c51d 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs +++ b/tests/Avalonia/Prism.Avalonia.Tests/Regions/ViewsCollectionFixture.cs @@ -1,7 +1,9 @@ -// NOTE: +// NOTE: // Avalonia.Data.CollectionViewSource control does not exist in Avalonia. // This feature was apart of a legacy build: // https://github.com/grokys/Avalonia/blob/master/Avalonia/Data/CollectionViewSource.cs +// Avalonia PR #14729 in draft as of 2024-04-11 +// https://github.com/AvaloniaUI/Avalonia/pull/14729 using System.Collections; using System.Collections.ObjectModel; using System.Collections.Specialized; @@ -114,7 +116,7 @@ public void CollectionChangedPassesWrappedItemInArgumentsWhenAdding() originalCollection.Remove(filteredInObject); Assert.NotNull(oldItemsPassed); - Assert.Equal(1, oldItemsPassed.Count); + Assert.Single(oldItemsPassed); Assert.Same(filteredInObject.Item, oldItemsPassed[0]); } @@ -130,7 +132,7 @@ public void CollectionChangedPassesWrappedItemInArgumentsWhenRemoving() originalCollection.Add(filteredInObject); Assert.NotNull(newItemsPassed); - Assert.Equal(1, newItemsPassed.Count); + Assert.Single(newItemsPassed); Assert.Same(filteredInObject.Item, newItemsPassed[0]); } @@ -268,6 +270,7 @@ public void OnRemoveOfFilterMatchingItemThenViewCollectionRelativeIndexProvided( Assert.Equal(1, removeEvent.OldStartingIndex); } + //// NOTE: Avalonia.Data.CollectionViewSource control does not exist in Avalonia. ////[Fact] ////public void RemovingFromFilteredCollectionDoesNotThrow() ////{ From 29fabdeaef60f7f4edb03e7eee95b3fe60533a3f Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 11:29:37 -0400 Subject: [PATCH 32/41] Removed unused MockBindingsView and ViewModel --- .../RegionManagerRegistrationBehavior.cs | 1 + .../Mocks/ViewModels/MockBindingsViewModel.cs | 45 ------------------- .../Mocks/Views/MockBindingsView.axaml | 28 ------------ .../Mocks/Views/MockBindingsView.axaml.cs | 18 -------- .../Prism.Avalonia.Tests.csproj | 6 --- 5 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 tests/Avalonia/Prism.Avalonia.Tests/Mocks/ViewModels/MockBindingsViewModel.cs delete mode 100644 tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml delete mode 100644 tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml.cs diff --git a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs index 8a7f1c5..da9a3c3 100644 --- a/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs +++ b/src/Prism.Avalonia/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs @@ -53,6 +53,7 @@ public AvaloniaObject HostControl { throw new InvalidOperationException(Resources.HostControlCannotBeSetAfterAttach); } + hostControl = value; } } diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/ViewModels/MockBindingsViewModel.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/ViewModels/MockBindingsViewModel.cs deleted file mode 100644 index 4338a08..0000000 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/ViewModels/MockBindingsViewModel.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections.ObjectModel; -using Prism.Mvvm; - -namespace Prism.Avalonia.Tests.Mocks.ViewModels -{ - internal class MockBindingsViewModel : BindableBase - { - private int _mockProperty; - private int _listItemSelected; - private string _listItemText = string.Empty; - private ObservableCollection _listItems = new(); - - public int MockProperty - { - get => _mockProperty; - set => SetProperty(ref _mockProperty, value); - } - - public int ListItemSelected - { - get => _listItemSelected; - set - { - SetProperty(ref _listItemSelected, value); - - if (value == -1) - return; - - ListItemText = ListItems[ListItemSelected]; - } - } - - public string ListItemText - { - get => _listItemText; - set => SetProperty(ref _listItemText, value); - } - - public ObservableCollection ListItems - { - get => _listItems; - set => SetProperty(ref _listItems, value); - } - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml deleted file mode 100644 index e69769f..0000000 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml.cs b/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml.cs deleted file mode 100644 index 04d3c14..0000000 --- a/tests/Avalonia/Prism.Avalonia.Tests/Mocks/Views/MockBindingsView.axaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Markup.Xaml; - -namespace Prism.Avalonia.Tests.Mocks.Views -{ - public partial class MockBindingsView : UserControl - { - public MockBindingsView() - { - InitializeComponent(); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj b/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj index 179465f..f96eaea 100644 --- a/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj +++ b/tests/Avalonia/Prism.Avalonia.Tests/Prism.Avalonia.Tests.csproj @@ -31,12 +31,6 @@ - - - MockBindingsView.axaml - - - MSBuild:Compile From 607f7e336ada9332f0eb709d382c1d0d0e746066 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 12:31:47 -0400 Subject: [PATCH 33/41] Documentation --- Upgrading-Prism.md | 49 ++++++++++--------- .../Extensions/CollectionExtensions.cs | 2 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Upgrading-Prism.md b/Upgrading-Prism.md index cbc1e6b..b0bacb9 100644 --- a/Upgrading-Prism.md +++ b/Upgrading-Prism.md @@ -91,35 +91,36 @@ As we all know, not everything is straight forward between these two XAML techno | File | Status | Notes | |-------------------------------------|---------|--------| -| MockHostAwareRegionBehavior.cs -| MockPresentationRegion.cs -| MockRegion.cs -| MockRegionAdapter.cs -| MockRegionBehavior.cs -| MockRegionBehaviorCollection.cs -| MockRegionManager.cs -| MockRegionmanagerAccessor.cs -| MockSortableViews.cs -| MockViewsCollection.cs -| PrismApplicationBaseFixture.cs -| PrismBootstrapperBaseFixture.cs -| AutoPopulateRegionBehaviorFixture.cs -| RegionActiveAwareBehaviorFixture.cs -| RegionManagerRegistrationBehaviorFixture.cs -| RegionMemberlifetimeBehaviorFixture.cs -| ContentControlRegionAdapterFixture.cs -| RegionAdapterBaseFixture.cs -| RegionBehaviorFixture.cs -| RegionFixture.cs -| RegionManagerRequestNavigateFixture.cs -| RegionViewRegistryFixture.cs +| MockHostAwareRegionBehavior.cs | :heavy_check_mark: +| MockPresentationRegion.cs | :heavy_check_mark: +| MockRegion.cs | :heavy_check_mark: +| MockRegionAdapter.cs | :heavy_check_mark: +| MockRegionBehavior.cs | :heavy_check_mark: +| MockRegionBehaviorCollection.cs | :heavy_check_mark: +| MockRegionManager.cs | :heavy_check_mark: +| MockRegionmanagerAccessor.cs | :heavy_check_mark: +| MockSortableViews.cs | :heavy_check_mark: +| MockViewsCollection.cs | :heavy_check_mark: +| PrismApplicationBaseFixture.cs | :heavy_check_mark: +| PrismBootstrapperBaseFixture.cs | :heavy_check_mark: +| AutoPopulateRegionBehaviorFixture.cs | :heavy_check_mark: +| RegionActiveAwareBehaviorFixture.cs | :heavy_check_mark: +| RegionManagerRegistrationBehaviorFixture.cs | :heavy_check_mark: +| RegionMemberlifetimeBehaviorFixture.cs | :heavy_check_mark: +| ContentControlRegionAdapterFixture.cs | :heavy_check_mark: +| RegionAdapterBaseFixture.cs | :heavy_check_mark: +| RegionBehaviorFixture.cs | :heavy_check_mark: +| RegionFixture.cs | :heavy_check_mark: +| RegionManagerRequestNavigateFixture.cs | :heavy_check_mark: +| RegionViewRegistryFixture.cs | :heavy_check_mark: ### Future Feature Work To Add | Project | Class | |-|-| -| Prism.Avalonia.Tests | ItemsControlRegionAdapterFixture -| Prism.Avalonia.Tests | SelectorRegionAdapterFixture +| Prism.Avalonia | `Interactivity/InvokeCommandAction` +| Prism.Avalonia.Tests | `Regions/ItemsControlRegionAdapterFixture` +| Prism.Avalonia.Tests | `Regions/SelectorRegionAdapterFixture` ## Upgrading from Prism 7.2 to 8.1 diff --git a/src/Prism.Avalonia/Extensions/CollectionExtensions.cs b/src/Prism.Avalonia/Extensions/CollectionExtensions.cs index da0553b..34a23c0 100644 --- a/src/Prism.Avalonia/Extensions/CollectionExtensions.cs +++ b/src/Prism.Avalonia/Extensions/CollectionExtensions.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace System.Collections.ObjectModel { From 432767ead03e7cf61ebf015d3ddd5a6ac163f9f2 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 11 Apr 2024 12:41:19 -0400 Subject: [PATCH 34/41] e2e `Prism.Regions` -> `Prism.Navigation.Regions` --- e2e/DummyModule1/DummyModule1.cs | 2 +- e2e/DummyModule1/Views/DummyModuleView.axaml | 2 +- e2e/DummyModule2/DumyModule2.cs | 2 +- e2e/DummyModule2/Views/DummyModuleView2.axaml | 4 ++-- e2e/DummyModule2/Views/DummyModuleView2.axaml.cs | 2 +- e2e/ModulesSample/MainWindow.axaml | 2 +- e2e/SampleDialogApp/ViewModels/ViewModelBase.cs | 2 +- e2e/SampleMvvmApp/App.axaml.cs | 2 +- e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs | 2 +- e2e/SampleMvvmApp/ViewModels/MainWindowViewModel.cs | 2 +- e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs | 2 +- e2e/SampleMvvmApp/ViewModels/SidebarViewModel.cs | 2 +- e2e/SampleMvvmApp/ViewModels/SubSettingsViewModel.cs | 2 +- e2e/SampleMvvmApp/ViewModels/ViewModelBase.cs | 2 +- e2e/ViewDiscovery/Views/MainWindow.axaml.cs | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/e2e/DummyModule1/DummyModule1.cs b/e2e/DummyModule1/DummyModule1.cs index 49b62e7..1cc6bf9 100644 --- a/e2e/DummyModule1/DummyModule1.cs +++ b/e2e/DummyModule1/DummyModule1.cs @@ -9,7 +9,7 @@ using Prism.Ioc; ////using Prism.Logging; using Prism.Modularity; -using Prism.Regions; +using Prism.Navigation.Regions; namespace DummyModule { diff --git a/e2e/DummyModule1/Views/DummyModuleView.axaml b/e2e/DummyModule1/Views/DummyModuleView.axaml index e812dc5..ee2af0c 100644 --- a/e2e/DummyModule1/Views/DummyModuleView.axaml +++ b/e2e/DummyModule1/Views/DummyModuleView.axaml @@ -1,6 +1,6 @@  diff --git a/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs b/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs index 2c46342..299a6d1 100644 --- a/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs +++ b/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs @@ -1,5 +1,5 @@ using Prism.Mvvm; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleDialogApp.ViewModels; diff --git a/e2e/SampleMvvmApp/App.axaml.cs b/e2e/SampleMvvmApp/App.axaml.cs index 81c6190..7cef8db 100644 --- a/e2e/SampleMvvmApp/App.axaml.cs +++ b/e2e/SampleMvvmApp/App.axaml.cs @@ -5,7 +5,7 @@ using Prism.DryIoc; using Prism.Ioc; using Prism.Modularity; -using Prism.Regions; +using Prism.Navigation.Regions; using SampleMvvmApp.Services; using SampleMvvmApp.ViewModels; using SampleMvvmApp.Views; diff --git a/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs b/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs index 432e2a5..cc4f330 100644 --- a/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs +++ b/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; using Avalonia.Controls; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.RegionAdapters { diff --git a/e2e/SampleMvvmApp/ViewModels/MainWindowViewModel.cs b/e2e/SampleMvvmApp/ViewModels/MainWindowViewModel.cs index cbae4ab..5f3edc0 100644 --- a/e2e/SampleMvvmApp/ViewModels/MainWindowViewModel.cs +++ b/e2e/SampleMvvmApp/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,4 @@ -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.ViewModels { diff --git a/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs b/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs index 436ea6f..8ce3b2b 100644 --- a/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs +++ b/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs @@ -1,6 +1,6 @@ using SampleMvvmApp.Views; using Prism.Commands; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.ViewModels { diff --git a/e2e/SampleMvvmApp/ViewModels/SidebarViewModel.cs b/e2e/SampleMvvmApp/ViewModels/SidebarViewModel.cs index e2ca9fe..86034e0 100644 --- a/e2e/SampleMvvmApp/ViewModels/SidebarViewModel.cs +++ b/e2e/SampleMvvmApp/ViewModels/SidebarViewModel.cs @@ -1,6 +1,6 @@ using SampleMvvmApp.Views; using Prism.Commands; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.ViewModels { diff --git a/e2e/SampleMvvmApp/ViewModels/SubSettingsViewModel.cs b/e2e/SampleMvvmApp/ViewModels/SubSettingsViewModel.cs index 2521b87..ce10712 100644 --- a/e2e/SampleMvvmApp/ViewModels/SubSettingsViewModel.cs +++ b/e2e/SampleMvvmApp/ViewModels/SubSettingsViewModel.cs @@ -6,7 +6,7 @@ using SampleMvvmApp.Views; using Prism.Commands; using Prism.Mvvm; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.ViewModels { diff --git a/e2e/SampleMvvmApp/ViewModels/ViewModelBase.cs b/e2e/SampleMvvmApp/ViewModels/ViewModelBase.cs index b18863e..becdcbb 100644 --- a/e2e/SampleMvvmApp/ViewModels/ViewModelBase.cs +++ b/e2e/SampleMvvmApp/ViewModels/ViewModelBase.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using Prism.Commands; using Prism.Mvvm; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleMvvmApp.ViewModels { diff --git a/e2e/ViewDiscovery/Views/MainWindow.axaml.cs b/e2e/ViewDiscovery/Views/MainWindow.axaml.cs index 5ef86c7..4d62602 100644 --- a/e2e/ViewDiscovery/Views/MainWindow.axaml.cs +++ b/e2e/ViewDiscovery/Views/MainWindow.axaml.cs @@ -3,7 +3,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Threading; -using Prism.Regions; +using Prism.Navigation.Regions; namespace ViewDiscovery.Views { From c3b865ddab9255249b8d677e9ef2a2f81a524e36 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 12 Apr 2024 17:29:30 -0400 Subject: [PATCH 35/41] Updated Sample Dialog app to Prism v9.0.271-pre --- .../ViewModels/DialogViewModel.cs | 31 ++++++++++------ .../ViewModels/MessageBoxViewModel.cs | 37 +++++++++---------- e2e/SampleDialogApp/Views/DialogView.axaml.cs | 25 ++++++++----- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index c9cb25f..6a7e596 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -27,19 +27,24 @@ public DialogViewModel(IDialogService dialogService) public string Title { get => _title; set => SetProperty(ref _title, value); } - /// Gets or sets the optional parent window of this Dialog pop-up. - public Window? ParentWindow { get => _parentWindow; set => SetProperty(ref _parentWindow, value); } + /////// Gets or sets the optional parent window of this Dialog pop-up. + ////public Window? ParentWindow { get => _parentWindow; set => SetProperty(ref _parentWindow, value); } public DelegateCommand CmdModalDialog => new(() => { var title = "MessageBox Title Here"; - var message = "Hello, I am a modal MessageBox window.\n\n" + - $"I {(ParentWindow == null ? "dont" : "do")} have a parent."; + var message = "Hello, I am a modal MessageBox window."; + // v9.0.271 _dialogService.ShowDialog( - ParentWindow, nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}")); + + // 8.1.97 + ////_dialogService.ShowDialog( + //// ParentWindow, + //// nameof(MessageBoxView), + //// new DialogParameters($"title={title}&message={message}")); }); public DelegateCommand CmdResult => new DelegateCommand((param) => @@ -57,13 +62,15 @@ public DialogViewModel(IDialogService dialogService) if (int.TryParse(param, out int intResult)) result = (ButtonResult)intResult; - RaiseRequestClose(new DialogResult(result)); + // NEW + RequestClose.Invoke(result); + + // OLD + ////RaiseRequestClose(new DialogResult(result)); }); public string CustomMessage { get => _customMessage; set => SetProperty(ref _customMessage, value); } - public event Action? RequestClose; - public virtual bool CanCloseDialog() { // Allow the dialog to close @@ -80,8 +87,8 @@ public void OnDialogOpened(IDialogParameters parameters) CustomMessage = parameters.GetValue("message"); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) - { - RequestClose?.Invoke(dialogResult); - } + ////public virtual void RaiseRequestClose(IDialogResult dialogResult) + ////{ + //// RequestClose?.Invoke(dialogResult); + ////} } diff --git a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs index 5861083..03f1a46 100644 --- a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs @@ -27,7 +27,11 @@ public MessageBoxViewModel() MaxWidth = 600; } - public event Action? RequestClose; + // v9.0.271-pre + public DialogCloseListener RequestClose { get; } + + // v8.1.97 + // public event Action? RequestClose; public string Title { get => _title; set => SetProperty(ref _title, value); } @@ -37,29 +41,23 @@ public MessageBoxViewModel() public DelegateCommand CmdResult => new DelegateCommand((param) => { - // None = 0 - // OK = 1 - // Cancel = 2 - // Abort = 3 - // Retry = 4 - // Ignore = 5 - // Yes = 6 - // No = 7 + // None = 0, OK = 1, Cancel = 2, Abort = 3, Retry = 4, Ignore = 5, Yes = 6, No = 7 ButtonResult result = ButtonResult.None; if (int.TryParse(param, out int intResult)) result = (ButtonResult)intResult; - RaiseRequestClose(new DialogResult(result)); + // v9.0.271-pre + RequestClose.Invoke(result); + + // v8.1.97 + // RaiseRequestClose(new DialogResult(result)); }); public string CustomMessage { get => _customMessage; set => SetProperty(ref _customMessage, value); } - public virtual bool CanCloseDialog() - { - // Allow the dialog to close - return true; - } + /// Allow the dialog to close + public virtual bool CanCloseDialog() => true; public virtual void OnDialogClosed() { @@ -75,8 +73,9 @@ public void OnDialogOpened(IDialogParameters parameters) CustomMessage = parameters.GetValue("message"); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) - { - RequestClose?.Invoke(dialogResult); - } + // v8.1.97 + ////public virtual void RaiseRequestClose(IDialogResult dialogResult) + ////{ + //// RequestClose?.Invoke(dialogResult); + ////} } diff --git a/e2e/SampleDialogApp/Views/DialogView.axaml.cs b/e2e/SampleDialogApp/Views/DialogView.axaml.cs index 696e183..e53e548 100644 --- a/e2e/SampleDialogApp/Views/DialogView.axaml.cs +++ b/e2e/SampleDialogApp/Views/DialogView.axaml.cs @@ -18,14 +18,15 @@ protected override void OnInitialized() { base.OnInitialized(); - // Pass the parent window to the ViewModel - // given that the ViewModel has been binded to this view - DialogViewModel? viewModel = this.DataContext as DialogViewModel; - if (this.Parent is Window parent && - viewModel is not null) - { - viewModel.ParentWindow = parent; - } + // v8.1.97 + ////// Pass the parent window to the ViewModel + ////// given that the ViewModel has been binded to this view + ////DialogViewModel? viewModel = this.DataContext as DialogViewModel; + ////if (this.Parent is Window parent && + //// viewModel is not null) + ////{ + //// viewModel.ParentWindow = parent; + ////} } private void InitializeComponent() @@ -42,9 +43,15 @@ private void BtnShowModal_Click(object sender, RoutedEventArgs args) "I've been called by the `.axaml.cs` UserControl."; dialogSvc.ShowDialog( - this.Parent as Window, nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}"), r => { }); + + // v8.1.97 + ////dialogSvc.ShowDialog( + //// this.Parent as Window, + //// nameof(MessageBoxView), + //// new DialogParameters($"title={title}&message={message}"), + //// r => { }); } } From 2686a28be09e1b9fb27e9741ced470294d3fa3d0 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 12 Apr 2024 17:30:01 -0400 Subject: [PATCH 36/41] Updated Sample MVVM App's NavigationParameters to Prism v9.0.271-pre --- .../RegionAdapters/ItemsControlRegionAdapter.cs | 1 + e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs b/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs index cc4f330..de2a0b7 100644 --- a/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs +++ b/e2e/SampleMvvmApp/RegionAdapters/ItemsControlRegionAdapter.cs @@ -70,6 +70,7 @@ protected override void Adapt(IRegion region, ItemsControl regionTarget) { items.Add(enumerator.Current); } + regionTarget.ItemsSource = items; }; } diff --git a/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs b/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs index 8ce3b2b..309aafc 100644 --- a/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs +++ b/e2e/SampleMvvmApp/ViewModels/SettingsViewModel.cs @@ -1,6 +1,7 @@ using SampleMvvmApp.Views; using Prism.Commands; using Prism.Navigation.Regions; +using Prism.Navigation; namespace SampleMvvmApp.ViewModels { @@ -14,11 +15,13 @@ public SettingsViewModel(IRegionManager regionManager) Title = "Settings"; } - public DelegateCommand CmdNavigateToChild => new DelegateCommand(() => + public DelegateCommand CmdNavigateToChild => new(() => { - var navParams = new NavigationParameters(); - navParams.Add("key1", "Some text"); - navParams.Add("key2", 999); + var navParams = new NavigationParameters + { + { "key1", "Some text" }, + { "key2", 999 } + }; _regionManager.RequestNavigate( RegionNames.ContentRegion, From 3653dba44811182f49b9fa13de30f8671d14019c Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 12 Apr 2024 20:29:55 -0400 Subject: [PATCH 37/41] Added KnownDialogParameters `ParentWindow` (type: Avalonia.Controls.Window) for DialogService parameter to override the default parent window. i.e. Using a dialog window as the parent for another dialog window. --- .../ViewModels/DialogViewModel.cs | 37 ++++++++++--------- e2e/SampleDialogApp/Views/DialogView.axaml.cs | 31 +++++++++------- src/Prism.Avalonia/Dialogs/DialogService.cs | 5 ++- .../Dialogs/IDialogServiceCompatExtensions.cs | 12 ++++++ .../Dialogs/KnownDialogParameters.cs | 3 ++ 5 files changed, 56 insertions(+), 32 deletions(-) diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index 6a7e596..6e0b887 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -12,6 +12,8 @@ public class DialogViewModel : BindableBase, IDialogAware private readonly IDialogService _dialogService; private string _customMessage = string.Empty; private string _title = "Notification"; + + /// Custom Prism.Avalonia feature. private Window? _parentWindow = null; public DialogViewModel(IDialogService dialogService) @@ -23,24 +25,31 @@ public DialogViewModel(IDialogService dialogService) Title = "I'm a Sample Dialog!"; } + // New: v9.0.271-pre public DialogCloseListener RequestClose { get; } public string Title { get => _title; set => SetProperty(ref _title, value); } - /////// Gets or sets the optional parent window of this Dialog pop-up. - ////public Window? ParentWindow { get => _parentWindow; set => SetProperty(ref _parentWindow, value); } + // Custom Prism.Avalonia feature + /// Gets or sets the optional parent window of this Dialog pop-up. + public Window? ParentWindow { get => _parentWindow; set => SetProperty(ref _parentWindow, value); } public DelegateCommand CmdModalDialog => new(() => { var title = "MessageBox Title Here"; - var message = "Hello, I am a modal MessageBox window."; + var message = "Hello, I am a modal MessageBox called via the ViewModel.\n\n" + + "My parent window is the DialogView's window."; // v9.0.271 _dialogService.ShowDialog( - nameof(MessageBoxView), - new DialogParameters($"title={title}&message={message}")); - - // 8.1.97 + name: nameof(MessageBoxView), + parameters: new DialogParameters($"title={title}&message={message}") + { + // This informs the DialogService to use this window for MessageBoxView's parent. + { KnownDialogParameters.ParentWindow , ParentWindow }, + }); + + // v8.1.97 ////_dialogService.ShowDialog( //// ParentWindow, //// nameof(MessageBoxView), @@ -49,23 +58,16 @@ public DialogViewModel(IDialogService dialogService) public DelegateCommand CmdResult => new DelegateCommand((param) => { - // None = 0 - // OK = 1 - // Cancel = 2 - // Abort = 3 - // Retry = 4 - // Ignore = 5 - // Yes = 6 - // No = 7 + // None = 0, OK = 1, Cancel = 2, Abort = 3, Retry = 4, Ignore = 5, Yes = 6, No = 7 ButtonResult result = ButtonResult.None; if (int.TryParse(param, out int intResult)) result = (ButtonResult)intResult; - // NEW + // NEW: 9.0.271-pre RequestClose.Invoke(result); - // OLD + // OLD: v8.1.97 ////RaiseRequestClose(new DialogResult(result)); }); @@ -87,6 +89,7 @@ public void OnDialogOpened(IDialogParameters parameters) CustomMessage = parameters.GetValue("message"); } + // OLD: v8.1.97 ////public virtual void RaiseRequestClose(IDialogResult dialogResult) ////{ //// RequestClose?.Invoke(dialogResult); diff --git a/e2e/SampleDialogApp/Views/DialogView.axaml.cs b/e2e/SampleDialogApp/Views/DialogView.axaml.cs index e53e548..4b3df96 100644 --- a/e2e/SampleDialogApp/Views/DialogView.axaml.cs +++ b/e2e/SampleDialogApp/Views/DialogView.axaml.cs @@ -18,15 +18,14 @@ protected override void OnInitialized() { base.OnInitialized(); - // v8.1.97 - ////// Pass the parent window to the ViewModel - ////// given that the ViewModel has been binded to this view - ////DialogViewModel? viewModel = this.DataContext as DialogViewModel; - ////if (this.Parent is Window parent && - //// viewModel is not null) - ////{ - //// viewModel.ParentWindow = parent; - ////} + // Pass the parent window to the ViewModel + // given that the ViewModel has been binded to this view + DialogViewModel? viewModel = this.DataContext as DialogViewModel; + if (this.Parent is Window parent && + viewModel is not null) + { + viewModel.ParentWindow = parent; + } } private void InitializeComponent() @@ -39,13 +38,19 @@ private void BtnShowModal_Click(object sender, RoutedEventArgs args) var dialogSvc = ContainerLocator.Current.Resolve(); var title = "MessageBox Title Here"; - var message = "Hello, I am a simple modal MessageBox with an OK button.\n\n" + - "I've been called by the `.axaml.cs` UserControl."; + var message = "Hello, I am a modal MessageBox called via the `.axaml.cs` UserControl.\n\n" + + "My parent window is the DialogView's window."; + + // Really you could just use 'this.Parent'. This ensures that our parent is a window and not another UserControl. + var parentWindow = this.Parent is Window parent ? parent : null; dialogSvc.ShowDialog( nameof(MessageBoxView), - new DialogParameters($"title={title}&message={message}"), - r => { }); + new DialogParameters($"title={title}&message={message}") + { + // This informs the DialogService to use this window for MessageBoxView's parent. + { KnownDialogParameters.ParentWindow, this.Parent }, + }); // v8.1.97 ////dialogSvc.ShowDialog( diff --git a/src/Prism.Avalonia/Dialogs/DialogService.cs b/src/Prism.Avalonia/Dialogs/DialogService.cs index b0d2295..54faeaa 100644 --- a/src/Prism.Avalonia/Dialogs/DialogService.cs +++ b/src/Prism.Avalonia/Dialogs/DialogService.cs @@ -25,18 +25,19 @@ public void ShowDialog(string name, IDialogParameters parameters, DialogCallback parameters ??= new DialogParameters(); var isModal = parameters.TryGetValue(KnownDialogParameters.ShowNonModal, out var show) ? !show : true; var windowName = parameters.TryGetValue(KnownDialogParameters.WindowName, out var wName) ? wName : null; + var owner = parameters.TryGetValue(KnownDialogParameters.ParentWindow, out var hWnd) ? hWnd : null; IDialogWindow dialogWindow = CreateDialogWindow(windowName); ConfigureDialogWindowEvents(dialogWindow, callback); ConfigureDialogWindowContent(name, dialogWindow, parameters); - ShowDialogWindow(dialogWindow, isModal); + ShowDialogWindow(dialogWindow, isModal, owner); } /// Shows the dialog window. /// The dialog window to show. /// If true; dialog is shown as a modal - /// Optional host window of the dialog. + /// Optional host window of the dialog. Use-case, Dialog calling a dialog. protected virtual void ShowDialogWindow(IDialogWindow dialogWindow, bool isModal, Window owner = null) { if (isModal && diff --git a/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs index dc1c7ca..544e6b5 100644 --- a/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs @@ -1,4 +1,5 @@ using System; +using Avalonia.Controls; namespace Prism.Dialogs { @@ -49,6 +50,17 @@ public static void Show(this IDialogService dialogService, string name, Action(KnownDialogParameters.ShowNonModal, out var show) ? !show : true; + //// var windowName = parameters.TryGetValue(KnownDialogParameters.WindowName, out var wName) ? wName : null; + //// var ownerWin = parameters.TryGetValue(KnownDialogParameters.ParentWindow, out var hWnd) ? hWnd : null; + //// + //// dialogService.ShowDialog(name, parameters, callback); + ////} + private static IDialogParameters EnsureShowNonModalParameter(IDialogParameters parameters) { parameters ??= new DialogParameters(); diff --git a/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs b/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs index 89040e3..b531404 100644 --- a/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs +++ b/src/Prism.Avalonia/Dialogs/KnownDialogParameters.cs @@ -8,4 +8,7 @@ public static class KnownDialogParameters /// Flag to show the Dialog Modally or Non-Modally. public const string ShowNonModal = "nonModal"; + + /// Host Window; when different from default. + public const string ParentWindow = "parentWindow"; } From 387e559712b500573f78e06c064758fe4cac8dff Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 12 Apr 2024 20:36:13 -0400 Subject: [PATCH 38/41] cleanup --- .../Dialogs/IDialogServiceCompatExtensions.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs index 544e6b5..eb9b838 100644 --- a/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs +++ b/src/Prism.Avalonia/Dialogs/IDialogServiceCompatExtensions.cs @@ -50,17 +50,6 @@ public static void Show(this IDialogService dialogService, string name, Action(KnownDialogParameters.ShowNonModal, out var show) ? !show : true; - //// var windowName = parameters.TryGetValue(KnownDialogParameters.WindowName, out var wName) ? wName : null; - //// var ownerWin = parameters.TryGetValue(KnownDialogParameters.ParentWindow, out var hWnd) ? hWnd : null; - //// - //// dialogService.ShowDialog(name, parameters, callback); - ////} - private static IDialogParameters EnsureShowNonModalParameter(IDialogParameters parameters) { parameters ??= new DialogParameters(); From cf8357035e0b158defb72541d408f404b0fb9ac0 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 12 Apr 2024 20:43:10 -0400 Subject: [PATCH 39/41] No loner need to pass empty result --- e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs | 2 +- e2e/SampleDialogApp/Views/MainWindow.axaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs index 988be5b..f7c41b6 100644 --- a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs @@ -22,7 +22,7 @@ public MainWindowViewModel(IDialogService dialogService) var message = "Hello, I am a simple MessageBox modal window with an OK button.\n\n" + "When too much text is added, a scrollbar will appear."; - _dialogService.ShowDialog(nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}"), r => { }); + _dialogService.ShowDialog(nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}")); }); public DelegateCommand CmdShowDialog => new DelegateCommand(() => diff --git a/e2e/SampleDialogApp/Views/MainWindow.axaml b/e2e/SampleDialogApp/Views/MainWindow.axaml index e662410..925de67 100644 --- a/e2e/SampleDialogApp/Views/MainWindow.axaml +++ b/e2e/SampleDialogApp/Views/MainWindow.axaml @@ -1,4 +1,4 @@ - Date: Fri, 12 Apr 2024 23:00:00 -0400 Subject: [PATCH 40/41] DialogService with a custom dialog window example --- e2e/SampleDialogApp/App.axaml.cs | 3 ++- .../ViewModels/DialogViewModel.cs | 21 +++++++++++++++ .../Views/CustomDialogWindow.axaml | 20 ++++++++++++++ .../Views/CustomDialogWindow.axaml.cs | 26 +++++++++++++++++++ e2e/SampleDialogApp/Views/DialogView.axaml | 6 ++++- 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 e2e/SampleDialogApp/Views/CustomDialogWindow.axaml create mode 100644 e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs diff --git a/e2e/SampleDialogApp/App.axaml.cs b/e2e/SampleDialogApp/App.axaml.cs index 239c0c8..de348e8 100644 --- a/e2e/SampleDialogApp/App.axaml.cs +++ b/e2e/SampleDialogApp/App.axaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using Avalonia; using Avalonia.Markup.Xaml; using Prism.DryIoc; @@ -27,5 +27,6 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.Register(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialogWindow(nameof(CustomDialogWindow)); } } diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index 6e0b887..b04c84b 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -56,6 +56,27 @@ public DialogViewModel(IDialogService dialogService) //// new DialogParameters($"title={title}&message={message}")); }); + public DelegateCommand CmdCustomDialogWindow => new(() => + { + // This passes the "title" to the Custom window's Title + // that is based off of it's inner 'MessageBoxView' UserControl. + var title = "Custom Title"; + var message = "Hello, I custom dialog window running inside of Prism.Avalonia!"; + + // NOTE: + // When setting, 'KnownDialogParameters.WindowName' the DialogService + // uses SampleDialogApp's CustomDialogWindow instead of + // Prism.Avalonia's default DialogWindow. + _dialogService.ShowDialog( + name: nameof(MessageBoxView), + new DialogParameters + { + { "title", title }, + { "message", message }, + { KnownDialogParameters.WindowName, nameof(CustomDialogWindow) } + }); + }); + public DelegateCommand CmdResult => new DelegateCommand((param) => { // None = 0, OK = 1, Cancel = 2, Abort = 3, Retry = 4, Ignore = 5, Yes = 6, No = 7 diff --git a/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml new file mode 100644 index 0000000..d2152b9 --- /dev/null +++ b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs new file mode 100644 index 0000000..ab78ee2 --- /dev/null +++ b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Prism.Dialogs; + +namespace SampleDialogApp.Views; + +/// Custom dialog window host. +public partial class CustomDialogWindow : Window, IDialogWindow +{ + public CustomDialogWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + /// The of the dialog. + public IDialogResult Result { get; set; } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/e2e/SampleDialogApp/Views/DialogView.axaml b/e2e/SampleDialogApp/Views/DialogView.axaml index 2e697ce..e07d3ad 100644 --- a/e2e/SampleDialogApp/Views/DialogView.axaml +++ b/e2e/SampleDialogApp/Views/DialogView.axaml @@ -1,4 +1,4 @@ - + +