@@ -14,10 +14,8 @@ public static class IContainerRegistryExtensions
14
14
/// <typeparam name="TView">The Type of object to register as the dialog</typeparam>
15
15
/// <param name="containerRegistry"></param>
16
16
/// <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 ) =>
19
18
containerRegistry . RegisterForNavigation < TView > ( name ) ;
20
- }
21
19
22
20
/// <summary>
23
21
/// Registers an object to be used as a dialog in the IDialogService.
@@ -26,54 +24,46 @@ public static class IContainerRegistryExtensions
26
24
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the dialog</typeparam>
27
25
/// <param name="containerRegistry"></param>
28
26
/// <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 =>
31
28
containerRegistry . RegisterForNavigation < TView , TViewModel > ( name ) ;
32
- }
33
29
34
30
/// <summary>
35
31
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
36
32
/// </summary>
37
33
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
38
34
/// <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 =>
41
36
containerRegistry . Register ( typeof ( Dialogs . IDialogWindow ) , typeof ( TWindow ) ) ;
42
- }
43
37
44
38
/// <summary>
45
39
/// Registers an object that implements IDialogWindow to be used to host all dialogs in the IDialogService.
46
40
/// </summary>
47
41
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
48
42
/// <param name="containerRegistry"></param>
49
43
/// <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 =>
52
45
containerRegistry . Register ( typeof ( Dialogs . IDialogWindow ) , typeof ( TWindow ) , name ) ;
53
- }
54
46
55
47
/// <summary>
56
48
/// Registers an object for navigation
57
49
/// </summary>
58
50
/// <param name="containerRegistry"></param>
59
51
/// <param name="type">The type of object to register</param>
60
52
/// <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 ) =>
63
54
containerRegistry . Register ( typeof ( object ) , type , name ) ;
64
- }
65
55
66
56
/// <summary>
67
57
/// Registers an object for navigation.
68
58
/// </summary>
69
59
/// <typeparam name="T">The Type of the object to register as the view</typeparam>
70
60
/// <param name="containerRegistry"></param>
71
61
/// <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 )
73
63
{
74
64
Type type = typeof ( T ) ;
75
65
string viewName = string . IsNullOrWhiteSpace ( name ) ? type . Name : name ;
76
- containerRegistry . RegisterForNavigation ( type , viewName ) ;
66
+ return containerRegistry . RegisterForNavigation ( type , viewName ) ;
77
67
}
78
68
79
69
/// <summary>
@@ -83,18 +73,16 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
83
73
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the view</typeparam>
84
74
/// <param name="containerRegistry"></param>
85
75
/// <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 ) =>
88
77
containerRegistry . RegisterForNavigationWithViewModel < TViewModel > ( typeof ( TView ) , name ) ;
89
- }
90
78
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 )
92
80
{
93
81
if ( string . IsNullOrWhiteSpace ( name ) )
94
82
name = viewType . Name ;
95
83
96
84
ViewModelLocationProvider . Register ( viewType . ToString ( ) , typeof ( TViewModel ) ) ;
97
- containerRegistry . RegisterForNavigation ( viewType , name ) ;
85
+ return containerRegistry . RegisterForNavigation ( viewType , name ) ;
98
86
}
99
87
}
100
88
}
0 commit comments