diff --git a/Source/Prism/Ioc/IContainerRegistry.cs b/Source/Prism/Ioc/IContainerRegistry.cs index 2b89ad980..d19e6866a 100644 --- a/Source/Prism/Ioc/IContainerRegistry.cs +++ b/Source/Prism/Ioc/IContainerRegistry.cs @@ -4,17 +4,17 @@ namespace Prism.Ioc { public interface IContainerRegistry { - void RegisterInstance(Type type, object instance); + IContainerRegistry RegisterInstance(Type type, object instance); - void RegisterInstance(Type type, object instance, string name); + IContainerRegistry RegisterInstance(Type type, object instance, string name); - void RegisterSingleton(Type from, Type to); + IContainerRegistry RegisterSingleton(Type from, Type to); - void RegisterSingleton(Type from, Type to, string name); + IContainerRegistry RegisterSingleton(Type from, Type to, string name); - void Register(Type from, Type to); + IContainerRegistry Register(Type from, Type to); - void Register(Type from, Type to, string name); + IContainerRegistry Register(Type from, Type to, string name); bool IsRegistered(Type type); diff --git a/Source/Prism/Ioc/IContainerRegistryExtensions.cs b/Source/Prism/Ioc/IContainerRegistryExtensions.cs index 4f88814df..2a9d01762 100644 --- a/Source/Prism/Ioc/IContainerRegistryExtensions.cs +++ b/Source/Prism/Ioc/IContainerRegistryExtensions.cs @@ -4,64 +4,64 @@ namespace Prism.Ioc { public static class IContainerRegistryExtensions { - public static void RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance) + public static IContainerRegistry RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance) { - containerRegistry.RegisterInstance(typeof(TInterface), instance); + return containerRegistry.RegisterInstance(typeof(TInterface), instance); } - public static void RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance, string name) + public static IContainerRegistry RegisterInstance(this IContainerRegistry containerRegistry, TInterface instance, string name) { - containerRegistry.RegisterInstance(typeof(TInterface), instance, name); + return containerRegistry.RegisterInstance(typeof(TInterface), instance, name); } - public static void RegisterSingleton(this IContainerRegistry containerRegistry, Type type) + public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, Type type) { - containerRegistry.RegisterSingleton(type, type); + return containerRegistry.RegisterSingleton(type, type); } - public static void RegisterSingleton(this IContainerRegistry containerRegistry) where TTo : TFrom + public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry) where TTo : TFrom { - containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo)); + return containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo)); } - public static void RegisterSingleton(this IContainerRegistry containerRegistry, string name) where TTo : TFrom + public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry, string name) where TTo : TFrom { - containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo), name); + return containerRegistry.RegisterSingleton(typeof(TFrom), typeof(TTo), name); } - public static void RegisterSingleton(this IContainerRegistry containerRegistry) + public static IContainerRegistry RegisterSingleton(this IContainerRegistry containerRegistry) { - containerRegistry.RegisterSingleton(typeof(T)); + return containerRegistry.RegisterSingleton(typeof(T)); } - public static void Register(this IContainerRegistry containerRegistry, Type type) + public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Type type) { - containerRegistry.Register(type, type); + return containerRegistry.Register(type, type); } - public static void Register(this IContainerRegistry containerRegistry) + public static IContainerRegistry Register(this IContainerRegistry containerRegistry) { - containerRegistry.Register(typeof(T)); + return containerRegistry.Register(typeof(T)); } - public static void Register(this IContainerRegistry containerRegistry, Type type, string name) + public static IContainerRegistry Register(this IContainerRegistry containerRegistry, Type type, string name) { - containerRegistry.Register(type, type, name); + return containerRegistry.Register(type, type, name); } - public static void Register(this IContainerRegistry containerRegistry, string name) + public static IContainerRegistry Register(this IContainerRegistry containerRegistry, string name) { - containerRegistry.Register(typeof(T), name); + return containerRegistry.Register(typeof(T), name); } - public static void Register(this IContainerRegistry containerRegistry) where TTo : TFrom + public static IContainerRegistry Register(this IContainerRegistry containerRegistry) where TTo : TFrom { - containerRegistry.Register(typeof(TFrom), typeof(TTo)); + return containerRegistry.Register(typeof(TFrom), typeof(TTo)); } - public static void Register(this IContainerRegistry containerRegistry, string name) where TTo : TFrom + public static IContainerRegistry Register(this IContainerRegistry containerRegistry, string name) where TTo : TFrom { - containerRegistry.Register(typeof(TFrom), typeof(TTo), name); + return containerRegistry.Register(typeof(TFrom), typeof(TTo), name); } public static bool IsRegistered(this IContainerRegistry containerRegistry) diff --git a/Source/Windows10/Prism.DryIoc.Windows/DryIocContainerExtension.cs b/Source/Windows10/Prism.DryIoc.Windows/DryIocContainerExtension.cs index 31c1bd26b..239af5622 100644 --- a/Source/Windows10/Prism.DryIoc.Windows/DryIocContainerExtension.cs +++ b/Source/Windows10/Prism.DryIoc.Windows/DryIocContainerExtension.cs @@ -16,34 +16,40 @@ public DryIocContainerExtension(IContainer container) public void FinalizeExtension() { } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { Instance.UseInstance(type, instance); + return this; } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { Instance.UseInstance(type, instance, serviceKey: name); + return this; } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { Instance.Register(from, to, Reuse.Singleton); + return this; } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { Instance.Register(from, to, Reuse.Singleton, serviceKey: name); + return this; } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { Instance.Register(from, to); + return this; } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { Instance.Register(from, to, serviceKey: name); + return this; } public object Resolve(Type type) diff --git a/Source/Windows10/Prism.Unity.Windows/UnityContainerExtension.cs b/Source/Windows10/Prism.Unity.Windows/UnityContainerExtension.cs index 02624dd0c..363edb86d 100644 --- a/Source/Windows10/Prism.Unity.Windows/UnityContainerExtension.cs +++ b/Source/Windows10/Prism.Unity.Windows/UnityContainerExtension.cs @@ -14,34 +14,40 @@ public sealed class UnityContainerExtension : IContainerExtension public void FinalizeExtension() { } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { Instance.RegisterInstance(type, instance); + return this; } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { Instance.RegisterInstance(type, name, instance); + return this; } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { Instance.RegisterSingleton(from, to); + return this; } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { Instance.RegisterSingleton(from, to, name); + return this; } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { Instance.RegisterType(from, to); + return this; } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { Instance.RegisterType(from, to, name); + return this; } public object Resolve(Type type) diff --git a/Source/Wpf/Prism.Wpf.Tests/Mocks/MockContainerAdapter.cs b/Source/Wpf/Prism.Wpf.Tests/Mocks/MockContainerAdapter.cs index 3db7c0c23..7ef6a106b 100644 --- a/Source/Wpf/Prism.Wpf.Tests/Mocks/MockContainerAdapter.cs +++ b/Source/Wpf/Prism.Wpf.Tests/Mocks/MockContainerAdapter.cs @@ -23,32 +23,32 @@ public bool IsRegistered(Type type, string name) throw new NotImplementedException(); } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { throw new NotImplementedException(); } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { throw new NotImplementedException(); } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { throw new NotImplementedException(); } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { throw new NotImplementedException(); } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { throw new NotImplementedException(); } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { throw new NotImplementedException(); } diff --git a/Source/Xamarin/Prism.DryIoc.Forms/DryIocContainerExtension.cs b/Source/Xamarin/Prism.DryIoc.Forms/DryIocContainerExtension.cs index d1283493d..cb7f342e5 100644 --- a/Source/Xamarin/Prism.DryIoc.Forms/DryIocContainerExtension.cs +++ b/Source/Xamarin/Prism.DryIoc.Forms/DryIocContainerExtension.cs @@ -16,34 +16,40 @@ public DryIocContainerExtension(IContainer container) public void FinalizeExtension() { } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { Instance.UseInstance(type, instance); + return this; } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { Instance.UseInstance(type, instance, serviceKey: name); + return this; } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { Instance.Register(from, to, Reuse.Singleton); + return this; } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { Instance.Register(from, to, Reuse.Singleton, serviceKey: name); + return this; } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { Instance.Register(from, to); + return this; } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { Instance.Register(from, to, serviceKey: name); + return this; } public object Resolve(Type type) diff --git a/Source/Xamarin/Prism.Forms.Tests/Mocks/PageNavigationContainerMock.cs b/Source/Xamarin/Prism.Forms.Tests/Mocks/PageNavigationContainerMock.cs index 51c2354a6..3b5e226e1 100644 --- a/Source/Xamarin/Prism.Forms.Tests/Mocks/PageNavigationContainerMock.cs +++ b/Source/Xamarin/Prism.Forms.Tests/Mocks/PageNavigationContainerMock.cs @@ -20,13 +20,14 @@ public object GetInstance(string key) return null; } - public void Register(string key, Type type) + public IContainerRegistry Register(string key, Type type) { if (!_registeredPages.ContainsKey(key)) { _registeredPages.Add(key, type); PageNavigationRegistry.Register(key, type); } + return this; } public object Resolve(Type type) @@ -39,37 +40,37 @@ public object Resolve(Type type, string name) throw new NotImplementedException(); } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { throw new NotImplementedException(); } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { throw new NotImplementedException(); } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { throw new NotImplementedException(); } - public void RegisterSingleton(Type type) + public IContainerRegistry RegisterSingleton(Type type) { throw new NotImplementedException(); } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { throw new NotImplementedException(); } - public void RegisterType(Type type) + public IContainerRegistry RegisterType(Type type) { throw new NotImplementedException(); } - public void RegisterType(Type type, string name) + public IContainerRegistry RegisterType(Type type, string name) { throw new NotImplementedException(); } @@ -94,12 +95,12 @@ public bool IsRegistered(Type type, string name) throw new NotImplementedException(); } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { throw new NotImplementedException(); } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { throw new NotImplementedException(); } diff --git a/Source/Xamarin/Prism.Unity.Forms/UnityContainerExtension.cs b/Source/Xamarin/Prism.Unity.Forms/UnityContainerExtension.cs index 71142f167..44e2a0280 100644 --- a/Source/Xamarin/Prism.Unity.Forms/UnityContainerExtension.cs +++ b/Source/Xamarin/Prism.Unity.Forms/UnityContainerExtension.cs @@ -14,34 +14,40 @@ public class UnityContainerExtension : IContainerExtension public void FinalizeExtension() { } - public void RegisterInstance(Type type, object instance) + public IContainerRegistry RegisterInstance(Type type, object instance) { Instance.RegisterInstance(type, instance); + return this; } - public void RegisterInstance(Type type, object instance, string name) + public IContainerRegistry RegisterInstance(Type type, object instance, string name) { Instance.RegisterInstance(type, name, instance); + return this; } - public void RegisterSingleton(Type from, Type to) + public IContainerRegistry RegisterSingleton(Type from, Type to) { Instance.RegisterSingleton(from, to); + return this; } - public void RegisterSingleton(Type from, Type to, string name) + public IContainerRegistry RegisterSingleton(Type from, Type to, string name) { Instance.RegisterSingleton(from, to, name); + return this; } - public void Register(Type from, Type to) + public IContainerRegistry Register(Type from, Type to) { Instance.RegisterType(from, to); + return this; } - public void Register(Type from, Type to, string name) + public IContainerRegistry Register(Type from, Type to, string name) { Instance.RegisterType(from, to, name); + return this; } public object Resolve(Type type)