diff --git a/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs b/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
index e66116438..4afdfffd3 100644
--- a/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
+++ b/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
@@ -14,10 +14,8 @@ public static class IContainerRegistryExtensions
/// The Type of object to register as the dialog
///
/// The unique name to register with the dialog.
- public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
- {
+ public static IContainerRegistry RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null) =>
containerRegistry.RegisterForNavigation(name);
- }
///
/// Registers an object to be used as a dialog in the IDialogService.
@@ -26,20 +24,16 @@ public static class IContainerRegistryExtensions
/// The ViewModel to use as the DataContext for the dialog
///
/// The unique name to register with the dialog.
- public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware
- {
+ public static IContainerRegistry RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware =>
containerRegistry.RegisterForNavigation(name);
- }
///
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
///
/// The Type of the Window class that will be used to host dialogs in the IDialogService
///
- public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
- {
+ public static IContainerRegistry RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow =>
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow));
- }
///
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
@@ -47,10 +41,8 @@ public static class IContainerRegistryExtensions
/// The Type of the Window class that will be used to host dialogs in the IDialogService
///
/// The name of the dialog window
- public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
- {
+ public static IContainerRegistry RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow =>
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow), name);
- }
///
/// Registers an object for navigation
@@ -58,10 +50,8 @@ public static class IContainerRegistryExtensions
///
/// The type of object to register
/// The unique name to register with the object.
- public static void RegisterForNavigation(this IContainerRegistry containerRegistry, Type type, string name)
- {
+ public static IContainerRegistry RegisterForNavigation(this IContainerRegistry containerRegistry, Type type, string name) =>
containerRegistry.Register(typeof(object), type, name);
- }
///
/// Registers an object for navigation.
@@ -69,11 +59,11 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
/// The Type of the object to register as the view
///
/// The unique name to register with the object.
- public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
+ public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
{
Type type = typeof(T);
string viewName = string.IsNullOrWhiteSpace(name) ? type.Name : name;
- containerRegistry.RegisterForNavigation(type, viewName);
+ return containerRegistry.RegisterForNavigation(type, viewName);
}
///
@@ -83,18 +73,16 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
/// The ViewModel to use as the DataContext for the view
///
/// The unique name to register with the view
- public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
- {
+ public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), name);
- }
- private static void RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
+ private static IContainerRegistry RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
{
if (string.IsNullOrWhiteSpace(name))
name = viewType.Name;
ViewModelLocationProvider.Register(viewType.ToString(), typeof(TViewModel));
- containerRegistry.RegisterForNavigation(viewType, name);
+ return containerRegistry.RegisterForNavigation(viewType, name);
}
}
}