diff --git a/PrismLibrary.sln b/PrismLibrary.sln index 920c29db95..767838aab8 100644 --- a/PrismLibrary.sln +++ b/PrismLibrary.sln @@ -58,10 +58,24 @@ 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 Global 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 + 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*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*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 + 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.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 GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -278,6 +292,9 @@ 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} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C7433AE2-B1A0-4C1A-887E-5CAA7AAF67A6} diff --git a/PrismLibrary_Forms.sln b/PrismLibrary_Forms.sln index 7f2690788c..7e389eea03 100644 --- a/PrismLibrary_Forms.sln +++ b/PrismLibrary_Forms.sln @@ -29,10 +29,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Unity.Forms.Tests", " 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}") = "Container", "Container", "{09DC3C91-141C-468E-9CE6-71091A95BED8}" +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 Global GlobalSection(SharedMSBuildProjectFiles) = preSolution tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{2fd30caf-6930-41f3-8104-3d018c8bdd9e}*SharedItemsImports = 5 tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{3cba8db4-c2f3-41cb-b5f5-4c282939d429}*SharedItemsImports = 5 + src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{5923689a-fbe9-4b22-8938-de554bed3144}*SharedItemsImports = 5 + src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*SharedItemsImports = 13 + src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{d4fe645d-0924-4a20-a081-27a0aff3adfa}*SharedItemsImports = 5 + src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{d66336a6-07e5-401a-a710-daedd6975d59}*SharedItemsImports = 13 tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{fac4fa5a-d6c1-4787-9b1f-a3ec6e2fb26e}*SharedItemsImports = 13 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -156,6 +166,9 @@ Global {3CBA8DB4-C2F3-41CB-B5F5-4C282939D429} = {CF8CB255-8A76-48A7-B09A-88B14648D3A8} {2FD30CAF-6930-41F3-8104-3D018C8BDD9E} = {CF8CB255-8A76-48A7-B09A-88B14648D3A8} {FAC4FA5A-D6C1-4787-9B1F-A3EC6E2FB26E} = {CF8CB255-8A76-48A7-B09A-88B14648D3A8} + {09DC3C91-141C-468E-9CE6-71091A95BED8} = {07A089D7-5FAF-492A-BE7F-B854E255E32C} + {D66336A6-07E5-401A-A710-DAEDD6975D59} = {09DC3C91-141C-468E-9CE6-71091A95BED8} + {6E7EC81D-DA39-4C4F-A898-0148558C34F4} = {09DC3C91-141C-468E-9CE6-71091A95BED8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E03CA9C3-F24B-442E-B378-C325728E9E29} diff --git a/PrismLibrary_Wpf.sln b/PrismLibrary_Wpf.sln index feab24f6a1..8f32d318fd 100644 --- a/PrismLibrary_Wpf.sln +++ b/PrismLibrary_Wpf.sln @@ -31,9 +31,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.IocContainer.Wpf.Test 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("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{3CD6B945-4E76-4DC7-A68A-972C36ADA718}" +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("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Unity.Shared", "src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.shproj", "{D66336A6-07E5-401A-A710-DAEDD6975D59}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution + src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{2f184285-b860-4c68-aaf7-73af6b2f98d8}*SharedItemsImports = 5 + src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*SharedItemsImports = 13 + src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{a2976e8c-589a-47c7-b81d-d59cbced2e0b}*SharedItemsImports = 5 + tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{a60cf7b0-56ad-4568-9720-e30ee5855149}*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*{d66336a6-07e5-401a-a710-daedd6975d59}*SharedItemsImports = 13 tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{fd11fa19-6a06-471d-8471-94c1153104cd}*SharedItemsImports = 5 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -170,6 +181,9 @@ Global {FD11FA19-6A06-471D-8471-94C1153104CD} = {414633C4-2FB9-4A81-8071-832C33C027BC} {4039BC28-15D4-4EE1-82D8-80BD4CC61C50} = {414633C4-2FB9-4A81-8071-832C33C027BC} {BD42A7D6-A84D-4D27-9C28-7F6A2EC477F1} = {414633C4-2FB9-4A81-8071-832C33C027BC} + {3CD6B945-4E76-4DC7-A68A-972C36ADA718} = {0DF20AD9-0A3F-4B61-BC8A-2D6DED59A7D2} + {6E7EC81D-DA39-4C4F-A898-0148558C34F4} = {3CD6B945-4E76-4DC7-A68A-972C36ADA718} + {D66336A6-07E5-401A-A710-DAEDD6975D59} = {3CD6B945-4E76-4DC7-A68A-972C36ADA718} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {544BBD3D-C3AA-405A-9832-122679F8AD05} diff --git a/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs b/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs new file mode 100644 index 0000000000..b475d1373a --- /dev/null +++ b/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs @@ -0,0 +1,177 @@ +using System; +using System.Linq; +using DryIoc; +using Prism.Ioc; + +namespace Prism.DryIoc +{ + /// + /// The Implementation to use with DryIoc + /// + public class DryIocContainerExtension : IContainerExtension + { + /// + /// The instance of the wrapped container + /// + public IContainer Instance { get; } + + /// + /// Constructs a new + /// + /// The instance to use. + public DryIocContainerExtension(IContainer container) + { + Instance = container; + Instance.RegisterInstanceMany(new[] + { + typeof(IContainerExtension), + typeof(IContainerProvider) + }, this); + } + + /// + /// 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, 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, serviceKey: name); + return this; + } + + /// + /// Registers a Transient with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The instance + public IContainerRegistry Register(Type from, Type to) + { + Instance.Register(from, to); + return this; + } + + /// + /// Registers a Transient with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The name or key to register the service + /// The instance + public IContainerRegistry Register(Type from, Type to, string name) + { + Instance.Register(from, to, serviceKey: name); + return this; + } + + /// + /// Resolves a given + /// + /// The service + /// The resolved Service + public object Resolve(Type type) + { + return Instance.Resolve(type); + } + + /// + /// Resolves a given + /// + /// The service + /// The service name/key used when registering the + /// The resolved Service + public object Resolve(Type type, string name) + { + return Instance.Resolve(type, serviceKey: name); + } + + /// + /// Resolves a given + /// + /// The service + /// Typed parameters to use when resolving the Service + /// The resolved Service + public object Resolve(Type type, params (Type Type, object Instance)[] parameters) + { + return Instance.Resolve(type, args: parameters.Select(p => p.Instance).ToArray()); + } + + /// + /// Resolves a given + /// + /// The service + /// The service name/key used when registering the + /// Typed parameters to use when resolving the Service + /// The resolved Service + public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) + { + return Instance.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray()); + } + + /// + /// Determines if a given service is registered + /// + /// The service + /// true if the service is registered. + public bool IsRegistered(Type type) + { + return Instance.IsRegistered(type); + } + + /// + /// Determines if a given service is registered with the specified name + /// + /// The service + /// The service name or key used + /// true if the service is registered. + public bool IsRegistered(Type type, string name) + { + return Instance.IsRegistered(type, name); + } + } +} diff --git a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems new file mode 100644 index 0000000000..2536e87499 --- /dev/null +++ b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.projitems @@ -0,0 +1,15 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 6e7ec81d-da39-4c4f-a898-0148558c34f4 + + + Prism.DryIoc + + + + + + \ No newline at end of file diff --git a/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj new file mode 100644 index 0000000000..ba802d8932 --- /dev/null +++ b/src/Containers/Prism.DryIoc.Shared/Prism.DryIoc.Shared.shproj @@ -0,0 +1,13 @@ + + + + 6e7ec81d-da39-4c4f-a898-0148558c34f4 + 14.0 + + + + + + + + diff --git a/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs b/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs new file mode 100644 index 0000000000..0fc865e48d --- /dev/null +++ b/src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs @@ -0,0 +1,31 @@ +using DryIoc; +using Prism.Ioc; + +namespace Prism.DryIoc +{ + /// + /// Extensions help get the underlying + /// + public static class PrismIocExtensions + { + /// + /// Gets the from the + /// + /// The current + /// The underlying + public static IContainer GetContainer(this IContainerProvider containerProvider) + { + return ((IContainerExtension)containerProvider).Instance; + } + + /// + /// Gets the from the + /// + /// The current + /// The underlying + public static IContainer GetContainer(this IContainerRegistry containerRegistry) + { + return ((IContainerExtension)containerRegistry).Instance; + } + } +} diff --git a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems new file mode 100644 index 0000000000..06152c646d --- /dev/null +++ b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.projitems @@ -0,0 +1,15 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + d66336a6-07e5-401a-a710-daedd6975d59 + + + Prism.Unity + + + + + + \ No newline at end of file diff --git a/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj new file mode 100644 index 0000000000..8ce0b4e3e1 --- /dev/null +++ b/src/Containers/Prism.Unity.Shared/Prism.Unity.Shared.shproj @@ -0,0 +1,13 @@ + + + + d66336a6-07e5-401a-a710-daedd6975d59 + 14.0 + + + + + + + + diff --git a/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs b/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs new file mode 100644 index 0000000000..33e60a4ad9 --- /dev/null +++ b/src/Containers/Prism.Unity.Shared/PrismIocExtensions.cs @@ -0,0 +1,31 @@ +using Prism.Ioc; +using Unity; + +namespace Prism.Unity +{ + /// + /// Extensions help get the underlying + /// + public static class PrismIocExtensions + { + /// + /// Gets the from the + /// + /// The current + /// The underlying + public static IUnityContainer GetContainer(this IContainerProvider containerProvider) + { + return ((IContainerExtension)containerProvider).Instance; + } + + /// + /// Gets the from the + /// + /// The current + /// The underlying + public static IUnityContainer GetContainer(this IContainerRegistry containerRegistry) + { + return ((IContainerExtension)containerRegistry).Instance; + } + } +} diff --git a/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs b/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs new file mode 100644 index 0000000000..403f927846 --- /dev/null +++ b/src/Containers/Prism.Unity.Shared/UnityContainerExtension.cs @@ -0,0 +1,187 @@ +using System; +using System.Linq; +using Prism.Ioc; +using Unity; +using Unity.Resolution; + +namespace Prism.Unity +{ + /// + /// The Unity implementation of the + /// + public class UnityContainerExtension : IContainerExtension + { + /// + /// The instance of the wrapped container + /// + public IUnityContainer Instance { get; } + + /// + /// Constructs a default + /// + public UnityContainerExtension() + : this(new UnityContainer()) + { + } + + /// + /// Constructs a with the specified + /// + /// + public UnityContainerExtension(IUnityContainer container) + { + Instance = container; + string currentContainer = "CurrentContainer"; + Instance.RegisterInstance(currentContainer, this); + Instance.RegisterFactory(typeof(IContainerExtension), c => c.Resolve(currentContainer)); + Instance.RegisterFactory(typeof(IContainerProvider), c => c.Resolve(currentContainer)); + } + + /// + /// Used to perform any final steps for configuring the extension that may be required by the container. + /// + public void FinalizeExtension() { } + + /// + /// Registers an instance of a given + /// + /// The service that is being registered + /// The instance of the service or + /// The instance + public IContainerRegistry RegisterInstance(Type type, object instance) + { + Instance.RegisterInstance(type, instance); + return this; + } + + /// + /// Registers an instance of a given with the specified name or key + /// + /// The service that is being registered + /// The instance of the service or + /// The name or key to register the service + /// The instance + public IContainerRegistry RegisterInstance(Type type, object instance, string name) + { + Instance.RegisterInstance(type, name, instance); + return this; + } + + /// + /// Registers a Singleton with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The instance + public IContainerRegistry RegisterSingleton(Type from, Type to) + { + Instance.RegisterSingleton(from, to); + return this; + } + + /// + /// Registers a Singleton with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The name or key to register the service + /// The instance + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) + { + Instance.RegisterSingleton(from, to, name); + return this; + } + + /// + /// Registers a Transient with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The instance + public IContainerRegistry Register(Type from, Type to) + { + Instance.RegisterType(from, to); + return this; + } + + /// + /// Registers a Transient with the given service and mapping to the specified implementation . + /// + /// The service + /// The implementation + /// The name or key to register the service + /// The instance + public IContainerRegistry Register(Type from, Type to, string name) + { + Instance.RegisterType(from, to, name); + return this; + } + + /// + /// Resolves a given + /// + /// The service + /// The resolved Service + public object Resolve(Type type) + { + return Instance.Resolve(type); + } + + /// + /// Resolves a given + /// + /// The service + /// The service name/key used when registering the + /// The resolved Service + public object Resolve(Type type, string name) + { + return Instance.Resolve(type, name); + } + + /// + /// Resolves a given + /// + /// The service + /// Typed parameters to use when resolving the Service + /// The resolved Service + public object Resolve(Type type, params (Type Type, object Instance)[] parameters) + { + var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); + return Instance.Resolve(type, overrides); + } + + /// + /// Resolves a given + /// + /// The service + /// The service name/key used when registering the + /// Typed parameters to use when resolving the Service + /// The resolved Service + public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) + { + var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); + return Instance.Resolve(type, name, overrides); + } + + /// + /// Determines if a given service is registered + /// + /// The service + /// true if the service is registered. + public bool IsRegistered(Type type) + { + return Instance.IsRegistered(type); + } + + /// + /// Determines if a given service is registered with the specified name + /// + /// The service + /// The service name or key used + /// true if the service is registered. + public bool IsRegistered(Type type, string name) + { + return Instance.IsRegistered(type, name); + } + } +} diff --git a/src/Forms/Prism.DryIoc.Forms/Prism.DryIoc.Forms.csproj b/src/Forms/Prism.DryIoc.Forms/Prism.DryIoc.Forms.csproj index b7d6f46b11..bbb21a6130 100644 --- a/src/Forms/Prism.DryIoc.Forms/Prism.DryIoc.Forms.csproj +++ b/src/Forms/Prism.DryIoc.Forms/Prism.DryIoc.Forms.csproj @@ -11,11 +11,13 @@ - + + + diff --git a/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs b/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs index d0c6426803..a6991cb851 100644 --- a/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs +++ b/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs @@ -56,7 +56,9 @@ protected override IContainerExtension CreateContainerExtension() /// An instance of protected virtual Rules CreateContainerRules() => Rules.Default.WithAutoConcreteTypeResolution() .With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments)) - .WithoutFastExpressionCompiler() +#if __IOS__ + .WithUseInterpretation() +#endif .WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace); /// diff --git a/src/Forms/Prism.DryIoc.Forms/PrismIocExtensions.cs b/src/Forms/Prism.DryIoc.Forms/PrismIocExtensions.cs deleted file mode 100644 index 9b909bb0c0..0000000000 --- a/src/Forms/Prism.DryIoc.Forms/PrismIocExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using DryIoc; -using Prism.Ioc; - -namespace Prism.DryIoc -{ - public static class PrismIocExtensions - { - public static IContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - public static IContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} diff --git a/src/Forms/Prism.Forms/PrismApplicationBase.cs b/src/Forms/Prism.Forms/PrismApplicationBase.cs index 15380f956f..938773e1df 100644 --- a/src/Forms/Prism.Forms/PrismApplicationBase.cs +++ b/src/Forms/Prism.Forms/PrismApplicationBase.cs @@ -1,4 +1,4 @@ -using Prism.AppModel; +using Prism.AppModel; using Prism.Behaviors; using Prism.Common; using Prism.Events; @@ -183,7 +183,6 @@ protected virtual string GetNavigationSegmentNameFromType(Type pageType) => /// protected virtual void RegisterRequiredTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterInstance(_containerExtension); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); diff --git a/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj b/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj index 088a562f63..ffc4623ea9 100644 --- a/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj +++ b/src/Forms/Prism.Unity.Forms/Prism.Unity.Forms.csproj @@ -12,11 +12,13 @@ - + + + \ No newline at end of file diff --git a/src/Forms/Prism.Unity.Forms/PrismIocExtensions.cs b/src/Forms/Prism.Unity.Forms/PrismIocExtensions.cs deleted file mode 100644 index 0a1f5b8d65..0000000000 --- a/src/Forms/Prism.Unity.Forms/PrismIocExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Prism.Ioc; -using Unity; - -namespace Prism.Unity -{ - public static class PrismIocExtensions - { - public static IUnityContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - public static IUnityContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} diff --git a/src/Forms/Prism.Unity.Forms/UnityContainerExtension.cs b/src/Forms/Prism.Unity.Forms/UnityContainerExtension.cs deleted file mode 100644 index 44e2a02802..0000000000 --- a/src/Forms/Prism.Unity.Forms/UnityContainerExtension.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Linq; -using Prism.Ioc; -using Unity; -using Unity.Resolution; - -namespace Prism.Unity -{ - public class UnityContainerExtension : IContainerExtension - { - public IUnityContainer Instance { get; } - - public UnityContainerExtension(IUnityContainer container) => Instance = container; - - public void FinalizeExtension() { } - - public IContainerRegistry RegisterInstance(Type type, object instance) - { - Instance.RegisterInstance(type, instance); - return this; - } - - public IContainerRegistry RegisterInstance(Type type, object instance, string name) - { - Instance.RegisterInstance(type, name, instance); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to) - { - Instance.RegisterSingleton(from, to); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to, string name) - { - Instance.RegisterSingleton(from, to, name); - return this; - } - - public IContainerRegistry Register(Type from, Type to) - { - Instance.RegisterType(from, to); - return this; - } - - public IContainerRegistry Register(Type from, Type to, string name) - { - Instance.RegisterType(from, to, name); - return this; - } - - public object Resolve(Type type) - { - return Instance.Resolve(type); - } - - public object Resolve(Type type, string name) - { - return Instance.Resolve(type, name); - } - - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Instance.Resolve(type, overrides); - } - - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Instance.Resolve(type, name, overrides); - } - - public bool IsRegistered(Type type) - { - return Instance.IsRegistered(type); - } - - public bool IsRegistered(Type type, string name) - { - return Instance.IsRegistered(type, name); - } - } -} diff --git a/src/Prism.Core/Ioc/IContainerExtension.cs b/src/Prism.Core/Ioc/IContainerExtension.cs index 6ca3380fc3..48983b53bf 100644 --- a/src/Prism.Core/Ioc/IContainerExtension.cs +++ b/src/Prism.Core/Ioc/IContainerExtension.cs @@ -1,5 +1,9 @@ namespace Prism.Ioc { + /// + /// A strongly typed container extension + /// + /// The underlying root container public interface IContainerExtension : IContainerExtension { /// @@ -8,6 +12,9 @@ public interface IContainerExtension : IContainerExtension TContainer Instance { get; } } + /// + /// A generic abstraction for what Prism expects from a container + /// public interface IContainerExtension : IContainerProvider, IContainerRegistry { /// diff --git a/src/Prism.Core/Ioc/IContainerProvider.cs b/src/Prism.Core/Ioc/IContainerProvider.cs index d306f48ed8..64b13d9501 100644 --- a/src/Prism.Core/Ioc/IContainerProvider.cs +++ b/src/Prism.Core/Ioc/IContainerProvider.cs @@ -2,14 +2,41 @@ 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); } } diff --git a/src/Prism.Core/Ioc/IContainerProviderExtensions.cs b/src/Prism.Core/Ioc/IContainerProviderExtensions.cs index c56a9be8f0..6900060388 100644 --- a/src/Prism.Core/Ioc/IContainerProviderExtensions.cs +++ b/src/Prism.Core/Ioc/IContainerProviderExtensions.cs @@ -2,23 +2,54 @@ 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); diff --git a/src/Prism.Core/Ioc/IContainerRegistry.cs b/src/Prism.Core/Ioc/IContainerRegistry.cs index d19e6866a6..628b2f2147 100644 --- a/src/Prism.Core/Ioc/IContainerRegistry.cs +++ b/src/Prism.Core/Ioc/IContainerRegistry.cs @@ -2,22 +2,75 @@ 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 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); + /// + /// 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 index 2a9d017627..9ecec8e037 100644 --- a/src/Prism.Core/Ioc/IContainerRegistryExtensions.cs +++ b/src/Prism.Core/Ioc/IContainerRegistryExtensions.cs @@ -2,73 +2,172 @@ namespace Prism.Ioc { + /// + /// Provides Generic Type extensions for the + /// public static class IContainerRegistryExtensions { + /// + /// 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 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); } + /// + /// 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/Wpf/Prism.DryIoc.Wpf/Ioc/DryIocContainerExtension.cs b/src/Wpf/Prism.DryIoc.Wpf/Ioc/DryIocContainerExtension.cs deleted file mode 100644 index 928a687c35..0000000000 --- a/src/Wpf/Prism.DryIoc.Wpf/Ioc/DryIocContainerExtension.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Linq; -using DryIoc; -using Prism.Ioc; - -namespace Prism.DryIoc.Ioc -{ - public class DryIocContainerExtension : IContainerExtension - { - public IContainer Instance { get; } - - public DryIocContainerExtension(IContainer container) - { - Instance = container; - } - - public void FinalizeExtension() { } - - public IContainerRegistry RegisterInstance(Type type, object instance) - { - Instance.UseInstance(type, instance); - return this; - } - - public IContainerRegistry RegisterInstance(Type type, object instance, string name) - { - Instance.UseInstance(type, instance, serviceKey: name); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to) - { - Instance.Register(from, to, Reuse.Singleton); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to, string name) - { - Instance.Register(from, to, Reuse.Singleton, serviceKey: name); - return this; - } - - public IContainerRegistry Register(Type from, Type to) - { - Instance.Register(from, to); - return this; - } - - public IContainerRegistry Register(Type from, Type to, string name) - { - Instance.Register(from, to, serviceKey: name); - return this; - } - - public object Resolve(Type type) - { - return Instance.Resolve(type); - } - - public object Resolve(Type type, string name) - { - return Instance.Resolve(type, serviceKey: name); - } - - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - return Instance.Resolve(type, args: parameters.Select(p => p.Instance).ToArray()); - } - - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - return Instance.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray()); - } - - public bool IsRegistered(Type type) - { - return Instance.IsRegistered(type); - } - - public bool IsRegistered(Type type, string name) - { - return Instance.IsRegistered(type, name); - } - } -} diff --git a/src/Wpf/Prism.DryIoc.Wpf/Ioc/PrismIocExtensions.cs b/src/Wpf/Prism.DryIoc.Wpf/Ioc/PrismIocExtensions.cs deleted file mode 100644 index 9b909bb0c0..0000000000 --- a/src/Wpf/Prism.DryIoc.Wpf/Ioc/PrismIocExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using DryIoc; -using Prism.Ioc; - -namespace Prism.DryIoc -{ - public static class PrismIocExtensions - { - public static IContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - public static IContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} diff --git a/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs b/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs index 1ba04ac2a5..3d5163ef20 100644 --- a/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs +++ b/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs @@ -1,7 +1,6 @@ -using System; +using System; using System.Globalization; using DryIoc; -using Prism.DryIoc.Ioc; using Prism.DryIoc.Properties; using Prism.Events; using Prism.Ioc; @@ -128,7 +127,6 @@ protected override void RegisterFrameworkExceptionTypes() /// protected virtual void ConfigureContainer() { - Container.UseInstance(ContainerExtension); Container.UseInstance(Logger); Container.UseInstance(ModuleCatalog); diff --git a/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj b/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj index f0530bb316..10b01cf420 100644 --- a/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj +++ b/src/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj @@ -13,11 +13,13 @@ - + + + \ No newline at end of file diff --git a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs index e8d9e94ac8..b62fb1254c 100644 --- a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs +++ b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs @@ -1,8 +1,6 @@ -using DryIoc; -using Prism.DryIoc.Ioc; +using System; +using DryIoc; using Prism.Ioc; -using Prism.Regions; -using System; namespace Prism.DryIoc { diff --git a/src/Wpf/Prism.Unity.Wpf/Ioc/PrismIocExtensions.cs b/src/Wpf/Prism.Unity.Wpf/Ioc/PrismIocExtensions.cs deleted file mode 100644 index 22e3d9a6c8..0000000000 --- a/src/Wpf/Prism.Unity.Wpf/Ioc/PrismIocExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Prism.Ioc; -using Unity; - -namespace Prism.Unity -{ - public static class PrismIocExtensions - { - public static IUnityContainer GetContainer(this IContainerProvider containerProvider) - { - return ((IContainerExtension)containerProvider).Instance; - } - - public static IUnityContainer GetContainer(this IContainerRegistry containerRegistry) - { - return ((IContainerExtension)containerRegistry).Instance; - } - } -} \ No newline at end of file diff --git a/src/Wpf/Prism.Unity.Wpf/Ioc/UnityContainerExtension.cs b/src/Wpf/Prism.Unity.Wpf/Ioc/UnityContainerExtension.cs deleted file mode 100644 index 56630d5a97..0000000000 --- a/src/Wpf/Prism.Unity.Wpf/Ioc/UnityContainerExtension.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Linq; -using Prism.Ioc; -using Unity; -using Unity.Resolution; - -namespace Prism.Unity.Ioc -{ - public class UnityContainerExtension : IContainerExtension - { - public IUnityContainer Instance { get; } - - public UnityContainerExtension() : this(new UnityContainer()) { } - - public UnityContainerExtension(IUnityContainer container) => Instance = container; - - public void FinalizeExtension() { } - - public IContainerRegistry RegisterInstance(Type type, object instance) - { - Instance.RegisterInstance(type, instance); - return this; - } - - public IContainerRegistry RegisterInstance(Type type, object instance, string name) - { - Instance.RegisterInstance(type, name, instance); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to) - { - Instance.RegisterSingleton(from, to); - return this; - } - - public IContainerRegistry RegisterSingleton(Type from, Type to, string name) - { - Instance.RegisterSingleton(from, to, name); - return this; - } - - public IContainerRegistry Register(Type from, Type to) - { - Instance.RegisterType(from, to); - return this; - } - - public IContainerRegistry Register(Type from, Type to, string name) - { - Instance.RegisterType(from, to, name); - return this; - } - - public object Resolve(Type type) - { - return Instance.Resolve(type); - } - - public object Resolve(Type type, string name) - { - return Instance.Resolve(type, name); - } - - public object Resolve(Type type, params (Type Type, object Instance)[] parameters) - { - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Instance.Resolve(type, overrides); - } - - public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) - { - var overrides = parameters.Select(p => new DependencyOverride(p.Type, p.Instance)).ToArray(); - return Instance.Resolve(type, name, overrides); - } - - public bool IsRegistered(Type type) - { - return Instance.IsRegistered(type); - } - - public bool IsRegistered(Type type, string name) - { - return Instance.IsRegistered(type, name); - } - } -} diff --git a/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs b/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs index 402476233e..045586ae67 100644 --- a/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs +++ b/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs @@ -6,7 +6,6 @@ using Prism.Modularity; using Prism.Regions; using Prism.Services.Dialogs; -using Prism.Unity.Ioc; using Prism.Unity.Properties; using Unity; using Unity.Lifetime; @@ -125,7 +124,6 @@ protected virtual void ConfigureContainer() { this.Logger.Log(Resources.AddingUnityBootstrapperExtensionToContainer, Category.Debug, Priority.Low); - Container.RegisterInstance(ContainerExtension); Container.RegisterInstance(Logger); this.Container.RegisterInstance(this.ModuleCatalog); diff --git a/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj b/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj index ebcfb55f0c..f557cbf6be 100644 --- a/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj +++ b/src/Wpf/Prism.Unity.Wpf/Prism.Unity.Wpf.csproj @@ -20,4 +20,6 @@ + + \ No newline at end of file diff --git a/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs b/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs index 00d7d42e07..be4c933266 100644 --- a/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs +++ b/src/Wpf/Prism.Unity.Wpf/PrismApplication.cs @@ -1,7 +1,5 @@ using System; using Prism.Ioc; -using Prism.Regions; -using Prism.Unity.Ioc; using Unity; namespace Prism.Unity diff --git a/src/Wpf/Prism.Wpf/PrismApplicationBase.cs b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs index 1b9a0bf843..147807825b 100644 --- a/src/Wpf/Prism.Wpf/PrismApplicationBase.cs +++ b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; @@ -111,7 +111,6 @@ protected virtual IModuleCatalog CreateModuleCatalog() /// protected virtual void RegisterRequiredTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterInstance(_containerExtension); containerRegistry.RegisterInstance(_moduleCatalog); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton();