diff --git a/Directory.Packages.props b/Directory.Packages.props
index c1b4283eda..be9aba98a4 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,7 +1,8 @@
-
-
+
+
+
@@ -52,14 +53,14 @@
-
+
-
-
-
-
+
+
+
+
diff --git a/PrismLibrary.sln b/PrismLibrary.sln
index c16390cab7..468c1fa15d 100644
--- a/PrismLibrary.sln
+++ b/PrismLibrary.sln
@@ -59,24 +59,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.DI.Forms.Tests", "tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.shproj", "{FAC4FA5A-D6C1-4787-9B1F-A3EC6E2FB26E}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{75B1C655-8365-4130-8B79-C748BF0403F2}"
-EndProject
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Unity.Shared", "src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.shproj", "{D66336A6-07E5-401A-A710-DAEDD6975D59}"
-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("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Uno", "Uno", "{8F959801-D494-4CAF-9437-90F30472E169}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Forms.Regions", "src\Forms\Prism.Forms.Regions\Prism.Forms.Regions.csproj", "{7760BB71-219E-4DB1-B67C-7A428D9A10E2}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Ioc.DryIoc.Tests", "tests\Containers\Prism.Container.DryIoc.Tests\Prism.Ioc.DryIoc.Tests.csproj", "{2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Ioc.Unity.Tests", "tests\Containers\Prism.Container.Unity.Tests\Prism.Ioc.Unity.Tests.csproj", "{704E14A4-C3A2-492D-9C4E-7D386A18B698}"
-EndProject
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Ioc.Shared", "tests\Containers\Prism.Container.Shared\Prism.Ioc.Shared.shproj", "{78932299-2281-4A59-BFB8-07DE3014F748}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{D62DD517-CA80-449D-A26B-9AB427379825}"
-EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Container.Wpf.Shared", "tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.shproj", "{BD42A7D6-A84D-4D27-9C28-7F6A2EC477F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Uno.WinUI", "src\Uno\Prism.Uno\Prism.Uno.WinUI.csproj", "{E74664C1-1BB1-4920-8099-2C9125CFD00B}"
@@ -99,7 +85,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Maui.Tests", "tests\M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.DryIoc.Maui.Tests", "tests\Maui\Prism.DryIoc.Maui.Tests\Prism.DryIoc.Maui.Tests.csproj", "{8711D306-1118-4A11-9399-EF14AA13015E}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prism.Events", "src\Prism.Events\Prism.Events.csproj", "{8610485A-BE9F-4938-86D4-E9F1FA1739A0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Events", "src\Prism.Events\Prism.Events.csproj", "{8610485A-BE9F-4938-86D4-E9F1FA1739A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -303,30 +289,6 @@ Global
{7760BB71-219E-4DB1-B67C-7A428D9A10E2}.Release|x64.Build.0 = Release|Any CPU
{7760BB71-219E-4DB1-B67C-7A428D9A10E2}.Release|x86.ActiveCfg = Release|Any CPU
{7760BB71-219E-4DB1-B67C-7A428D9A10E2}.Release|x86.Build.0 = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|x64.ActiveCfg = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|x64.Build.0 = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Debug|x86.Build.0 = Debug|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|Any CPU.Build.0 = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|x64.ActiveCfg = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|x64.Build.0 = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|x86.ActiveCfg = Release|Any CPU
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA}.Release|x86.Build.0 = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|x64.ActiveCfg = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|x64.Build.0 = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|x86.ActiveCfg = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Debug|x86.Build.0 = Debug|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|Any CPU.Build.0 = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|x64.ActiveCfg = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|x64.Build.0 = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|x86.ActiveCfg = Release|Any CPU
- {704E14A4-C3A2-492D-9C4E-7D386A18B698}.Release|x86.Build.0 = Release|Any CPU
{E74664C1-1BB1-4920-8099-2C9125CFD00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E74664C1-1BB1-4920-8099-2C9125CFD00B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E74664C1-1BB1-4920-8099-2C9125CFD00B}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -460,15 +422,8 @@ Global
{367BE810-5B34-4894-BE47-1C8DCC67DE81} = {F1F91777-01EA-43A3-A3ED-D473B382F46C}
{2E8F565D-9D13-424E-BD86-C5A362F9AAE7} = {F1F91777-01EA-43A3-A3ED-D473B382F46C}
{FAC4FA5A-D6C1-4787-9B1F-A3EC6E2FB26E} = {F8A0FDE6-8E75-47D1-9E33-02AB8E8AB473}
- {75B1C655-8365-4130-8B79-C748BF0403F2} = {F3664D7A-6FF5-4D1F-9F5F-26EE87F032D3}
- {D66336A6-07E5-401A-A710-DAEDD6975D59} = {75B1C655-8365-4130-8B79-C748BF0403F2}
- {6E7EC81D-DA39-4C4F-A898-0148558C34F4} = {75B1C655-8365-4130-8B79-C748BF0403F2}
{8F959801-D494-4CAF-9437-90F30472E169} = {F3664D7A-6FF5-4D1F-9F5F-26EE87F032D3}
{7760BB71-219E-4DB1-B67C-7A428D9A10E2} = {017675AD-346B-499D-819A-C43A2288DE98}
- {2D7EC81A-17B5-47C3-8AE1-619F7F8843AA} = {D62DD517-CA80-449D-A26B-9AB427379825}
- {704E14A4-C3A2-492D-9C4E-7D386A18B698} = {D62DD517-CA80-449D-A26B-9AB427379825}
- {78932299-2281-4A59-BFB8-07DE3014F748} = {D62DD517-CA80-449D-A26B-9AB427379825}
- {D62DD517-CA80-449D-A26B-9AB427379825} = {00FFDC13-7397-46F1-897E-A62A7575D28A}
{BD42A7D6-A84D-4D27-9C28-7F6A2EC477F1} = {F1F91777-01EA-43A3-A3ED-D473B382F46C}
{E74664C1-1BB1-4920-8099-2C9125CFD00B} = {8F959801-D494-4CAF-9437-90F30472E169}
{DB530D15-0556-4B6F-96B2-1497C8DF08D6} = {8F959801-D494-4CAF-9437-90F30472E169}
@@ -487,23 +442,10 @@ Global
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{089c5e84-52c3-409e-924c-bd8f4833594b}*SharedItemsImports = 5
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{0c8aab85-387c-41d2-abce-bafaf74b62b2}*SharedItemsImports = 5
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{2d7ec81a-17b5-47c3-8ae1-619f7f8843aa}*SharedItemsImports = 5
- tests\Containers\Prism.Container.Shared\Prism.Container.Shared.projitems*{2d7ec81a-17b5-47c3-8ae1-619f7f8843aa}*SharedItemsImports = 5
tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{367be810-5b34-4894-be47-1c8dcc67de81}*SharedItemsImports = 5
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{60d92138-66ac-4dc9-973d-fdd917f87112}*SharedItemsImports = 5
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*SharedItemsImports = 13
- src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{704e14a4-c3a2-492d-9c4e-7d386a18b698}*SharedItemsImports = 5
- tests\Containers\Prism.Container.Shared\Prism.Container.Shared.projitems*{704e14a4-c3a2-492d-9c4e-7d386a18b698}*SharedItemsImports = 5
- tests\Containers\Prism.Container.Shared\Prism.Container.Shared.projitems*{78932299-2281-4a59-bfb8-07de3014f748}*SharedItemsImports = 13
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{aad8a958-546b-4b7d-bbd1-d79e825530eb}*SharedItemsImports = 5
tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{ba05687e-2317-4a65-805b-c596f52f7203}*SharedItemsImports = 5
tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{bd42a7d6-a84d-4d27-9c28-7f6a2ec477f1}*SharedItemsImports = 13
- src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{c2f58215-92f0-4501-a9f4-862c78b2b4ce}*SharedItemsImports = 5
tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{c2ff8459-f2d1-4b87-a31a-82a1835f89cf}*SharedItemsImports = 5
- src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{d66336a6-07e5-401a-a710-daedd6975d59}*SharedItemsImports = 13
- src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{db530d15-0556-4b6f-96b2-1497c8df08d6}*SharedItemsImports = 5
- src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{e9a2458b-999d-4d36-822f-663d3830575a}*SharedItemsImports = 5
tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{fac4fa5a-d6c1-4787-9b1f-a3ec6e2fb26e}*SharedItemsImports = 13
EndGlobalSection
EndGlobal
diff --git a/PrismLibrary_Core.slnf b/PrismLibrary_Core.slnf
index d870bc04cf..5cbb22b6ee 100644
--- a/PrismLibrary_Core.slnf
+++ b/PrismLibrary_Core.slnf
@@ -2,13 +2,8 @@
"solution": {
"path": "PrismLibrary.sln",
"projects": [
- "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj",
- "src\\Containers\\Prism.Unity.Shared\\Prism.Unity.Shared.shproj",
"src\\Prism.Core\\Prism.Core.csproj",
"src\\Prism.Events\\Prism.Events.csproj",
- "tests\\Containers\\Prism.Container.DryIoc.Tests\\Prism.Ioc.DryIoc.Tests.csproj",
- "tests\\Containers\\Prism.Container.Shared\\Prism.Ioc.Shared.shproj",
- "tests\\Containers\\Prism.Container.Unity.Tests\\Prism.Ioc.Unity.Tests.csproj",
"tests\\Prism.Core.Tests\\Prism.Core.Tests.csproj"
]
}
diff --git a/PrismLibrary_Forms.slnf b/PrismLibrary_Forms.slnf
index 42c38975c8..4c22eebec8 100644
--- a/PrismLibrary_Forms.slnf
+++ b/PrismLibrary_Forms.slnf
@@ -2,17 +2,12 @@
"solution": {
"path": "PrismLibrary.sln",
"projects": [
- "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj",
- "src\\Containers\\Prism.Unity.Shared\\Prism.Unity.Shared.shproj",
"src\\Forms\\Prism.DryIoc.Forms\\Prism.DryIoc.Forms.csproj",
"src\\Forms\\Prism.Forms.Regions\\Prism.Forms.Regions.csproj",
"src\\Forms\\Prism.Forms\\Prism.Forms.csproj",
"src\\Forms\\Prism.Unity.Forms\\Prism.Unity.Forms.csproj",
"src\\Prism.Core\\Prism.Core.csproj",
"src\\Prism.Events\\Prism.Events.csproj",
- "tests\\Containers\\Prism.Container.DryIoc.Tests\\Prism.Ioc.DryIoc.Tests.csproj",
- "tests\\Containers\\Prism.Container.Shared\\Prism.Ioc.Shared.shproj",
- "tests\\Containers\\Prism.Container.Unity.Tests\\Prism.Ioc.Unity.Tests.csproj",
"tests\\Forms\\Prism.DI.Forms.Tests\\Prism.DI.Forms.Tests.shproj",
"tests\\Forms\\Prism.DryIoc.Forms.Tests\\Prism.DryIoc.Forms.Tests.csproj",
"tests\\Forms\\Prism.Forms.Regions.Tests\\Prism.Forms.Regions.Tests.csproj",
diff --git a/PrismLibrary_Maui.slnf b/PrismLibrary_Maui.slnf
index 0248af8dfc..0ef9a20368 100644
--- a/PrismLibrary_Maui.slnf
+++ b/PrismLibrary_Maui.slnf
@@ -2,14 +2,11 @@
"solution": {
"path": "PrismLibrary.sln",
"projects": [
- "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj",
"src\\Maui\\Prism.DryIoc.Maui\\Prism.DryIoc.Maui.csproj",
"src\\Maui\\Prism.Maui.Rx\\Prism.Maui.Rx.csproj",
"src\\Maui\\Prism.Maui\\Prism.Maui.csproj",
"src\\Prism.Core\\Prism.Core.csproj",
"src\\Prism.Events\\Prism.Events.csproj",
- "tests\\Containers\\Prism.Container.DryIoc.Tests\\Prism.Ioc.DryIoc.Tests.csproj",
- "tests\\Containers\\Prism.Container.Shared\\Prism.Ioc.Shared.shproj",
"tests\\Maui\\Prism.DryIoc.Maui.Tests\\Prism.DryIoc.Maui.Tests.csproj",
"tests\\Maui\\Prism.Maui.Tests\\Prism.Maui.Tests.csproj",
"tests\\Prism.Core.Tests\\Prism.Core.Tests.csproj"
diff --git a/PrismLibrary_Uno.slnf b/PrismLibrary_Uno.slnf
index 3438a423d2..3c69accf58 100644
--- a/PrismLibrary_Uno.slnf
+++ b/PrismLibrary_Uno.slnf
@@ -2,15 +2,10 @@
"solution": {
"path": "PrismLibrary.sln",
"projects": [
- "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj",
- "src\\Containers\\Prism.Unity.Shared\\Prism.Unity.Shared.shproj",
"src\\Prism.Core\\Prism.Core.csproj",
"src\\Prism.Events\\Prism.Events.csproj",
"src\\Uno\\Prism.DryIoc.Uno\\Prism.DryIoc.Uno.WinUI.csproj",
"src\\Uno\\Prism.Uno\\Prism.Uno.WinUI.csproj",
- "tests\\Containers\\Prism.Container.DryIoc.Tests\\Prism.Ioc.DryIoc.Tests.csproj",
- "tests\\Containers\\Prism.Container.Shared\\Prism.Ioc.Shared.shproj",
- "tests\\Containers\\Prism.Container.Unity.Tests\\Prism.Ioc.Unity.Tests.csproj",
"tests\\Prism.Core.Tests\\Prism.Core.Tests.csproj"
]
}
diff --git a/PrismLibrary_Wpf.slnf b/PrismLibrary_Wpf.slnf
index b988d35c28..8ff6843d98 100644
--- a/PrismLibrary_Wpf.slnf
+++ b/PrismLibrary_Wpf.slnf
@@ -2,16 +2,11 @@
"solution": {
"path": "PrismLibrary.sln",
"projects": [
- "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj",
- "src\\Containers\\Prism.Unity.Shared\\Prism.Unity.Shared.shproj",
"src\\Prism.Core\\Prism.Core.csproj",
"src\\Prism.Events\\Prism.Events.csproj",
"src\\Wpf\\Prism.DryIoc.Wpf\\Prism.DryIoc.Wpf.csproj",
"src\\Wpf\\Prism.Unity.Wpf\\Prism.Unity.Wpf.csproj",
"src\\Wpf\\Prism.Wpf\\Prism.Wpf.csproj",
- "tests\\Containers\\Prism.Container.DryIoc.Tests\\Prism.Ioc.DryIoc.Tests.csproj",
- "tests\\Containers\\Prism.Container.Shared\\Prism.Ioc.Shared.shproj",
- "tests\\Containers\\Prism.Container.Unity.Tests\\Prism.Ioc.Unity.Tests.csproj",
"tests\\Prism.Core.Tests\\Prism.Core.Tests.csproj",
"tests\\Wpf\\Prism.Container.Wpf.Shared\\Prism.Container.Wpf.Shared.shproj",
"tests\\Wpf\\Prism.DryIoc.Wpf.Tests\\Prism.DryIoc.Wpf.Tests.csproj",
diff --git a/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs b/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs
deleted file mode 100644
index 666f2539d9..0000000000
--- a/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs
+++ /dev/null
@@ -1,452 +0,0 @@
-using System;
-using System.Linq;
-using DryIoc;
-using Prism.Ioc;
-using Prism.Ioc.Internals;
-using ExceptionExtensions = System.ExceptionExtensions;
-using IContainer = DryIoc.IContainer;
-
-namespace Prism.DryIoc
-{
- ///
- /// The Implementation to use with DryIoc
- ///
-#if ContainerExtensions
- internal
-#else
- public
-#endif
- partial 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(DefaultRules)
- {
- }
-
- public DryIocContainerExtension(Rules rules)
- : this(new Container(rules))
- {
- }
-
- ///
- /// 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
diff --git a/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs b/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs
index d05ba65958..9e2e9fdc89 100644
--- a/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs
+++ b/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs
@@ -1,4 +1,5 @@
using DryIoc;
+using Prism.Container.DryIoc;
using Prism.Ioc;
using Xamarin.Forms.Internals;
@@ -40,7 +41,7 @@ protected PrismApplication(IPlatformInitializer platformInitializer, bool setFor
///
protected override IContainerExtension CreateContainerExtension()
{
- return new DryIocContainerExtension(new Container(CreateContainerRules()));
+ return new DryIocContainerExtension(CreateContainerRules());
}
///
diff --git a/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs b/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
index 382090704d..ea20dea231 100644
--- a/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
+++ b/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
@@ -843,7 +843,7 @@ protected virtual Page CreatePage(string segmentName)
}
catch (Exception ex)
{
- if (((IContainerRegistry)_container).IsRegistered(segmentName))
+ if (_container.IsRegistered(segmentName))
throw new NavigationException(NavigationException.ErrorCreatingPage, _page, ex);
throw new NavigationException(NavigationException.NoPageIsRegistered, _page, ex);
diff --git a/src/Forms/Prism.Forms/PrismApplicationBase.cs b/src/Forms/Prism.Forms/PrismApplicationBase.cs
index 3a8d2881af..3af9466821 100644
--- a/src/Forms/Prism.Forms/PrismApplicationBase.cs
+++ b/src/Forms/Prism.Forms/PrismApplicationBase.cs
@@ -140,15 +140,21 @@ private INavigationService CreateNavigationService(object view)
///
protected virtual void Initialize()
{
- ContainerLocator.SetContainerExtension(CreateContainerExtension);
+ var initialize = ContainerLocator.TrySetContainerExtension(CreateContainerExtension());
_containerExtension = ContainerLocator.Current;
- RegisterRequiredTypes(_containerExtension);
- PlatformInitializer?.RegisterTypes(_containerExtension);
- RegisterTypes(_containerExtension);
- _containerExtension.FinalizeExtension();
+ if (initialize)
+ {
+ RegisterRequiredTypes(_containerExtension);
+ PlatformInitializer?.RegisterTypes(_containerExtension);
+ RegisterTypes(_containerExtension);
+
+ _containerExtension.FinalizeExtension();
+
+ _moduleCatalog = Container.Resolve();
+ ConfigureModuleCatalog(_moduleCatalog);
+ }
- _moduleCatalog = Container.Resolve();
- ConfigureModuleCatalog(_moduleCatalog);
+ _moduleCatalog ??= Container.Resolve();
_containerExtension.CreateScope();
NavigationService = _containerExtension.Resolve();
diff --git a/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj b/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj
index 353e7ab0c3..d29862b2e2 100644
--- a/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj
+++ b/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj
@@ -11,13 +11,11 @@
-
+
-
-
diff --git a/src/Forms/Prism.Unity.Forms/PrismApplication.cs b/src/Forms/Prism.Unity.Forms/PrismApplication.cs
index f15c57c7ca..d13880ad1a 100644
--- a/src/Forms/Prism.Unity.Forms/PrismApplication.cs
+++ b/src/Forms/Prism.Unity.Forms/PrismApplication.cs
@@ -1,4 +1,5 @@
-using Prism.Ioc;
+using Prism.Container.Unity;
+using Prism.Ioc;
using Unity;
[assembly: Xamarin.Forms.XmlnsDefinition("http://prismlibrary.com", "Prism.Unity")]
diff --git a/src/Maui/Prism.DryIoc.Maui/DryIocContainerExtension.cs b/src/Maui/Prism.DryIoc.Maui/DryIocContainerExtension.cs
deleted file mode 100644
index b0dbe4c33a..0000000000
--- a/src/Maui/Prism.DryIoc.Maui/DryIocContainerExtension.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using DryIoc;
-using Prism.Ioc;
-using IContainer = DryIoc.IContainer;
-
-namespace Prism.DryIoc;
-
-partial class DryIocContainerExtension : IServiceCollectionAware
-{
- public IServiceProvider CreateServiceProvider()
- {
- var capabilities = new DryIocServiceProviderCapabilities(Instance);
- var singletons = Instance.SingletonScope;
- singletons.Use(capabilities);
- singletons.Use(capabilities);
- singletons.UseFactory(r => new DryIocServiceScopeFactory(r));
-
- return Instance;
- }
-
- public void Populate(IServiceCollection services)
- {
- foreach (var descriptor in services)
- RegisterDescriptor(Instance, descriptor);
-
- var errors = Instance.Validate();
- }
-
- static IReuse ToReuse(ServiceLifetime lifetime) =>
- lifetime == ServiceLifetime.Singleton ? Reuse.Singleton :
- lifetime == ServiceLifetime.Scoped ? Reuse.ScopedOrSingleton : // see, that we have Reuse.ScopedOrSingleton here instead of Reuse.Scoped
- Reuse.Transient;
-
- static void RegisterDescriptor(IContainer container, ServiceDescriptor descriptor)
- {
- var serviceType = descriptor.ServiceType;
- var implType = descriptor.ImplementationType;
- if (implType != null)
- {
- container.Register(ReflectionFactory.Of(implType, ToReuse(descriptor.Lifetime)), serviceType,
- null, null, isStaticallyChecked: implType == serviceType);
- }
- else if (descriptor.ImplementationFactory != null)
- {
- container.Register(DelegateFactory.Of(descriptor.ImplementationFactory.ToFactoryDelegate, ToReuse(descriptor.Lifetime)), serviceType,
- null, null, isStaticallyChecked: true);
- }
- else
- {
- var instance = descriptor.ImplementationInstance;
- container.Register(InstanceFactory.Of(instance), serviceType,
- null, null, isStaticallyChecked: true);
- container.TrackDisposable(instance);
- }
- }
-}
diff --git a/src/Maui/Prism.DryIoc.Maui/DryIocServiceProviderCapabilities.cs b/src/Maui/Prism.DryIoc.Maui/DryIocServiceProviderCapabilities.cs
deleted file mode 100644
index 5919f6e1a4..0000000000
--- a/src/Maui/Prism.DryIoc.Maui/DryIocServiceProviderCapabilities.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using DryIoc;
-using Prism.Ioc;
-using IContainer = DryIoc.IContainer;
-
-namespace Prism.DryIoc;
-
-internal sealed class DryIocServiceProviderCapabilities : IServiceProviderIsService, ISupportRequiredService
-{
- private readonly IContainer _container;
- /// Statefully wraps the passed
- public DryIocServiceProviderCapabilities(IContainer container) => _container = container;
-
- ///
- public bool IsService(Type serviceType)
- {
- // I am not fully comprehend but MS.DI considers asking for the open-generic type even if it is registered to return `false`
- // Probably mixing here the fact that open type cannot be instantiated without providing the concrete type argument.
- // But I think it is conflating two things and making the reasoning harder.
- if (serviceType.IsGenericTypeDefinition)
- return false;
-
- if (serviceType == typeof(IServiceProviderIsService) ||
- serviceType == typeof(ISupportRequiredService) ||
- serviceType == typeof(IServiceScopeFactory))
- return true;
-
- if (_container.IsRegistered(serviceType))
- return true;
-
- if (serviceType.IsGenericType &&
- _container.IsRegistered(serviceType.GetGenericTypeDefinition()))
- return true;
-
- return _container.IsRegistered(serviceType, factoryType: FactoryType.Wrapper);
- }
-
- ///
- public object GetRequiredService(Type serviceType) => _container.Resolve(serviceType);
-}
diff --git a/src/Maui/Prism.DryIoc.Maui/DryIocServiceScope.cs b/src/Maui/Prism.DryIoc.Maui/DryIocServiceScope.cs
deleted file mode 100644
index 075aadb1a4..0000000000
--- a/src/Maui/Prism.DryIoc.Maui/DryIocServiceScope.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using DryIoc;
-
-namespace Prism.DryIoc;
-
-internal sealed class DryIocServiceScope : IServiceScope
-{
- ///
- public IServiceProvider ServiceProvider => _resolverContext;
- private readonly IResolverContext _resolverContext;
-
- /// Creating from resolver context
- public DryIocServiceScope(IResolverContext resolverContext) => _resolverContext = resolverContext;
-
- /// Disposes the underlying resolver context
- public void Dispose() => _resolverContext.Dispose();
-}
diff --git a/src/Maui/Prism.DryIoc.Maui/DryIocServiceScopeFactory.cs b/src/Maui/Prism.DryIoc.Maui/DryIocServiceScopeFactory.cs
deleted file mode 100644
index 1c67610773..0000000000
--- a/src/Maui/Prism.DryIoc.Maui/DryIocServiceScopeFactory.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using DryIoc;
-
-namespace Prism.DryIoc;
-
-internal sealed class DryIocServiceScopeFactory : IServiceScopeFactory
-{
- private readonly IResolverContext _scopedResolver;
-
- /// Stores passed scoped container to open nested scope.
- /// Scoped container to be used to create nested scope.
- public DryIocServiceScopeFactory(IResolverContext scopedResolver) => _scopedResolver = scopedResolver;
-
- /// Opens scope and wraps it into DI interface.
- /// DI wrapper of opened scope.
- public IServiceScope CreateScope()
- {
- var r = _scopedResolver;
- var scope = r.ScopeContext == null
- ? Scope.Of(r.OwnCurrentScope)
- : r.ScopeContext.SetCurrent(p => Scope.Of(p));
- return new DryIocServiceScope(r.WithCurrentScope(scope));
- }
-}
diff --git a/src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj b/src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj
index c57e3b3fde..d52263e4b3 100644
--- a/src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj
+++ b/src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj
@@ -9,7 +9,7 @@
-
+
@@ -18,6 +18,4 @@
-
-
diff --git a/src/Maui/Prism.DryIoc.Maui/PrismAppExtensions.cs b/src/Maui/Prism.DryIoc.Maui/PrismAppExtensions.cs
index 37754f8285..a43dda8558 100644
--- a/src/Maui/Prism.DryIoc.Maui/PrismAppExtensions.cs
+++ b/src/Maui/Prism.DryIoc.Maui/PrismAppExtensions.cs
@@ -1,6 +1,5 @@
using DryIoc;
using Prism;
-using Prism.DryIoc;
namespace Microsoft.Maui;
diff --git a/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
index 7a947be2e2..4827e91821 100644
--- a/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
@@ -2,6 +2,9 @@
namespace Prism.Ioc;
+///
+/// Provides extensions for registering Behaviors to add to pages.
+///
public static class BehaviorFactoryRegistrationExtensions
{
///
@@ -52,18 +55,45 @@ public static IContainerRegistry RegisterPageBehavior(this ICo
p.Behaviors.Add(c.Resolve());
});
+ ///
+ /// Registers an delegate to execute on a given Page instance. This could apply a
+ /// or it could add attached properties such Platform Specifics.
+ ///
+ /// The .
+ /// The delegate action to perform on the .
+ /// The .
public static IServiceCollection RegisterPageBehaviorFactory(this IServiceCollection services, Action pageBehaviorFactory) =>
services.AddSingleton(new DelegatePageBehaviorFactory(pageBehaviorFactory));
+ ///
+ /// Registers an delegate to execute on a given Page instance. This could apply a
+ /// or it could add attached properties such Platform Specifics.
+ ///
+ /// The .
+ /// The delegate action to perform on the .
+ /// The .
public static IServiceCollection RegisterPageBehaviorFactory(this IServiceCollection services, Action pageBehaviorFactory) =>
services.AddScoped(c => new DelegateContainerPageBehaviorFactory(pageBehaviorFactory, c.GetRequiredService()));
+ ///
+ /// Registers a given for all Pages.
+ ///
+ /// The type.
+ /// The .
+ /// The .
public static IServiceCollection RegisterPageBehavior(this IServiceCollection services)
where TBehavior : Behavior =>
services
.AddTransient()
.RegisterPageBehaviorFactory((c, p) => p.Behaviors.Add(c.Resolve()));
+ ///
+ /// Registers a given for the specified type of
+ ///
+ /// The type.
+ /// The type.
+ /// The .
+ /// The .
public static IServiceCollection RegisterPageBehavior(this IServiceCollection services)
where TPage : Page
where TBehavior : Behavior =>
diff --git a/src/Maui/Prism.Maui/Ioc/IServiceCollectionAware.cs b/src/Maui/Prism.Maui/Ioc/IServiceCollectionAware.cs
deleted file mode 100644
index 2d6ccfc895..0000000000
--- a/src/Maui/Prism.Maui/Ioc/IServiceCollectionAware.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Prism.Ioc;
-
-public interface IServiceCollectionAware
-{
- void Populate(IServiceCollection services);
- IServiceProvider CreateServiceProvider();
-}
diff --git a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
index ddacf64132..b714514cdf 100644
--- a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
@@ -2,24 +2,14 @@
namespace Prism.Ioc;
+///
+/// Navigation Extensions for working with the
+///
public static class MicrosoftDependencyInjectionExtensions
{
- public static void Populate(this IContainerExtension container, IServiceCollection services)
- {
- if (container is not IServiceCollectionAware sca)
- throw new InvalidOperationException("The instance of IContainerExtension does not implement IServiceCollectionAware");
-
- sca.Populate(services);
- }
-
- public static IServiceProvider CreateServiceProvider(this IContainerExtension container)
- {
- if (container is not IServiceCollectionAware sca)
- throw new InvalidOperationException("The instance of IContainerExtension does not implement IServiceCollectionAware");
-
- return sca.CreateServiceProvider();
- }
#if !UNO_WINUI_PROJECT
+ private static readonly Type PageType = typeof(Page);
+
public static IServiceCollection RegisterForNavigation(this IServiceCollection services, string name = null)
where TView : Page =>
services.RegisterForNavigation(typeof(TView), null, name);
@@ -33,6 +23,9 @@ public static IServiceCollection RegisterForNavigation(this IServiceCollection s
if (view is null)
throw new ArgumentNullException(nameof(view));
+ if (!view.IsAssignableTo(PageType))
+ throw new InvalidOperationException($"The view type '{view.FullName}' is not a type of Page.");
+
if (string.IsNullOrEmpty(name))
name = view.Name;
diff --git a/src/Maui/Prism.Maui/Ioc/PrismServiceProviderFactory.cs b/src/Maui/Prism.Maui/Ioc/PrismServiceProviderFactory.cs
deleted file mode 100644
index a8af18c28e..0000000000
--- a/src/Maui/Prism.Maui/Ioc/PrismServiceProviderFactory.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace Prism.Ioc;
-
-public class PrismServiceProviderFactory : IServiceProviderFactory
-{
- private Action _registerTypes { get; }
-
- public PrismServiceProviderFactory(Action registerTypes)
- {
- _registerTypes = registerTypes;
- }
-
- public IContainerExtension CreateBuilder(IServiceCollection services)
- {
- var container = ContainerLocator.Current;
- container.Populate(services);
- _registerTypes(container);
-
- return container;
- }
-
- public IServiceProvider CreateServiceProvider(IContainerExtension containerExtension)
- {
- return containerExtension.CreateServiceProvider();
- }
-}
diff --git a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
index 87c0f29f03..f7d0b49e40 100644
--- a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
+++ b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
@@ -2,7 +2,6 @@
using System.Web;
using Prism.Common;
using Prism.Events;
-using Prism.Ioc;
using Prism.Mvvm;
using Application = Microsoft.Maui.Controls.Application;
using XamlTab = Prism.Navigation.Xaml.TabbedPage;
diff --git a/src/Maui/Prism.Maui/PrismAppBuilder.cs b/src/Maui/Prism.Maui/PrismAppBuilder.cs
index 6dcaa4bb5b..7a2143e6d8 100644
--- a/src/Maui/Prism.Maui/PrismAppBuilder.cs
+++ b/src/Maui/Prism.Maui/PrismAppBuilder.cs
@@ -5,7 +5,6 @@
using Prism.Controls;
using Prism.Dialogs;
using Prism.Events;
-using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
using Prism.Navigation;
@@ -77,7 +76,7 @@ internal PrismAppBuilder(IContainerExtension containerExtension, MauiAppBuilder
});
ContainerLocator.ResetContainer();
- ContainerLocator.SetContainerExtension(() => containerExtension);
+ ContainerLocator.SetContainerExtension(containerExtension);
containerExtension.RegisterInstance(this);
containerExtension.RegisterSingleton();
@@ -85,6 +84,9 @@ internal PrismAppBuilder(IContainerExtension containerExtension, MauiAppBuilder
ConfigureViewModelLocator();
}
+ ///
+ /// Gets the associated .
+ ///
public MauiAppBuilder MauiBuilder { get; }
private void ConfigureViewModelLocator()
@@ -117,12 +119,22 @@ internal static object DefaultViewModelLocator(object view, Type viewModelType)
}
}
+ ///
+ /// Provides a Delegate to register services with the
+ ///
+ /// The delegate to register your services.
+ /// The .
public PrismAppBuilder RegisterTypes(Action registerTypes)
{
_registrations.Add(registerTypes);
return this;
}
+ ///
+ /// Provides a Delegate to invoke when the App is initialized.
+ ///
+ /// The delegate to invoke.
+ /// The .
public PrismAppBuilder OnInitialized(Action action)
{
_initializations.Add(action);
@@ -176,6 +188,12 @@ internal void OnAppStarted()
onStart.Wait();
}
+ ///
+ /// When the is started and the native platform calls
+ /// this delegate will be invoked to do your initial Navigation.
+ ///
+ /// The Navigation Delegate.
+ /// The .
public PrismAppBuilder OnAppStart(Func onAppStarted)
{
_onAppStarted = onAppStarted;
@@ -206,12 +224,22 @@ private void RegistrationCallback(IContainerExtension container)
_registrations.ForEach(action => action(container));
}
+ ///
+ /// Configures for Region Navigation with the .
+ ///
+ /// Delegate to configure the .
+ /// The .
public PrismAppBuilder ConfigureRegionAdapters(Action configureMappings)
{
_configureAdapters = configureMappings;
return this;
}
+ ///
+ /// Configures the .
+ ///
+ /// Delegate to configure the .
+ /// The .
public PrismAppBuilder ConfigureRegionBehaviors(Action configureBehaviors)
{
_configureBehaviors = configureBehaviors;
diff --git a/src/Prism.Core/Extensions/ExceptionExtensions.cs b/src/Prism.Core/Extensions/ExceptionExtensions.cs
deleted file mode 100644
index daa655bd2b..0000000000
--- a/src/Prism.Core/Extensions/ExceptionExtensions.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System.Collections.Generic;
-
-namespace System
-{
- ///
- /// Class that provides extension methods for the Exception class. These extension methods provide
- /// a mechanism for developers to get more easily to the root cause of an exception, especially in combination with
- /// DI-containers such as Unity.
- ///
- public static class ExceptionExtensions
- {
- private static List frameworkExceptionTypes = new List();
-
- ///
- /// Register the type of an Exception that is thrown by the framework. The method uses
- /// this list of Exception types to find out if something has gone wrong.
- ///
- /// The type of exception to register.
- public static void RegisterFrameworkExceptionType(Type frameworkExceptionType)
- {
- if (frameworkExceptionType == null) throw new ArgumentNullException(nameof(frameworkExceptionType));
-
- if (!frameworkExceptionTypes.Contains(frameworkExceptionType))
- frameworkExceptionTypes.Add(frameworkExceptionType);
- }
-
-
- ///
- /// Determines whether the exception type is already registered using the
- /// method
- ///
- /// The type of framework exception to find.
- ///
- /// true if the exception type is already registered; otherwise, false.
- ///
- public static bool IsFrameworkExceptionRegistered(Type frameworkExceptionType)
- {
- return frameworkExceptionTypes.Contains(frameworkExceptionType);
- }
-
- ///
- /// Looks at all the inner exceptions of the parameter to find the
- /// most likely root cause of the exception. This works by skipping all registered exception types.
- ///
- ///
- /// This method is not 100% accurate and should only be used to point a developer into the most likely direction.
- /// It should not be used to replace the Inner Exception stack of an exception, because this might hide required exception
- /// information.
- ///
- /// The exception that will provide the list of inner exceptions to examine.
- ///
- /// The exception that most likely caused the exception to occur. If it can't find the root exception, it will return the
- /// value itself.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We have to catch exception. This method is used in exception handling code, so it must not fail.")]
- public static Exception GetRootException(this Exception exception)
- {
- Exception rootException = exception;
-
- try
- {
- while (true)
- {
- if (rootException == null)
- {
- rootException = exception;
- break;
- }
-
- if (!IsFrameworkException(rootException))
- {
- break;
- }
- rootException = rootException.InnerException;
- }
- }
- catch (Exception)
- {
- rootException = exception;
- }
- return rootException;
- }
-
- private static bool IsFrameworkException(Exception exception)
- {
- bool isFrameworkException = frameworkExceptionTypes.Contains(exception.GetType());
- bool childIsFrameworkException = false;
-
- if (exception.InnerException != null)
- {
- childIsFrameworkException = frameworkExceptionTypes.Contains(exception.InnerException.GetType());
- }
-
- return isFrameworkException || childIsFrameworkException;
- }
- }
-}
diff --git a/src/Prism.Core/Ioc/ContainerLocator.cs b/src/Prism.Core/Ioc/ContainerLocator.cs
deleted file mode 100644
index 65b3f3a866..0000000000
--- a/src/Prism.Core/Ioc/ContainerLocator.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace Prism.Ioc
-{
- ///
- /// The tracks the current instance of the Container used by your Application
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static class ContainerLocator
- {
- private static Lazy _lazyContainer;
-
- private static IContainerExtension _current;
-
- ///
- /// Gets the current .
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static IContainerExtension Current =>
- _current ?? (_current = _lazyContainer?.Value);
-
- ///
- /// Gets the
- ///
- public static IContainerProvider Container =>
- Current;
-
- ///
- /// Sets the Container Factory to use if the Current is null
- ///
- ///
- ///
- /// NOTE: We want to use Lazy Initialization in case the container is first created
- /// prior to Prism initializing which could be the case with Shiny
- ///
- public static void SetContainerExtension(Func factory) =>
- _lazyContainer = new Lazy(factory);
-
- ///
- /// Used for Testing to Reset the Current Container
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void ResetContainer()
- {
- _current = null;
- _lazyContainer = null;
- }
- }
-}
diff --git a/src/Prism.Core/Ioc/ContainerResolutionErrorCollection.cs b/src/Prism.Core/Ioc/ContainerResolutionErrorCollection.cs
deleted file mode 100644
index c4148425cf..0000000000
--- a/src/Prism.Core/Ioc/ContainerResolutionErrorCollection.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Prism.Ioc
-{
- ///
- /// A collection of Errors encountered by while attempting to resolve a given type.
- ///
- public sealed class ContainerResolutionErrorCollection : IEnumerable>
- {
- private readonly List> _errors = new List>();
-
- internal void Add(Type type, Exception exception) =>
- _errors.Add(new KeyValuePair(type, exception));
-
- ///
- /// Provides a list of 's affected.
- ///
- ///
- /// This could include for Registered View's
- ///
- public IEnumerable Types => _errors.Select(x => x.Key).Distinct();
-
- IEnumerator> IEnumerable>.GetEnumerator() =>
- _errors.GetEnumerator();
-
- IEnumerator IEnumerable.GetEnumerator() =>
- _errors.GetEnumerator();
- }
-}
diff --git a/src/Prism.Core/Ioc/ContainerResolutionException.cs b/src/Prism.Core/Ioc/ContainerResolutionException.cs
deleted file mode 100644
index 4f16d0289f..0000000000
--- a/src/Prism.Core/Ioc/ContainerResolutionException.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Reflection;
-using Prism.Ioc.Internals;
-
-namespace Prism.Ioc
-{
- ///
- /// Provides a common exception class to be used by when encountering a resolution exception
- ///
- [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "The ContainerResolutionException is a specialized Exception to debug issues resolving services.")]
- public class ContainerResolutionException : Exception
- {
- ///
- /// The message provided by when no registration was found with the container
- ///
- public const string MissingRegistration = "No Registration was found in the container for the specified type";
-
- ///
- /// The message provided by when the implementing type is abstract
- ///
- public const string CannotResolveAbstractType = "The Implementing Type is abstract.";
-
- ///
- /// The message provided by when multiple constructors were found in the implementing type
- ///
- public const string MultipleConstructors = "The Implementing Type has multiple constructors which may not be resolvable";
-
- ///
- /// The message provided by when no public constructors were found in the implementing type
- ///
- public const string NoPublicConstructors = "The Implementing Type has no public constructors which cause issues with the type being resolved.";
-
- ///
- /// The message provided by when no public constructors were found in the implementing type
- ///
- public const string CyclicalDependency = "A cyclical dependency was detected. Type A requires an instance of Type A.";
-
- ///
- /// The message provided by when we have no clue why the container failed.
- ///
- ///
- /// Please file an issue with the Prism team if you encounter a ContainerResolutionException with this message
- ///
- public const string UnknownError = "You seem to have hit an edge case. Please file an issue with the Prism team along with a duplication.";
-
- private IContainerProvider _instance { get; }
- ///
- /// Creates a new instance of the
- ///
- /// The failed Service that was attempted to be resolved.
- /// The actual thrown by the Container.
- /// The instance of the container that was used to resolve the service type.
- public ContainerResolutionException(Type serviceType, Exception innerException, IContainerProvider instance)
- : this(serviceType, null, innerException, instance)
- {
- }
-
- ///
- /// Creates a new instance of the
- ///
- /// The failed Service that was attempted to be resolved.
- /// The Service Name/Key used to resolve the Service Type.
- /// The actual thrown by the Container.
- /// The instance of the container that was used to resolve the service type.
- public ContainerResolutionException(Type serviceType, string serviceName, Exception innerException, IContainerProvider instance)
- : base(GetErrorMessage(serviceType, serviceName), innerException)
- {
- _instance = instance;
- ServiceType = serviceType;
- ServiceName = serviceName;
- }
-
- // Used by GetErrors()
- private ContainerResolutionException(Type serviceType, string message, IContainerProvider instance)
- : base(message)
- {
- _instance = instance;
- ServiceType = serviceType;
- }
-
- ///
- /// Gets the ServiceType
- ///
- public Type ServiceType { get; }
-
- ///
- /// Gets the Service Key if one was used to resolve the ServiceType
- ///
- ///
- /// This is most commonly the key used to resolve a View for Navigation.
- ///
- public string ServiceName { get; }
-
- private bool IsKnownIssue
- {
- get
- {
- switch (Message)
- {
- // Be sure to add any constants here as new use cases emerge.
- case MissingRegistration:
- case CannotResolveAbstractType:
- case MultipleConstructors:
- case NoPublicConstructors:
- case CyclicalDependency:
- case UnknownError:
- return true;
- default:
- return false;
- }
- }
- }
-
- ///
- /// Gets a Dictionary of errors and their corresponding types to help diagnose possible issues
- /// that resulted in the ContainerResolutionException.
- ///
- /// A mapping types that encountered given exceptions in the resolution process.
- public ContainerResolutionErrorCollection GetErrors()
- {
- var errors = new ContainerResolutionErrorCollection();
- if (IsKnownIssue)
- {
- return errors;
- }
-
- var implementingType = TryFindImplementingType();
- if (implementingType is null)
- {
- errors.Add(ServiceType, new ContainerResolutionException(ServiceType, MissingRegistration, _instance));
- return errors;
- }
- else if (implementingType.IsAbstract)
- {
- errors.Add(ServiceType, new ContainerResolutionException(implementingType, CannotResolveAbstractType, _instance));
- }
-
- PopulateErrors(implementingType, ref errors);
- return errors;
- }
-
- private Type TryFindImplementingType()
- {
- var name = ServiceName;
-
- // A ViewModel generally isn't directly registered with the container
- // as a result we want to provide the ServiceType when it's a concrete type.
- var defaultValue = IsConcreteType(ServiceType) ? ServiceType : null;
- if (string.IsNullOrEmpty(name))
- {
- if (!_instance.IsRegistered(ServiceType))
- {
- return defaultValue;
- }
-
- // RegistrationType must be retrieved from the Root Container
- return ContainerLocator.Current.GetRegistrationType(ServiceType);
- }
- else if (!_instance.IsRegistered(ServiceType, ServiceName))
- {
- return defaultValue;
- }
-
- // RegistrationType must be retrieved from the Root Container
- return ContainerLocator.Current.GetRegistrationType(name);
- }
-
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "This method is meant to collect any exception thrown.")]
- private void PopulateErrors(Type implementingType, ref ContainerResolutionErrorCollection errors)
- {
- var ctors = implementingType.GetConstructors();
-
- if (ctors.Length > 1)
- {
- errors.Add(implementingType, new ContainerResolutionException(implementingType, MultipleConstructors, _instance));
- }
- else if (ctors.Length == 0)
- {
- errors.Add(implementingType, new ContainerResolutionException(implementingType, NoPublicConstructors, _instance));
- return;
- }
-
- var ctor = ctors.OrderByDescending(x => x.GetParameters().Length).FirstOrDefault();
- var parameters = ctor.GetParameters();
- var parameterInstances = new List();
- foreach (var parameter in parameters)
- {
- try
- {
- var defaultImplementingType = IsConcreteType(parameter.ParameterType) ? parameter.ParameterType : null;
-
- // RegistrationType must be retrieved from the Root Container
- var parameterImplementingType = ContainerLocator.Current.GetRegistrationType(parameter.ParameterType);
- if (parameterImplementingType is null)
- throw new ContainerResolutionException(parameter.ParameterType, MissingRegistration, _instance);
-
- var instance = _instance.Resolve(parameter.ParameterType);
- parameterInstances.Add(instance);
- }
- catch (Exception ex)
- {
- // TODO: Add Exceptions Extensions lookup here to get root Exception
- errors.Add(parameter.ParameterType, ex);
- if (ex is ContainerResolutionException cre && !cre.IsKnownIssue)
- {
- foreach (var subError in cre.GetErrors())
- {
- errors.Add(subError.Key, subError.Value);
- }
- }
- }
- }
-
- // Return if we had an error with any children
- if (parameters.Length != parameterInstances.Count)
- return;
-
- try
- {
- // We generally expect some sort of InvocationException Exception here...
- ctor.Invoke(parameterInstances.ToArray());
-
- // If we managed to create an instance for every parameter and the
- // constructor didn't throw an exception when activating the instance
- // we really aren't sure what allowed us to get here...
- throw new ContainerResolutionException(implementingType, UnknownError, _instance);
- }
- catch (TargetInvocationException tie)
- {
- errors.Add(implementingType, tie);
-
- if (tie.InnerException != null)
- errors.Add(implementingType, tie.InnerException);
- }
- catch (Exception ex)
- {
- errors.Add(implementingType, ex);
- }
- }
-
- private static bool IsConcreteType(Type type)
- {
- if (type.IsAbstract || type.IsEnum || type.IsPrimitive || type == typeof(object))
- return false;
-
- return true;
- }
-
- private static string GetErrorMessage(Type type, string name)
- {
- var message = $"An unexpected error occurred while resolving '{type.FullName}'";
- if (!string.IsNullOrEmpty(name))
- message += $", with the service name '{name}'";
-
- return message;
- }
- }
-}
diff --git a/src/Prism.Core/Ioc/IContainerExtension.cs b/src/Prism.Core/Ioc/IContainerExtension.cs
deleted file mode 100644
index 48983b53bf..0000000000
--- a/src/Prism.Core/Ioc/IContainerExtension.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace Prism.Ioc
-{
- ///
- /// A strongly typed container extension
- ///
- /// The underlying root container
- public interface IContainerExtension : IContainerExtension
- {
- ///
- /// The instance of the wrapped container
- ///
- TContainer Instance { get; }
- }
-
- ///
- /// A generic abstraction for what Prism expects from a container
- ///
- public interface IContainerExtension : IContainerProvider, IContainerRegistry
- {
- ///
- /// Used to perform any final steps for configuring the extension that may be required by the container.
- ///
- void FinalizeExtension();
- }
-}
diff --git a/src/Prism.Core/Ioc/IContainerProvider.cs b/src/Prism.Core/Ioc/IContainerProvider.cs
deleted file mode 100644
index 5fbd036a9a..0000000000
--- a/src/Prism.Core/Ioc/IContainerProvider.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-
-namespace Prism.Ioc
-{
- ///
- /// Resolves Services from the Container
- ///
- public interface IContainerProvider
- {
- ///
- /// Resolves a given
- ///
- /// The service
- /// The resolved Service
- object Resolve(Type type);
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// Typed parameters to use when resolving the Service
- /// The resolved Service
- object Resolve(Type type, params (Type Type, object Instance)[] parameters);
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// The service name/key used when registering the
- /// The resolved Service
- object Resolve(Type type, string name);
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// The service name/key used when registering the
- /// Typed parameters to use when resolving the Service
- /// The resolved Service
- object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters);
-
- ///
- /// Creates a new scope
- ///
- IScopedProvider CreateScope();
-
- ///
- /// Gets the Current Scope
- ///
- IScopedProvider CurrentScope { get; }
- }
-}
diff --git a/src/Prism.Core/Ioc/IContainerProviderExtensions.cs b/src/Prism.Core/Ioc/IContainerProviderExtensions.cs
deleted file mode 100644
index 5a53c79934..0000000000
--- a/src/Prism.Core/Ioc/IContainerProviderExtensions.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-
-namespace Prism.Ioc
-{
- ///
- /// Provides Generic Type extensions for the
- ///
- public static class IContainerProviderExtensions
- {
- ///
- /// Resolves a given
- ///
- /// The service
- /// The current
- /// The resolved Service
- public static T Resolve(this IContainerProvider provider)
- {
- return (T)provider.Resolve(typeof(T));
- }
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// The current
- /// Typed parameters to use when resolving the Service
- /// The resolved Service
- public static T Resolve(this IContainerProvider provider, params (Type Type, object Instance)[] parameters)
- {
- return (T)provider.Resolve(typeof(T), parameters);
- }
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// The current
- /// The service name/key used when registering the
- /// Typed parameters to use when resolving the Service
- /// The resolved Service
- public static T Resolve(this IContainerProvider provider, string name, params (Type Type, object Instance)[] parameters)
- {
- return (T)provider.Resolve(typeof(T), name, parameters);
- }
-
- ///
- /// Resolves a given
- ///
- /// The service
- /// The current
- /// The service name/key used when registering the
- /// The resolved Service
- public static T Resolve(this IContainerProvider provider, string name)
- {
- return (T)provider.Resolve(typeof(T), name);
- }
-
- ///
- /// Determines if a given service is registered
- ///
- /// The service
- /// The instance of the
- /// true if the service is registered.
- public static bool IsRegistered(this IContainerProvider containerProvider)
- {
- return containerProvider.IsRegistered(typeof(T));
- }
-
- internal static bool IsRegistered(this IContainerProvider containerProvider, Type type)
- {
- if (containerProvider is IContainerRegistry containerRegistry)
- return containerRegistry.IsRegistered(type);
- return false;
- }
-
- ///
- /// Determines if a given service is registered with the specified name
- ///
- /// The service
- /// The instance of the
- /// The service name or key used
- /// true if the service is registered.
- public static bool IsRegistered(this IContainerProvider containerProvider, string name)
- {
- return containerProvider.IsRegistered(typeof(T), name);
- }
-
- internal static bool IsRegistered(this IContainerProvider containerProvider, Type type, string name)
- {
- if (containerProvider is IContainerRegistry containerRegistry)
- return containerRegistry.IsRegistered(type, name);
- return false;
- }
- }
-}
diff --git a/src/Prism.Core/Ioc/IContainerRegistry.cs b/src/Prism.Core/Ioc/IContainerRegistry.cs
deleted file mode 100644
index 90a4b99426..0000000000
--- a/src/Prism.Core/Ioc/IContainerRegistry.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-using System;
-
-namespace Prism.Ioc
-{
- ///
- /// The registering container
- ///
- public interface IContainerRegistry
- {
- ///
- /// Registers an instance of a given
- ///
- /// The service that is being registered
- /// The instance of the service or
- /// The instance
- IContainerRegistry RegisterInstance(Type type, object instance);
-
- ///
- /// 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
- IContainerRegistry RegisterInstance(Type type, object instance, string name);
-
- ///
- /// Registers a Singleton with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance
- IContainerRegistry RegisterSingleton(Type from, Type to);
-
- ///
- /// 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
- IContainerRegistry RegisterSingleton(Type from, Type to, string name);
-
- ///
- /// Registers a Singleton with the given service factory delegate method.
- ///
- /// The service
- /// The delegate method.
- /// The instance
- IContainerRegistry RegisterSingleton(Type type, Func factoryMethod);
-
- ///
- /// Registers a Singleton with the given service factory delegate method.
- ///
- /// The service
- /// The delegate method using .
- /// The instance
- IContainerRegistry RegisterSingleton(Type type, Func factoryMethod);
-
- ///
- /// Registers a Singleton Service which implements service interfaces
- ///
- /// The implementation .
- /// The service 's.
- /// The instance
- /// Registers all interfaces if none are specified.
- IContainerRegistry RegisterManySingleton(Type type, params Type[] serviceTypes);
-
- ///
- /// Registers a Transient with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance
- IContainerRegistry Register(Type from, Type to);
-
- ///
- /// 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
- IContainerRegistry Register(Type from, Type to, string name);
-
- ///
- /// Registers a Transient Service using a delegate method
- ///
- /// The service
- /// The delegate method.
- /// The instance
- IContainerRegistry Register(Type type, Func factoryMethod);
-
- ///
- /// Registers a Transient Service using a delegate method
- ///
- /// The service
- /// The delegate method using .
- /// The instance
- IContainerRegistry Register(Type type, Func factoryMethod);
-
- ///
- /// Registers a Transient Service which implements service interfaces
- ///
- /// The implementing .
- /// The service 's.
- /// The instance
- /// Registers all interfaces if none are specified.
- IContainerRegistry RegisterMany(Type type, params Type[] serviceTypes);
-
- ///
- /// Registers a scoped service
- ///
- /// The service
- /// The implementation
- /// The instance
- IContainerRegistry RegisterScoped(Type from, Type to);
-
- ///
- /// Registers a scoped service using a delegate method.
- ///
- /// The service
- /// The delegate method.
- /// The instance
- IContainerRegistry RegisterScoped(Type type, Func factoryMethod);
-
- ///
- /// Registers a scoped service using a delegate method.
- ///
- /// The service .
- /// The delegate method.
- /// The instance
- IContainerRegistry RegisterScoped(Type type, Func factoryMethod);
-
- ///
- /// Determines if a given service is registered
- ///
- /// The service
- /// true if the service is registered.
- bool IsRegistered(Type 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.
- bool IsRegistered(Type type, string name);
- }
-}
diff --git a/src/Prism.Core/Ioc/IContainerRegistryExtensions.cs b/src/Prism.Core/Ioc/IContainerRegistryExtensions.cs
deleted file mode 100644
index 18c57c5945..0000000000
--- a/src/Prism.Core/Ioc/IContainerRegistryExtensions.cs
+++ /dev/null
@@ -1,444 +0,0 @@
-using System;
-
-namespace Prism.Ioc
-{
- ///
- /// Provides Generic Type extensions for the
- ///
- public static class IContainerRegistryExtensions
- {
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegister(this IContainerRegistry containerRegistry, Type from, Type to)
- {
- if (!containerRegistry.IsRegistered(from))
- containerRegistry.Register(from, to);
-
- return containerRegistry;
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegister(this IContainerRegistry containerRegistry)
- where TTo : TFrom
- {
- return containerRegistry.TryRegister(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegister(this IContainerRegistry containerRegistry)
- where T : class
- {
- return containerRegistry.TryRegister(typeof(T), typeof(T));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterScoped(this IContainerRegistry containerRegistry, Type from, Type to)
- {
- if (!containerRegistry.IsRegistered(from))
- containerRegistry.RegisterScoped(from, to);
-
- return containerRegistry;
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterScoped(this IContainerRegistry containerRegistry)
- where T : class
- {
- return containerRegistry.TryRegisterScoped(typeof(T), typeof(T));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterScoped(this IContainerRegistry containerRegistry)
- where TTo : TFrom
- {
- return containerRegistry.TryRegisterScoped(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterSingleton(this IContainerRegistry containerRegistry, Type from, Type to)
- {
- if (!containerRegistry.IsRegistered(from))
- containerRegistry.RegisterSingleton(from, to);
-
- return containerRegistry;
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The implementation type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterSingleton(this IContainerRegistry containerRegistry)
- where TTo : TFrom
- {
- return containerRegistry.TryRegisterSingleton(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The .
- /// The .
- public static IContainerRegistry TryRegisterSingleton(this IContainerRegistry containerRegistry)
- where T : class
- {
- return containerRegistry.TryRegisterSingleton(typeof(T), typeof(T));
- }
-
- ///
- /// Will try to register the service if it has not already been registered
- ///
- /// The service type.
- /// The .
- /// An instance of the service.
- /// The .
- public static IContainerRegistry TryRegisterInstance(this IContainerRegistry containerRegistry, T instance)
- {
- if (!containerRegistry.IsRegistered())
- containerRegistry.RegisterInstance(instance);
-
- return containerRegistry;
- }
-
- ///
- /// Registers an instance of a given
- ///
- /// The service that is being registered
- /// The instance of the
- /// The instance of the service or
- /// The instance
- public static IContainerRegistry RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance)
- {
- return containerRegistry.RegisterInstance(typeof(TInterface), instance);
- }
-
- ///
- /// Registers an instance of a given with the specified name or key
- ///
- /// The service that is being registered
- /// The instance of the
- /// The instance of the service or
- /// The name or key to register the service
- /// The instance
- public static IContainerRegistry RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance, string name)
- {
- return containerRegistry.RegisterInstance(typeof(TInterface), instance, name);
- }
-
- ///
- /// Registers a Singleton with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, Type type)
- {
- return containerRegistry.RegisterSingleton(type, type);
- }
-
- ///
- /// Registers a Singleton with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance of the
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry) where TTo : TFrom
- {
- return containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Registers a Singleton with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance of the
- /// The name or key to register the service
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, string name) where TTo : TFrom
- {
- return containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo), name);
- }
-
- ///
- /// Registers a Singleton with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry)
- {
- return containerRegistry.RegisterSingleton(typeof(T));
- }
-
- ///
- /// Registers a Singleton with the given service factory delegate method.
- ///
- /// The service
- /// The instance of the
- /// The delegate method.
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.RegisterSingleton(typeof(T), factoryMethod);
- }
-
- ///
- /// Registers a Singleton with the given service factory delegate method.
- ///
- /// The service
- /// The instance of the
- /// The delegate method using .
- /// The instance
- public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.RegisterSingleton(typeof(T), factoryMethod);
- }
-
- ///
- /// Registers a Singleton Service which implements service interfaces
- ///
- /// The implementation .
- /// The instance of the
- /// The service 's.
- /// The instance
- /// Registers all interfaces if none are specified.
- public static IContainerRegistry RegisterManySingleton(this IContainerRegistry containerRegistry, params Type[] serviceTypes)
- {
- return containerRegistry.RegisterManySingleton(typeof(T), serviceTypes);
- }
-
- ///
- /// Registers a Transient with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Type type)
- {
- return containerRegistry.Register(type, type);
- }
-
- ///
- /// Registers a Transient with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry)
- {
- return containerRegistry.Register(typeof(T));
- }
-
- ///
- /// Registers a Transient with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The name or key to register the service
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Type type, string name)
- {
- return containerRegistry.Register(type, type, name);
- }
-
- ///
- /// Registers a Singleton with the given .
- ///
- /// The instance of the
- /// The concrete
- /// The name or key to register the service
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, string name)
- {
- return containerRegistry.Register(typeof(T), name);
- }
-
- ///
- /// Registers a Transient with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance of the
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry) where TTo : TFrom
- {
- return containerRegistry.Register(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Registers a Transient with the given service and mapping to the specified implementation .
- ///
- /// The service
- /// The implementation
- /// The instance of the
- /// The name or key to register the service
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, string name) where TTo : TFrom
- {
- return containerRegistry.Register(typeof(TFrom), typeof(TTo), name);
- }
-
- ///
- /// Registers a Transient Service using a delegate method
- ///
- /// The service
- /// The instance of the
- /// The delegate method.
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.Register(typeof(T), factoryMethod);
- }
-
- ///
- /// Registers a Transient Service using a delegate method
- ///
- /// The service
- /// The instance of the
- /// The delegate method using .
- /// The instance
- public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.Register(typeof(T), factoryMethod);
- }
-
- ///
- /// Registers a Transient Service which implements service interfaces
- ///
- /// The implementing
- /// The instance of the
- /// The service 's.
- /// The instance
- /// Registers all interfaces if none are specified.
- public static IContainerRegistry RegisterMany(this IContainerRegistry containerRegistry, params Type[] serviceTypes)
- {
- return containerRegistry.RegisterMany(typeof(T), serviceTypes);
- }
-
- ///
- /// Registers a scoped service.
- ///
- /// The instance of the
- /// The concrete .
- /// The instance
- public static IContainerRegistry RegisterScoped(this IContainerRegistry containerRegistry, Type type)
- {
- return containerRegistry.RegisterScoped(type, type);
- }
-
- ///
- /// Registers a scoped service.
- ///
- /// The service
- /// The instance of the
- /// The instance
- public static IContainerRegistry RegisterScoped(this IContainerRegistry containerRegistry)
- {
- return containerRegistry.RegisterScoped(typeof(T));
- }
-
- ///
- /// Registers a scoped service
- ///
- /// The service
- /// The implementation
- /// The instance of the
- /// The instance
- public static IContainerRegistry RegisterScoped(this IContainerRegistry containerRegistry)
- where TTo : TFrom
- {
- return containerRegistry.RegisterScoped(typeof(TFrom), typeof(TTo));
- }
-
- ///
- /// Registers a scoped service using a delegate method.
- ///
- /// The service
- /// The instance of the
- /// The delegate method.
- /// The instance
- public static IContainerRegistry RegisterScoped(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.RegisterScoped(typeof(T), factoryMethod);
- }
-
- ///
- /// Registers a scoped service using a delegate method.
- ///
- /// The service
- /// The instance of the
- /// The delegate method.
- /// The instance
- public static IContainerRegistry RegisterScoped(this IContainerRegistry containerRegistry, Func factoryMethod)
- {
- return containerRegistry.RegisterScoped(typeof(T), factoryMethod);
- }
-
- ///
- /// Determines if a given service is registered
- ///
- /// The service
- /// The instance of the
- /// true if the service is registered.
- public static bool IsRegistered(this IContainerRegistry containerRegistry)
- {
- return containerRegistry.IsRegistered(typeof(T));
- }
-
- ///
- /// Determines if a given service is registered with the specified name
- ///
- /// The service
- /// The instance of the
- /// The service name or key used
- /// true if the service is registered.
- public static bool IsRegistered(this IContainerRegistry containerRegistry, string name)
- {
- return containerRegistry.IsRegistered(typeof(T), name);
- }
- }
-}
diff --git a/src/Prism.Core/Ioc/IScopedProvider.cs b/src/Prism.Core/Ioc/IScopedProvider.cs
deleted file mode 100644
index bbf3dcc99c..0000000000
--- a/src/Prism.Core/Ioc/IScopedProvider.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-
-namespace Prism.Ioc
-{
- ///
- /// Defines a Container Scope
- ///
- public interface IScopedProvider : IContainerProvider, IDisposable
- {
- ///
- /// Gets or Sets the IsAttached property.
- ///
- ///
- /// Indicates that Prism is tracking the scope
- ///
- bool IsAttached { get; set; }
- }
-}
diff --git a/src/Prism.Core/Ioc/Internals/IContainerInfo.cs b/src/Prism.Core/Ioc/Internals/IContainerInfo.cs
deleted file mode 100644
index d61d78e90b..0000000000
--- a/src/Prism.Core/Ioc/Internals/IContainerInfo.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace Prism.Ioc.Internals
-{
- ///
- /// Used to resolve the registered implementation type for a given key
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public interface IContainerInfo
- {
- ///
- /// Locates the registered implementation for a give key
- ///
- /// Registration Key
- /// Implementation
- [EditorBrowsable(EditorBrowsableState.Never)]
- Type GetRegistrationType(string key);
-
- ///
- /// Locates the registered implementation for a give key
- ///
- /// Service Type
- /// Implementation
- [EditorBrowsable(EditorBrowsableState.Never)]
- Type GetRegistrationType(Type serviceType);
- }
-}
diff --git a/src/Prism.Core/Ioc/Internals/IContainerInfoExtensions.cs b/src/Prism.Core/Ioc/Internals/IContainerInfoExtensions.cs
deleted file mode 100644
index efb8939c2c..0000000000
--- a/src/Prism.Core/Ioc/Internals/IContainerInfoExtensions.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace Prism.Ioc.Internals
-{
- ///
- /// Internal extensions to get the registered implementation for Regions
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static class IContainerInfoExtensions
- {
- ///
- /// Locates the registered implementation for a give key
- ///
- /// The
- /// Registration Key
- /// Implementation
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static Type GetRegistrationType(this IContainerExtension container, string key)
- {
- if (container is IContainerInfo ci)
- return ci.GetRegistrationType(key);
-
- return null;
- }
-
- ///
- /// Locates the registered implementation for a give key
- ///
- /// The
- /// Service Type
- /// Implementation
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static Type GetRegistrationType(this IContainerExtension container, Type
- type)
- {
- if (container is IContainerInfo ci)
- return ci.GetRegistrationType(type);
-
- return null;
- }
- }
-}
diff --git a/src/Prism.Core/Prism.Core.csproj b/src/Prism.Core/Prism.Core.csproj
index 3fa161c74c..deb8534c3a 100644
--- a/src/Prism.Core/Prism.Core.csproj
+++ b/src/Prism.Core/Prism.Core.csproj
@@ -10,6 +10,10 @@
Prism is a fully open source version of the Prism guidance originally produced by Microsoft Patterns & Practices. Prism provides an implementation of a collection of design patterns that are helpful in writing well structured and maintainable XAML applications, including MVVM, dependency injection, commanding, event aggregation, and more. Prism's core functionality is a shared code base in a Portable Class Library targeting these platforms; WPF, and Xamarin Forms. Features that need to be platform specific are implemented in the respective libraries for the target platform.
prism;wpf;xamarin;dotnet maui;maui;uno;unoplatform;mvvm;xaml
+
+
+
+
diff --git a/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj b/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
index eab62a0b41..6138be3a48 100644
--- a/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
+++ b/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
@@ -34,6 +34,10 @@ Prism provides an implementation of a collection of design patterns that are hel
+
+
+
+
@@ -44,17 +48,7 @@ Prism provides an implementation of a collection of design patterns that are hel
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Uno/Prism.Uno/Ioc/PrismServiceProviderFactory.cs b/src/Uno/Prism.Uno/Ioc/PrismServiceProviderFactory.cs
deleted file mode 100644
index 3d2340438c..0000000000
--- a/src/Uno/Prism.Uno/Ioc/PrismServiceProviderFactory.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace Prism.Ioc;
-
-public class PrismServiceProviderFactory : IServiceProviderFactory
-{
- private readonly IContainerExtension _containerExtension;
- public PrismServiceProviderFactory(IContainerExtension containerExtension)
- {
- _containerExtension = containerExtension;
- }
-
- public IContainerExtension CreateBuilder(IServiceCollection services)
- {
- _containerExtension.Populate(services);
- return _containerExtension;
- }
-
- public IServiceProvider CreateServiceProvider(IContainerExtension containerExtension)
- {
- return containerExtension.CreateServiceProvider();
- }
-}
diff --git a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
index dffe8ac177..05a2d5153e 100644
--- a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
+++ b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
@@ -66,10 +66,6 @@
-
-
-
-
diff --git a/src/Uno/Prism.Uno/PrismApplicationBase.cs b/src/Uno/Prism.Uno/PrismApplicationBase.cs
index 4160a15611..ab423a2964 100644
--- a/src/Uno/Prism.Uno/PrismApplicationBase.cs
+++ b/src/Uno/Prism.Uno/PrismApplicationBase.cs
@@ -100,7 +100,7 @@ protected virtual void ConfigureServices(IServiceCollection services) { }
///
protected virtual void Initialize(IApplicationBuilder builder)
{
- ContainerLocator.SetContainerExtension(CreateContainerExtension);
+ ContainerLocator.SetContainerExtension(CreateContainerExtension());
_containerExtension = ContainerLocator.Current;
ConfigureApp(builder);
builder.Configure(ConfigureHost)
diff --git a/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj b/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj
index f259a72ab3..5b10a86ef7 100644
--- a/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj
+++ b/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj
@@ -12,7 +12,7 @@
-
+
@@ -24,6 +24,4 @@
-
-
diff --git a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
index 42d2d911a5..432013a49d 100644
--- a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
+++ b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
@@ -1,7 +1,7 @@
using System;
using DryIoc;
+using Prism.Container.DryIoc;
using Prism.Ioc;
-using Prism.Navigation.Regions;
using ExceptionExtensions = System.ExceptionExtensions;
namespace Prism.DryIoc
@@ -23,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/Wpf/Prism.DryIoc.Wpf/PrismBootstrapper.cs b/src/Wpf/Prism.DryIoc.Wpf/PrismBootstrapper.cs
index 19d5a521d1..6ea9bf6083 100644
--- a/src/Wpf/Prism.DryIoc.Wpf/PrismBootstrapper.cs
+++ b/src/Wpf/Prism.DryIoc.Wpf/PrismBootstrapper.cs
@@ -1,5 +1,6 @@
using System;
using DryIoc;
+using Prism.Container.DryIoc;
using Prism.Ioc;
namespace Prism.DryIoc
@@ -21,7 +22,7 @@ public abstract class PrismBootstrapper : PrismBootstrapperBase
/// A new .
protected override IContainerExtension CreateContainerExtension()
{
- return new DryIocContainerExtension(new Container(CreateContainerRules()));
+ return new DryIocContainerExtension(CreateContainerRules());
}
///
diff --git a/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj b/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj
index 558166be04..d083b7e495 100644
--- a/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj
+++ b/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj
@@ -12,7 +12,7 @@
-
+
@@ -26,6 +26,4 @@
-
-
diff --git a/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs b/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs
index 5bc0e791e4..55d863ba35 100644
--- a/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs
+++ b/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs
@@ -1,4 +1,5 @@
using System;
+using Prism.Container.Unity;
using Prism.Ioc;
using Unity;
diff --git a/src/Wpf/Prism.Unity.Wpf/PrismBootstrapper.cs b/src/Wpf/Prism.Unity.Wpf/PrismBootstrapper.cs
index 60590e11b9..945331403a 100644
--- a/src/Wpf/Prism.Unity.Wpf/PrismBootstrapper.cs
+++ b/src/Wpf/Prism.Unity.Wpf/PrismBootstrapper.cs
@@ -1,4 +1,5 @@
using System;
+using Prism.Container.Unity;
using Prism.Ioc;
using Unity;
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
index 994fbc4d0e..85ce900f92 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
@@ -35,7 +35,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)
{
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
index fea6bd0e6a..f843dbdc3d 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
@@ -30,7 +30,6 @@ public class Region : IRegion
private object _context;
private IRegionManager _regionManager;
private IRegionNavigationService _regionNavigationService;
- private IContainerProvider _container;
private Comparison _sort;
@@ -40,7 +39,6 @@ public class Region : IRegion
public Region()
{
Behaviors = new RegionBehaviorCollection(this);
- _container = ContainerLocator.Container;
_sort = DefaultSortComparison;
}
@@ -217,10 +215,7 @@ protected virtual ObservableCollection ItemMetadataCollection
{
get
{
- if (_itemMetadataCollection == null)
- {
- _itemMetadataCollection = new ObservableCollection();
- }
+ _itemMetadataCollection ??= new ObservableCollection();
return _itemMetadataCollection;
}
@@ -234,7 +229,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(string viewName)
{
- var view = _container.Resolve(viewName);
+ var view = ContainerLocator.Container.Resolve(viewName);
return Add(view, viewName, false);
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
index e01de9f7ba..65e17c545d 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
@@ -176,7 +176,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/Wpf/Prism.Wpf/PrismApplicationBase.cs b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
index 3ccd861f9e..ce6a615f24 100644
--- a/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
+++ b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
@@ -56,7 +56,7 @@ protected virtual void ConfigureViewModelLocator()
///
protected virtual void Initialize()
{
- ContainerLocator.SetContainerExtension(CreateContainerExtension);
+ ContainerLocator.SetContainerExtension(CreateContainerExtension());
_containerExtension = ContainerLocator.Current;
_moduleCatalog = CreateModuleCatalog();
RegisterRequiredTypes(_containerExtension);
diff --git a/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs b/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
index 9a74a34ee9..e1d9cc386d 100644
--- a/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
+++ b/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
@@ -53,7 +53,7 @@ protected virtual void ConfigureViewModelLocator()
///
protected virtual void Initialize()
{
- ContainerLocator.SetContainerExtension(CreateContainerExtension);
+ ContainerLocator.SetContainerExtension(CreateContainerExtension());
_containerExtension = ContainerLocator.Current;
_moduleCatalog = CreateModuleCatalog();
RegisterRequiredTypes(_containerExtension);
diff --git a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerHelpers.cs b/tests/Containers/Prism.Container.DryIoc.Tests/ContainerHelpers.cs
deleted file mode 100644
index 453686d685..0000000000
--- a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerHelpers.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using DryIoc;
-
-namespace Prism.Ioc.Tests
-{
- public static class ContainerHelpers
- {
- public static IContainer GetContainer(this IContainerExtension container) =>
- Prism.DryIoc.PrismIocExtensions.GetContainer((IContainerProvider)container);
- }
-}
diff --git a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetup.cs b/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetup.cs
deleted file mode 100644
index 4155270132..0000000000
--- a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetup.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using DryIoc;
-using Prism.DryIoc;
-
-namespace Prism.Ioc.Tests
-{
- partial class ContainerSetup
- {
- protected virtual IContainerExtension CreateContainerInternal() => new DryIocContainerExtension();
-
- public Type NativeContainerType => typeof(IContainer);
- }
-}
diff --git a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetupWithDefaultSingleton.cs b/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetupWithDefaultSingleton.cs
deleted file mode 100644
index 138a47150a..0000000000
--- a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerSetupWithDefaultSingleton.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using DryIoc;
-using Prism.DryIoc;
-using Prism.Ioc.Tests;
-
-namespace Prism.Ioc.DryIoc.Tests
-{
- public class ContainerSetupWithDefaultSingleton : ContainerSetup
- {
- public static Rules RulesWithDefaultSingleton => DryIocContainerExtension.DefaultRules.WithDefaultReuse(Reuse.Singleton);
-
- protected override IContainerExtension CreateContainerInternal() => new DryIocContainerExtension(new Container(RulesWithDefaultSingleton));
- }
-}
diff --git a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerTestsWithDefaultSingleton.cs b/tests/Containers/Prism.Container.DryIoc.Tests/ContainerTestsWithDefaultSingleton.cs
deleted file mode 100644
index 22c0f304a2..0000000000
--- a/tests/Containers/Prism.Container.DryIoc.Tests/ContainerTestsWithDefaultSingleton.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using Prism.Ioc.Mocks.Services;
-using Prism.Ioc.Tests;
-using Xunit;
-
-namespace Prism.Ioc.DryIoc.Tests
-{
- public class ContainerTestsWithDefaultSingleton : IClassFixture, IDisposable
- {
- private bool disposedValue;
-
- protected ContainerSetup Setup { get; }
-
- public ContainerTestsWithDefaultSingleton(ContainerSetupWithDefaultSingleton setup)
- {
- Setup = setup;
- }
-
- [Fact]
- public void RegisterServiceMappingCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterNamedServiceMappingCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register("Test");
- var resolved1 = container.Resolve("Test");
- var resolved2 = container.Resolve("Test");
- var ex = Record.Exception(() => container.Resolve());
- Assert.NotNull(ex);
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void AutomaticTransientResolutionOfConcreteType()
- {
- var container = Setup.CreateContainer();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotSame(resolved1, resolved2);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- Setup.Dispose();
- }
-
- disposedValue = true;
- }
- }
-
- public void Dispose()
- {
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.DryIoc.Tests/Prism.Ioc.DryIoc.Tests.csproj b/tests/Containers/Prism.Container.DryIoc.Tests/Prism.Ioc.DryIoc.Tests.csproj
deleted file mode 100644
index 8c90bf8649..0000000000
--- a/tests/Containers/Prism.Container.DryIoc.Tests/Prism.Ioc.DryIoc.Tests.csproj
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- net6.0
- false
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/CompositeService.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/CompositeService.cs
deleted file mode 100644
index 56f62c69d0..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/CompositeService.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public class CompositeService : IServiceA, IServiceB, IServiceC
- {
- public IServiceB ServiceB => this;
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceA.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceA.cs
deleted file mode 100644
index 3b64867f4e..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceA.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public interface IServiceA
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceB.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceB.cs
deleted file mode 100644
index 61d27a866d..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceB.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public interface IServiceB
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceC.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceC.cs
deleted file mode 100644
index f5d34ea991..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/IServiceC.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public interface IServiceC
- {
- IServiceB ServiceB { get; }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceA.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceA.cs
deleted file mode 100644
index 27127e4c09..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceA.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public class ServiceA : IServiceA
- {
- public string SomeProperty { get; set; }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceB.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceB.cs
deleted file mode 100644
index e594f63c13..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceB.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public class ServiceB : IServiceB
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceC.cs b/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceC.cs
deleted file mode 100644
index ac46806352..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Services/ServiceC.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Prism.Ioc.Mocks.Services
-{
- public class ServiceC : IServiceC
- {
- public ServiceC(IServiceB serviceB)
- {
- ServiceB = serviceB;
- }
-
- public IServiceB ServiceB { get; }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/ViewModels/ConstructorArgumentViewModel.cs b/tests/Containers/Prism.Container.Shared/Mocks/ViewModels/ConstructorArgumentViewModel.cs
deleted file mode 100644
index 218cacc2f6..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/ViewModels/ConstructorArgumentViewModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Prism.Ioc.Mocks.Services;
-using Prism.Mvvm;
-
-namespace Prism.Ioc.Mocks.ViewModels
-{
- public class ConstructorArgumentViewModel : BindableBase
- {
- public IServiceA Service { get; }
-
- public ConstructorArgumentViewModel(IServiceA service)
- {
- Service = service;
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Views/BadView.cs b/tests/Containers/Prism.Container.Shared/Mocks/Views/BadView.cs
deleted file mode 100644
index 924b41201f..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Views/BadView.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace Prism.Ioc.Mocks.Views
-{
- public class BadView : ViewBase
- {
- public BadView()
- {
- throw new XamlParseException("You write bad XAML");
- }
- }
-
- public class XamlParseException : Exception
- {
- public XamlParseException(string message)
- : base(message)
- {
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewA.cs b/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewA.cs
deleted file mode 100644
index bc577f2449..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewA.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Views
-{
- public class ViewA : ViewBase
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewB.cs b/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewB.cs
deleted file mode 100644
index 5b07592f76..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewB.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Views
-{
- public class ViewB : ViewBase
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewBase.cs b/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewBase.cs
deleted file mode 100644
index 97329365cc..0000000000
--- a/tests/Containers/Prism.Container.Shared/Mocks/Views/ViewBase.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Prism.Ioc.Mocks.Views
-{
- public class ViewBase
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Prism.Container.Shared.projitems b/tests/Containers/Prism.Container.Shared/Prism.Container.Shared.projitems
deleted file mode 100644
index 0c6bb4dc66..0000000000
--- a/tests/Containers/Prism.Container.Shared/Prism.Container.Shared.projitems
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- true
- 78932299-2281-4a59-bfb8-07de3014f748
-
-
- Prism.Ioc
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/Containers/Prism.Container.Shared/Prism.Ioc.Shared.shproj b/tests/Containers/Prism.Container.Shared/Prism.Ioc.Shared.shproj
deleted file mode 100644
index 192f77f2f2..0000000000
--- a/tests/Containers/Prism.Container.Shared/Prism.Ioc.Shared.shproj
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- 78932299-2281-4a59-bfb8-07de3014f748
- 14.0
-
-
-
-
-
-
-
-
diff --git a/tests/Containers/Prism.Container.Shared/Tests/ContainerExtension.cs b/tests/Containers/Prism.Container.Shared/Tests/ContainerExtension.cs
deleted file mode 100644
index 7c4121a2d1..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/ContainerExtension.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-using Xunit;
-
-namespace Prism.Ioc.Tests
-{
- public class ContainerExtension { }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Tests/ContainerExtensionCollection.cs b/tests/Containers/Prism.Container.Shared/Tests/ContainerExtensionCollection.cs
deleted file mode 100644
index da36a82a63..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/ContainerExtensionCollection.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Xunit;
-
-namespace Prism.Ioc.Tests
-{
- [CollectionDefinition(nameof(ContainerExtension), DisableParallelization = true)]
- public class ContainerExtensionCollection : ICollectionFixture
- {
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Tests/ContainerFixture.cs b/tests/Containers/Prism.Container.Shared/Tests/ContainerFixture.cs
deleted file mode 100644
index 099c7533f6..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/ContainerFixture.cs
+++ /dev/null
@@ -1,778 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Prism.Ioc.Mocks.Services;
-using Prism.Ioc.Mocks.Views;
-using Xunit;
-
-namespace Prism.Ioc.Tests
-{
- public class ContainerTests : TestBase
- {
- public ContainerTests(ContainerSetup setup)
- : base(setup)
- {
- }
-
- [Fact]
- public void IContainerProviderIsRegistered()
- {
- var container = Setup.CreateContainer();
- var resolved = container.Resolve();
- Assert.Same(container, resolved);
- }
-
- [Fact]
- public void IContainerExtensionIsRegistered()
- {
- var container = Setup.CreateContainer();
- var resolved = container.Resolve();
- Assert.Same(container, resolved);
- }
-
- [Fact]
- public void NativeContainerIsRegistered()
- {
- var container = Setup.CreateContainer();
- object resolved = null;
- var ex = Record.Exception(() => resolved = container.Resolve(Setup.NativeContainerType));
- Assert.Null(ex);
- Assert.NotNull(resolved);
- Assert.IsAssignableFrom(Setup.NativeContainerType, resolved);
- }
-
- [Fact]
- public void RegisterInstanceReturnsSameInstance()
- {
- var instance = new ServiceA();
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterInstance(instance);
- object resolved = container.Resolve();
- Assert.Same(instance, resolved);
- }
-
- [Fact]
- public void RegisterNamedInstanceReturnsSameInstance()
- {
- var instance = new ServiceA();
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterInstance(instance, "Test");
- var resolved = container.Resolve("Test");
- Assert.Same(instance, resolved);
- }
-
- [Fact]
- public void AutomaticTransientResolutionOfConcreteType()
- {
- var container = Setup.CreateContainer();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterConcreteTypeCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterNamedConcreteTypeCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register("Test");
- var resolved1 = container.Resolve("Test");
- var resolved2 = container.Resolve("Test");
- Assert.NotNull(resolved1);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterServiceMappingCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterNamedServiceMappingCreatesTransient()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register("Test");
- var resolved1 = container.Resolve("Test");
- var resolved2 = container.Resolve("Test");
- var ex = Record.Exception(() => container.Resolve());
- Assert.NotNull(ex);
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.NotSame(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterTransientWithFactory()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(CreateService);
- var resolved = container.Resolve();
- Assert.NotNull(resolved);
- Assert.IsType(resolved);
- var ServiceA = resolved as ServiceA;
- Assert.Equal("Created through a factory", ServiceA.SomeProperty);
- var resolved2 = container.Resolve();
- Assert.NotSame(resolved, resolved2);
- }
-
- [Fact]
- public void RegisterTransientWithFactoryAndContainerProvider()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(nameof(ServiceA));
- Setup.Registry.Register(CreateServiceWithContainerProvider);
- var resolved = container.Resolve();
- Assert.NotNull(resolved);
- Assert.IsType(resolved);
- var serviceA = resolved as ServiceA;
-
- var resolved2 = container.Resolve();
- Assert.NotSame(resolved, resolved2);
- }
-
- [Fact]
- public void RegisterManyRegistersAllInterfacesByDefault()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterMany();
-
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- }
-
- [Fact]
- public void RegisterManyOnlyRegistersSpecifiedInterfaces()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterMany(typeof(IServiceA), typeof(IServiceB));
-
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- var ex = Record.Exception(() => container.Resolve());
- Assert.NotNull(ex);
- }
-
- [Fact]
- public void RegisterManyRegistersServicesAsTransients()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterMany();
- Assert.NotSame(container.Resolve(), container.Resolve());
- }
-
- [Fact]
- public void RegisterSupportsLazyInjection()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var lazy = container.Resolve>();
- Assert.NotNull(lazy);
- Assert.False(lazy.IsValueCreated);
- var instance = lazy.Value;
- Assert.IsType(instance);
-
- var lazy2 = container.Resolve>();
- Assert.NotSame(instance, lazy2.Value);
- }
-
- [Fact]
- public void RegisterSupportsFuncInjection()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var func = container.Resolve>();
- Assert.NotNull(func);
- var instance = func();
- Assert.IsType(instance);
-
- var func2 = container.Resolve>();
- Assert.NotSame(instance, func2());
- }
-
- [Fact]
- public void RegisterSingletonConcreteTypeCreatesSingleton()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.Same(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterSingletonServiceMappingCreatesSingleton()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.Same(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterSingletonNamedServiceMappingCreatesSingleton()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton("Test");
- var resolved1 = container.Resolve("Test");
- var resolved2 = container.Resolve("Test");
- var ex = Record.Exception(() => container.Resolve());
- Assert.NotNull(ex);
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.Same(resolved1, resolved2);
- }
-
- [Fact]
- public void RegisterSingletonWithFactory()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton(CreateService);
- var resolved = container.Resolve();
- Assert.NotNull(resolved);
- Assert.IsType(resolved);
- var ServiceA = resolved as ServiceA;
- Assert.Equal("Created through a factory", ServiceA.SomeProperty);
- var resolved2 = container.Resolve();
- Assert.Same(resolved, resolved2);
- }
-
- [Fact]
- public void RegisterSingletonWithFactoryAndContainerProvider()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(nameof(ServiceA));
- Setup.Registry.RegisterSingleton(CreateServiceWithContainerProvider);
- var resolved = container.Resolve();
- Assert.NotNull(resolved);
- Assert.IsType(resolved);
- var serviceA = resolved as ServiceA;
- var resolved2 = container.Resolve();
- Assert.Same(resolved, resolved2);
- }
-
- [Fact]
- public void RegisterManySingletonRegistersAllInterfacesByDefault()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterManySingleton();
-
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- }
-
- [Fact]
- public void RegisterManySingletonOnlyRegistersSpecifiedInterfaces()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterManySingleton(typeof(IServiceA), typeof(IServiceB));
-
- Assert.IsType(container.Resolve());
- Assert.IsType(container.Resolve());
- var ex = Record.Exception(() => container.Resolve());
- Assert.NotNull(ex);
- }
-
- [Fact]
- public void RegisterManySingletonUsesSharedInstanceForAllServices()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterManySingleton();
-
- var serviceA = container.Resolve();
- var serviceB = container.Resolve();
- var serviceC = container.Resolve();
-
- Assert.Same(serviceA, serviceB);
- Assert.Same(serviceB, serviceC);
- }
-
- [Fact]
- public void RegisterSingletonSupportsLazyInjection()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- var lazy = container.Resolve>();
- Assert.NotNull(lazy);
- Assert.False(lazy.IsValueCreated);
- var instance = lazy.Value;
- Assert.IsType(instance);
-
- var lazy2 = container.Resolve>();
- Assert.Same(instance, lazy2.Value);
- }
-
- [Fact]
- public void RegisterSingletonSupportsFuncInjection()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- var func = container.Resolve>();
- Assert.NotNull(func);
- var instance = func();
- Assert.IsType(instance);
-
- var func2 = container.Resolve>();
- Assert.Same(instance, func2());
- }
-
- [Fact]
- public void RegisterScopedConcreteTypeCreatesScoped()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterScoped();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
-
- Assert.NotNull(resolved1);
- Assert.Same(resolved1, resolved2);
-
- container.CreateScope();
- var resolved3 = container.Resolve();
- Assert.NotSame(resolved1, resolved3);
- }
-
- [Fact]
- public void RegisterScopedServiceMappingCreatesScoped()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterScoped();
- var resolved1 = container.Resolve();
- var resolved2 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.NotNull(resolved2);
- Assert.IsType(resolved1);
- Assert.IsType(resolved2);
- Assert.Same(resolved1, resolved2);
-
- container.CreateScope();
- var resolved3 = container.Resolve();
- Assert.NotSame(resolved1, resolved3);
- }
-
- [Fact]
- public void RegisterScopedWithFactory()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.RegisterScoped(CreateService);
- var resolved1 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.IsType(resolved1);
- var ServiceA = resolved1 as ServiceA;
- Assert.Equal("Created through a factory", ServiceA.SomeProperty);
-
- var resolved2 = container.Resolve();
- Assert.Same(resolved1, resolved2);
- container.CreateScope();
- var resolved3 = container.Resolve();
- Assert.NotSame(resolved2, resolved3);
- }
-
- [Fact]
- public void RegisterScopedWithFactoryAndContainerProvider()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(nameof(ServiceA));
- Setup.Registry.RegisterScoped(CreateServiceWithContainerProvider);
- var resolved1 = container.Resolve();
- Assert.NotNull(resolved1);
- Assert.IsType(resolved1);
-
- var resolved2 = container.Resolve();
- Assert.Same(resolved1, resolved2);
- container.CreateScope();
- var resolved3 = container.Resolve();
- Assert.NotSame(resolved2, resolved3);
- }
-
- [Fact]
- public void LocatesImplementationTypeForNamedService()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(nameof(ViewA));
- var type = ((Internals.IContainerInfo)Setup.Extension).GetRegistrationType(nameof(ViewA));
- Assert.NotNull(type);
- Assert.Equal(typeof(ViewA), type);
- }
-
- [Fact]
- public void LocatesImplementationType()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register();
- var type = ((Internals.IContainerInfo)Setup.Extension).GetRegistrationType(typeof(IServiceA));
- Assert.NotNull(type);
- Assert.Equal(typeof(ServiceA), type);
- }
-
- [Fact]
- public void RegisterTransientDelegateReturnsNewInstanceEachTime()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(() => new ServiceA());
-
- Assert.NotSame(container.Resolve(), container.Resolve());
- }
-
- [Fact]
- public void RegisterTransientDelegateWithContainerReturnsNewInstanceEachTime()
- {
- var container = Setup.CreateContainer();
- Setup.Registry.Register(x => new ServiceA());
-
- Assert.NotSame(container.Resolve(), container.Resolve());
- }
-
- private static IServiceA CreateService() =>
- new ServiceA { SomeProperty = "Created through a factory" };
-
- private static IServiceA CreateServiceWithContainerProvider(IContainerProvider containerProvider) =>
- containerProvider.Resolve(nameof(ServiceA));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Fact]
- public void Register_RegistersTransientService()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
-
- var resolve1 = Setup.Container.Resolve();
- var resolve2 = Setup.Container.Resolve();
-
- Assert.IsType(resolve1);
- Assert.NotSame(resolve1, resolve2);
- }
-
- [Fact]
- public void Register_RegistersFunc()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory());
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.NotSame(service, factory());
- }
-
- [Fact]
- public void Register_RegistersLazy()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory.Value);
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.NotSame(service, Setup.Container.Resolve>().Value);
- }
-
-#if !UNITY
- [Fact]
- public void Register_RegistersIEnumerable()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
- var services = Setup.Container.Resolve>();
-
- Assert.NotNull(services);
- Assert.Single(services);
- Assert.IsType(services.First());
- }
-#endif
-
- [Fact]
- public void Register_LastInFirstOut()
- {
- Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- Setup.Registry.Register();
- var service = Setup.Container.Resolve();
-
- Assert.IsType(service);
- Assert.NotSame(service, Setup.Container.Resolve());
- }
-
-#if !UNITY
- [Theory]
- [InlineData(0, typeof(ServiceA))]
- [InlineData(1, typeof(CompositeService))]
- public void Register_ResolveAll(int index, Type type)
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
- Setup.Registry.Register();
- var services = Setup.Container.Resolve>();
-
- Assert.NotNull(services);
- Assert.Equal(2, services.Count());
- Assert.IsType(type, services.ElementAt(index));
- }
-
-#endif
-
- [Fact]
- public void RegisterSingleton_RegistersSingletonService()
- {
- Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
-
- var resolve1 = Setup.Container.Resolve();
- var resolve2 = Setup.Container.Resolve();
-
- Assert.IsType(resolve1);
- Assert.Same(resolve1, resolve2);
- }
-
- [Fact]
- public void RegisterSinglton_RegistersFunc()
- {
- Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory());
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.Same(service, factory());
- }
-
- [Fact]
- public void RegisterSingleton_RegistersLazy()
- {
- Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory.Value);
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.Same(service, Setup.Container.Resolve>().Value);
- }
-
-#if !UNITY
-
- [Fact]
- public void RegisterSingleton_RegistersIEnumerable()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
- var services = Setup.Container.Resolve>();
-
- Assert.NotNull(services);
- Assert.Single(services);
- Assert.IsType(services.First());
- }
-
-#endif
-
- [Fact]
- public void RegisterInstance_RegistersSingletonService()
- {
- Setup.CreateContainer();
- var instance = new ServiceA();
- Setup.Registry.RegisterInstance(instance);
-
- var resolve1 = Setup.Container.Resolve();
-
- Assert.IsType(resolve1);
- Assert.Same(instance, resolve1);
- }
-
- [Fact]
- public void RegisterSingleton_LastInFirstOut()
- {
- Setup.CreateContainer();
- Setup.Registry.Register();
- Setup.Registry.RegisterSingleton();
- var service = Setup.Container.Resolve();
-
- Assert.IsType(service);
- Assert.Same(service, Setup.Container.Resolve());
- }
-
-#if !UNITY
- [Theory]
- [InlineData(0, typeof(ServiceA))]
- [InlineData(1, typeof(CompositeService))]
- public void RegisterSingleton_ResolveAll(int index, Type type)
- {
- Setup.CreateContainer();
- Setup.Registry.RegisterSingleton();
- Setup.Registry.RegisterSingleton();
- var services = Setup.Container.Resolve>();
-
- Assert.NotNull(services);
- Assert.Equal(2, services.Count());
- Assert.IsType(type, services.ElementAt(index));
- }
-
-#endif
-
- [Fact]
- public void RegisterInstance_RegistersFunc()
- {
- Setup.CreateContainer();
- var instance = new ServiceA();
- Setup.Registry.RegisterInstance(instance);
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory());
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.Same(service, factory());
- }
-
- [Fact]
- public void RegisterInstance_RegistersLazy()
- {
- Setup.CreateContainer();
- var instance = new ServiceA();
- Setup.Registry.RegisterInstance(instance);
-
- var factory = Setup.Container.Resolve>();
- IServiceA service = null;
- Assert.NotNull(factory);
- var ex = Record.Exception(() => service = factory.Value);
- Assert.Null(ex);
- Assert.NotNull(service);
- Assert.IsType(service);
- Assert.Same(service, Setup.Container.Resolve>().Value);
- }
-
-
-
-#if !UNITY
-
- [Fact]
- public void RegisterInstance_RegistersIEnumerable()
- {
- Setup.CreateContainer();
- var instance = new ServiceA();
- Setup.Registry.RegisterInstance(instance);
- var services = Setup.Container.Resolve>();
-
- Assert.NotNull(services);
- Assert.Single(services);
- Assert.IsType(services.First());
- }
-
-#endif
-
- [Fact]
- public void TryRegisterTransientDoesNotReplaceOriginalRegistration()
- {
- Setup.CreateContainer();
- Setup.Registry.TryRegister();
- Setup.Registry.TryRegister();
-
- var service = Setup.Container.Resolve();
- Assert.IsType(service);
- }
-
- [Fact]
- public void TryRegisterScopedDoesNotReplaceOriginalRegistration()
- {
- Setup.CreateContainer();
- Setup.Registry.TryRegisterScoped();
- Setup.Registry.TryRegisterScoped();
-
- var service = Setup.Container.Resolve();
- Assert.IsType(service);
- }
-
- [Fact]
- public void TryRegisterSingletonDoesNotReplaceOriginalRegistration()
- {
- Setup.CreateContainer();
- Setup.Registry.TryRegisterSingleton();
- Setup.Registry.TryRegisterSingleton();
-
- var service = Setup.Container.Resolve();
- Assert.IsType(service);
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Tests/ContainerResolutionExceptionFixture.cs b/tests/Containers/Prism.Container.Shared/Tests/ContainerResolutionExceptionFixture.cs
deleted file mode 100644
index 40ab39bb8c..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/ContainerResolutionExceptionFixture.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using Prism.Ioc;
-using Prism.Ioc.Mocks.Services;
-using Prism.Ioc.Mocks.ViewModels;
-using Prism.Ioc.Mocks.Views;
-using Xunit;
-
-namespace Prism.Ioc.Tests
-{
- public class ContainerResolutionExceptionFixture : TestBase
- {
- public ContainerResolutionExceptionFixture(ContainerSetup setup)
- : base(setup)
- {
- }
-
- [Fact]
- public void ThrowsContainerResolutionExceptionForUnregisteredService()
- {
- var container = Setup.CreateContainer();
- var ex = Record.Exception(() => container.Resolve());
-
- Assert.NotNull(ex);
- Assert.IsType(ex);
- }
-
- [Fact]
- public void ThrowsContainerResolutionExceptionForUnregisteredNamedPage()
- {
- var container = Setup.CreateContainer();
- var ex = Record.Exception(() => container.Resolve("missing"));
-
- Assert.NotNull(ex);
- Assert.IsType(ex);
- }
-
- [Fact]
- public void GetErrorsDoesNotThrowException()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
- Setup.Registry.Register("BadView");
-
- var ex = Record.Exception(() => container.Resolve("BadView"));
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- ContainerResolutionErrorCollection errors = null;
- var ex2 = Record.Exception(() => errors = cre.GetErrors());
- Assert.Null(ex2);
- }
-
- [Fact]
- public void GetErrorsLocatesIssueWithBadView()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
- Setup.Registry.Register("BadView");
-
- var ex = Record.Exception(() => container.Resolve("BadView"));
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- var errors = cre.GetErrors();
-
- Assert.Contains(typeof(BadView), errors.Types);
- }
-
- [Fact]
- public void GetErrorsLocatesTargetInvocationException()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
- Setup.Registry.Register("BadView");
-
- var ex = Record.Exception(() => container.Resolve("BadView"));
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- var errors = cre.GetErrors();
-
- Assert.Contains(errors, x => x.Value is TargetInvocationException);
- }
-
- [Fact]
- public void GetErrorsLocatesXamlParseException()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
- Setup.Registry.Register("BadView");
-
- var ex = Record.Exception(() => container.Resolve("BadView"));
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- var errors = cre.GetErrors();
-
- Assert.Contains(errors, x => x.Value is XamlParseException);
- }
-
- [Fact]
- public void LocatesUnregisteredServiceType()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
-
- var ex = Record.Exception(() => container.Resolve());
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- var errors = cre.GetErrors();
-
- Assert.Contains(typeof(IServiceA), errors.Types);
- }
-
- [Fact]
- public void LocatesUnregisteredServiceWithMissingRegistration()
- {
- ContainerLocator.ResetContainer();
- var container = Setup.CreateContainer();
- ContainerLocator.SetContainerExtension(() => Setup.Extension);
-
- var ex = Record.Exception(() => container.Resolve());
-
- Assert.IsType(ex);
- var cre = ex as ContainerResolutionException;
- var errors = cre.GetErrors();
-
- Assert.Contains(errors, x => x.Value is ContainerResolutionException innerCre && innerCre.ServiceType == typeof(IServiceA) && innerCre.Message == ContainerResolutionException.MissingRegistration);
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Tests/ContainerSetup.cs b/tests/Containers/Prism.Container.Shared/Tests/ContainerSetup.cs
deleted file mode 100644
index 9aa7df061d..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/ContainerSetup.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using Prism.Ioc;
-using Prism.Mvvm;
-
-namespace Prism.Ioc.Tests
-{
- public partial class ContainerSetup : IDisposable
- {
- public ContainerSetup()
- {
- ViewModelLocationProvider.SetDefaultViewModelFactory((view, type) => Container.Resolve(type));
- }
-
- public IContainerProvider Container => ContainerLocator.Container;
-
- public IContainerExtension Extension => ContainerLocator.Current;
-
- public IContainerRegistry Registry => Extension;
-
- public IContainerProvider CreateContainer()
- {
- ContainerLocator.ResetContainer();
- ContainerLocator.SetContainerExtension(() => CreateContainerInternal());
- var container = ContainerLocator.Current;
- container.CreateScope();
- return container;
- }
-
- private bool _disposed;
-
- private void Dispose(bool disposing)
- {
- _disposed = true;
- ContainerLocator.ResetContainer();
- }
-
- public void Dispose()
- {
- if (!_disposed)
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Shared/Tests/TestBase.cs b/tests/Containers/Prism.Container.Shared/Tests/TestBase.cs
deleted file mode 100644
index 8de104c102..0000000000
--- a/tests/Containers/Prism.Container.Shared/Tests/TestBase.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using Xunit;
-
-namespace Prism.Ioc.Tests
-{
- [Collection(nameof(ContainerExtension))]
- public abstract class TestBase : IClassFixture, IDisposable
- {
- private bool disposedValue;
-
- protected ContainerSetup Setup { get; }
-
- protected TestBase(ContainerSetup setup)
- {
- Setup = setup;
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- Setup.Dispose();
- }
-
- // TODO: free unmanaged resources (unmanaged objects) and override finalizer
- // TODO: set large fields to null
- disposedValue = true;
- }
- }
-
- public void Dispose()
- {
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
- }
-}
diff --git a/tests/Containers/Prism.Container.Unity.Tests/ContainerHelpers.cs b/tests/Containers/Prism.Container.Unity.Tests/ContainerHelpers.cs
deleted file mode 100644
index e9c3bab33d..0000000000
--- a/tests/Containers/Prism.Container.Unity.Tests/ContainerHelpers.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Unity;
-
-namespace Prism.Ioc.Tests
-{
- public static class ContainerHelpers
- {
- public static IUnityContainer GetContainer(this IContainerExtension container) =>
- Prism.Unity.PrismIocExtensions.GetContainer((IContainerProvider)container);
- }
-}
diff --git a/tests/Containers/Prism.Container.Unity.Tests/ContainerSetup.cs b/tests/Containers/Prism.Container.Unity.Tests/ContainerSetup.cs
deleted file mode 100644
index db2bbbde96..0000000000
--- a/tests/Containers/Prism.Container.Unity.Tests/ContainerSetup.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using Prism.Ioc;
-using Prism.Unity;
-using Unity;
-
-namespace Prism.Ioc.Tests
-{
- partial class ContainerSetup
- {
- IContainerExtension CreateContainerInternal() => new UnityContainerExtension();
-
- public Type NativeContainerType => typeof(IUnityContainer);
- }
-}
diff --git a/tests/Containers/Prism.Container.Unity.Tests/Prism.Ioc.Unity.Tests.csproj b/tests/Containers/Prism.Container.Unity.Tests/Prism.Ioc.Unity.Tests.csproj
deleted file mode 100644
index 16a5f606ad..0000000000
--- a/tests/Containers/Prism.Container.Unity.Tests/Prism.Ioc.Unity.Tests.csproj
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
- net6.0
- false
- $(DefineConstants);UNITY
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs
index 2f2f1e0917..c2b20ef21d 100644
--- a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs
+++ b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs
@@ -222,7 +222,7 @@ public void CustomNamedNavigationService_Resolved_In_ViewModel()
}
[Fact]
- public async Task XamlNavigation_NaviateTo()
+ public async Task XamlNavigation_NavigateTo()
{
var app = CreateMockApplication();
await app.NavigationService.NavigateAsync("NavigationPage/XamlViewMockA");
diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs
index 911d2a5ea2..66eb232de0 100644
--- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs
+++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs
@@ -191,7 +191,7 @@ public void AddViewPassesSameScopeByDefaultToNamedView()
}
[Fact]
- public void AddViewPassesDiferentScopeWhenAdding()
+ public void AddViewPassesDifferentScopeWhenAdding()
{
var regionManager = Mock.Of();
IRegion region = new Region
@@ -491,7 +491,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.NavigationService.RequestNavigate(uri, navigationCallback, navigationParameters);
diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs
index 692f839673..cb7194e54a 100644
--- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs
+++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs
@@ -350,7 +350,7 @@ public void CanRegisterViewType()
};
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();
@@ -386,7 +386,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();
diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs
index 694a97f80b..193fe56215 100644
--- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs
+++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using Moq;
using Prism.Ioc;
@@ -16,7 +14,9 @@ public class RegionViewRegistryFixture
[Fact]
public void CanRegisterContentAndRetrieveIt()
{
+ ContainerLocator.ResetContainer();
var containerMock = new Mock();
+ ContainerLocator.SetContainerExtension(containerMock.Object);
containerMock.Setup(c => c.Resolve(typeof(MockContentObject))).Returns(new MockContentObject());
var registry = new RegionViewRegistry(containerMock.Object);
@@ -52,6 +52,8 @@ public void ShouldRaiseEventWhenAddingContent()
[Fact]
public void CanRegisterContentAsDelegateAndRetrieveIt()
{
+ ContainerLocator.ResetContainer();
+ ContainerLocator.SetContainerExtension(Mock.Of());
var registry = new RegionViewRegistry(null);
var content = new MockContentObject();
diff --git a/tests/Forms/Prism.Forms.Tests/Common/PageUtilitiesFixture.cs b/tests/Forms/Prism.Forms.Tests/Common/PageUtilitiesFixture.cs
index 4187fec928..6b9cfa6683 100644
--- a/tests/Forms/Prism.Forms.Tests/Common/PageUtilitiesFixture.cs
+++ b/tests/Forms/Prism.Forms.Tests/Common/PageUtilitiesFixture.cs
@@ -36,7 +36,7 @@ public void DestroyContentPage()
Assert.Equal(page, recorder.Records[0].Sender);
Assert.Null(page.BindingContext);
- Assert.Equal(0, page.Behaviors.Count);
+ Assert.Empty(page.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[0].Event);
Assert.Equal(viewModel, recorder.Records[1].Sender);
@@ -62,7 +62,7 @@ public void DestroyNavigationPage()
// contentPage2
Assert.Equal(contentPage2, recorder.Records[0].Sender);
Assert.Null(contentPage2.BindingContext);
- Assert.Equal(0, contentPage2.Behaviors.Count);
+ Assert.Empty(contentPage2.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[0].Event);
Assert.Equal(contentPage2ViewModel, recorder.Records[1].Sender);
@@ -71,7 +71,7 @@ public void DestroyNavigationPage()
// contentPage1
Assert.Equal(contentPage1, recorder.Records[2].Sender);
Assert.Null(contentPage1.BindingContext);
- Assert.Equal(0, contentPage1.Behaviors.Count);
+ Assert.Empty(contentPage1.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[2].Event);
Assert.Equal(contentPage1ViewModel, recorder.Records[3].Sender);
@@ -80,7 +80,7 @@ public void DestroyNavigationPage()
// navigationPage
Assert.Equal(navigationPage, recorder.Records[4].Sender);
Assert.Null(navigationPage.BindingContext);
- Assert.Equal(0, navigationPage.Behaviors.Count);
+ Assert.Empty(navigationPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[4].Event);
Assert.Equal(navigationPageViewModel, recorder.Records[5].Sender);
@@ -104,7 +104,7 @@ public void DestoryMasterDetailPage()
var record = recorder.TakeFirst();
Assert.Equal(masterPage, record.Sender);
Assert.Null(masterPage.BindingContext);
- Assert.Equal(0, masterPage.Behaviors.Count);
+ Assert.Empty(masterPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, record.Event);
record = recorder.TakeFirst();
@@ -115,7 +115,7 @@ record = recorder.TakeFirst();
record = recorder.TakeFirst();
Assert.Equal(detailPage, record.Sender);
Assert.Null(detailPage.BindingContext);
- Assert.Equal(0, detailPage.Behaviors.Count);
+ Assert.Empty(detailPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, record.Event);
record = recorder.TakeFirst();
@@ -126,7 +126,7 @@ record = recorder.TakeFirst();
record = recorder.TakeFirst();
Assert.Equal(masterDetailPage, record.Sender);
Assert.Null(masterDetailPage.BindingContext);
- Assert.Equal(0, masterDetailPage.Behaviors.Count);
+ Assert.Empty(masterDetailPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, record.Event);
record = recorder.TakeFirst();
@@ -167,7 +167,7 @@ public void DestroyTabbedPage()
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[0].Event);
Assert.Equal(tab5, recorder.Records[1].Sender);
- Assert.Equal(0, tab5.Behaviors.Count);
+ Assert.Empty(tab5.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[1].Event);
Assert.Equal(tab5ChildViewModel, recorder.Records[2].Sender);
@@ -175,14 +175,14 @@ public void DestroyTabbedPage()
//tab 4
Assert.Equal(tab4Child, recorder.Records[3].Sender);
- Assert.Equal(0, tab4Child.Behaviors.Count);
+ Assert.Empty(tab4Child.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[3].Event);
Assert.Equal(tab4ChildViewModel, recorder.Records[4].Sender);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[4].Event);
Assert.Equal(tab4, recorder.Records[5].Sender);
- Assert.Equal(0, tab4.Behaviors.Count);
+ Assert.Empty(tab4.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[5].Event);
Assert.Equal(tab4ViewModel, recorder.Records[6].Sender);
@@ -191,7 +191,7 @@ public void DestroyTabbedPage()
//tab 3
Assert.Equal(tab3, recorder.Records[7].Sender);
Assert.Null(tab3.BindingContext);
- Assert.Equal(0, tab3.Behaviors.Count);
+ Assert.Empty(tab3.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[7].Event);
Assert.Equal(tab3ViewModel, recorder.Records[8].Sender);
@@ -202,7 +202,7 @@ public void DestroyTabbedPage()
//tab 1
Assert.Equal(tab1, recorder.Records[9].Sender);
Assert.Null(tab1.BindingContext);
- Assert.Equal(0, tab1.Behaviors.Count);
+ Assert.Empty(tab1.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[9].Event);
Assert.Equal(tab1ViewModel, recorder.Records[10].Sender);
@@ -211,7 +211,7 @@ public void DestroyTabbedPage()
//TabbedPage
Assert.Equal(tabbedPage, recorder.Records[11].Sender);
Assert.Null(tabbedPage.BindingContext);
- Assert.Equal(0, tabbedPage.Behaviors.Count);
+ Assert.Empty(tabbedPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[11].Event);
Assert.Equal(tabbedPageViewModel, recorder.Records[12].Sender);
@@ -238,7 +238,7 @@ public void DestroyCarouselPage()
// childPage2
Assert.Equal(childPage2, recorder.Records[1].Sender);
Assert.Null(childPage2.BindingContext);
- Assert.Equal(0, childPage2.Behaviors.Count);
+ Assert.Empty(childPage2.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[1].Event);
Assert.Equal(childPage2ViewModel, recorder.Records[2].Sender);
@@ -251,7 +251,7 @@ public void DestroyCarouselPage()
// tabbedPage
Assert.Equal(carouselPage, recorder.Records[4].Sender);
Assert.Null(carouselPage.BindingContext);
- Assert.Equal(0, carouselPage.Behaviors.Count);
+ Assert.Empty(carouselPage.Behaviors);
Assert.Equal(PageNavigationEvent.Destroy, recorder.Records[4].Event);
Assert.Equal(carouselPageViewModel, recorder.Records[5].Sender);
diff --git a/tests/Forms/Prism.Forms.Tests/Navigation/INavigationServiceExtensionsFixture.cs b/tests/Forms/Prism.Forms.Tests/Navigation/INavigationServiceExtensionsFixture.cs
index 83a9986788..2a826764db 100644
--- a/tests/Forms/Prism.Forms.Tests/Navigation/INavigationServiceExtensionsFixture.cs
+++ b/tests/Forms/Prism.Forms.Tests/Navigation/INavigationServiceExtensionsFixture.cs
@@ -21,7 +21,7 @@ public INavigationServiceExtensionsFixture()
ContainerLocator.ResetContainer();
var container = new Mock