Skip to content

Commit 0ea820c

Browse files
authored
Merge pull request #3267 from PrismLibrary/dev/ds/registration-extensions
Align registration return type
2 parents ec09b17 + 0c9338b commit 0ea820c

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

Diff for: src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs

+10-22
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ public static class IContainerRegistryExtensions
1414
/// <typeparam name="TView">The Type of object to register as the dialog</typeparam>
1515
/// <param name="containerRegistry"></param>
1616
/// <param name="name">The unique name to register with the dialog.</param>
17-
public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
18-
{
17+
public static IContainerRegistry RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null) =>
1918
containerRegistry.RegisterForNavigation<TView>(name);
20-
}
2119

2220
/// <summary>
2321
/// Registers an object to be used as a dialog in the IDialogService.
@@ -26,54 +24,46 @@ public static class IContainerRegistryExtensions
2624
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the dialog</typeparam>
2725
/// <param name="containerRegistry"></param>
2826
/// <param name="name">The unique name to register with the dialog.</param>
29-
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
30-
{
27+
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 =>
3128
containerRegistry.RegisterForNavigation<TView, TViewModel>(name);
32-
}
3329

3430
/// <summary>
3531
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
3632
/// </summary>
3733
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
3834
/// <param name="containerRegistry"></param>
39-
public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
40-
{
35+
public static IContainerRegistry RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow =>
4136
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow));
42-
}
4337

4438
/// <summary>
4539
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
4640
/// </summary>
4741
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
4842
/// <param name="containerRegistry"></param>
4943
/// <param name="name">The name of the dialog window</param>
50-
public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
51-
{
44+
public static IContainerRegistry RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow =>
5245
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow), name);
53-
}
5446

5547
/// <summary>
5648
/// Registers an object for navigation
5749
/// </summary>
5850
/// <param name="containerRegistry"></param>
5951
/// <param name="type">The type of object to register</param>
6052
/// <param name="name">The unique name to register with the object.</param>
61-
public static void RegisterForNavigation(this IContainerRegistry containerRegistry, Type type, string name)
62-
{
53+
public static IContainerRegistry RegisterForNavigation(this IContainerRegistry containerRegistry, Type type, string name) =>
6354
containerRegistry.Register(typeof(object), type, name);
64-
}
6555

6656
/// <summary>
6757
/// Registers an object for navigation.
6858
/// </summary>
6959
/// <typeparam name="T">The Type of the object to register as the view</typeparam>
7060
/// <param name="containerRegistry"></param>
7161
/// <param name="name">The unique name to register with the object.</param>
72-
public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
62+
public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
7363
{
7464
Type type = typeof(T);
7565
string viewName = string.IsNullOrWhiteSpace(name) ? type.Name : name;
76-
containerRegistry.RegisterForNavigation(type, viewName);
66+
return containerRegistry.RegisterForNavigation(type, viewName);
7767
}
7868

7969
/// <summary>
@@ -83,18 +73,16 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
8373
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the view</typeparam>
8474
/// <param name="containerRegistry"></param>
8575
/// <param name="name">The unique name to register with the view</param>
86-
public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
87-
{
76+
public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) =>
8877
containerRegistry.RegisterForNavigationWithViewModel<TViewModel>(typeof(TView), name);
89-
}
9078

91-
private static void RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
79+
private static IContainerRegistry RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
9280
{
9381
if (string.IsNullOrWhiteSpace(name))
9482
name = viewType.Name;
9583

9684
ViewModelLocationProvider.Register(viewType.ToString(), typeof(TViewModel));
97-
containerRegistry.RegisterForNavigation(viewType, name);
85+
return containerRegistry.RegisterForNavigation(viewType, name);
9886
}
9987
}
10088
}

0 commit comments

Comments
 (0)