6
6
7
7
namespace Prism ;
8
8
9
+ /// <summary>
10
+ /// Common extensions and overloads for the <see cref="PrismAppBuilder"/>
11
+ /// </summary>
9
12
public static class PrismAppBuilderExtensions
10
13
{
11
14
private static bool s_didRegisterModules = false ;
12
15
16
+ /// <summary>
17
+ /// Configures the <see cref="MauiAppBuilder"/> to use Prism with a callback for the <see cref="PrismAppBuilder"/>
18
+ /// </summary>
19
+ /// <param name="builder">The <see cref="MauiAppBuilder"/>.</param>
20
+ /// <param name="containerExtension">The instance of the <see cref="IContainerExtension"/> Prism should use.</param>
21
+ /// <param name="configurePrism">A delegate callback for the <see cref="PrismAppBuilder"/></param>
22
+ /// <returns>The <see cref="MauiAppBuilder"/>.</returns>
13
23
public static MauiAppBuilder UsePrism ( this MauiAppBuilder builder , IContainerExtension containerExtension , Action < PrismAppBuilder > configurePrism )
14
24
{
15
25
var prismBuilder = new PrismAppBuilder ( containerExtension , builder ) ;
16
26
configurePrism ( prismBuilder ) ;
17
27
return builder ;
18
28
}
19
29
30
+ /// <summary>
31
+ /// Provides a Delegate to invoke when the App is initialized.
32
+ /// </summary>
33
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
34
+ /// <param name="action">The delegate to invoke.</param>
35
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
20
36
public static PrismAppBuilder OnInitialized ( this PrismAppBuilder builder , Action action )
21
37
{
22
38
return builder . OnInitialized ( _ => action ( ) ) ;
@@ -45,9 +61,24 @@ public static PrismAppBuilder ConfigureModuleCatalog(this PrismAppBuilder builde
45
61
} ) ;
46
62
}
47
63
64
+ /// <summary>
65
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
66
+ /// this delegate will be invoked to do your initial Navigation.
67
+ /// </summary>
68
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
69
+ /// <param name="uri">The initial Navigation Uri.</param>
70
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
48
71
public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , string uri ) =>
49
72
builder . CreateWindow ( navigation => navigation . NavigateAsync ( uri ) ) ;
50
73
74
+ /// <summary>
75
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
76
+ /// this delegate will be invoked to do your initial Navigation.
77
+ /// </summary>
78
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
79
+ /// <param name="uri">The intial Navigation Uri.</param>
80
+ /// <param name="onError">A delegate callback if the navigation fails.</param>
81
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
51
82
public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , string uri , Action < Exception > onError ) =>
52
83
builder . CreateWindow ( async navigation =>
53
84
{
@@ -56,30 +87,78 @@ public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, string
56
87
onError ( result . Exception ) ;
57
88
} ) ;
58
89
59
- public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < IContainerProvider , INavigationService , Task > CreateWindowed ) =>
60
- builder . CreateWindow ( ( c , n ) => CreateWindowed ( c , n ) ) ;
90
+ /// <summary>
91
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
92
+ /// this delegate will be invoked to do your initial Navigation.
93
+ /// </summary>
94
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
95
+ /// <param name="createWindow">The Navigation Delegate.</param>
96
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
97
+ public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < IContainerProvider , INavigationService , Task > createWindow ) =>
98
+ builder . CreateWindow ( ( c , n ) => createWindow ( c , n ) ) ;
61
99
62
- public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < INavigationService , Task > CreateWindowed ) =>
63
- builder . CreateWindow ( ( _ , n ) => CreateWindowed ( n ) ) ;
100
+ /// <summary>
101
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
102
+ /// this delegate will be invoked to do your initial Navigation.
103
+ /// </summary>
104
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
105
+ /// <param name="createWindow">The Navigation Delegate.</param>
106
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
107
+ public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < INavigationService , Task > createWindow ) =>
108
+ builder . CreateWindow ( ( _ , n ) => createWindow ( n ) ) ;
64
109
65
- public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < INavigationService , INavigationBuilder > CreateWindowed ) =>
66
- builder . CreateWindow ( n => CreateWindowed ( n ) . NavigateAsync ( ) ) ;
110
+ /// <summary>
111
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
112
+ /// this delegate will be invoked to do your initial Navigation.
113
+ /// </summary>
114
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
115
+ /// <param name="createWindow">The Navigation Delegate.</param>
116
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
117
+ public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < INavigationService , INavigationBuilder > createWindow ) =>
118
+ builder . CreateWindow ( n => createWindow ( n ) . NavigateAsync ( ) ) ;
119
+
120
+ /// <summary>
121
+ /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
122
+ /// this delegate will be invoked to do your initial Navigation.
123
+ /// </summary>
124
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
125
+ /// <param name="createWindow">The Navigation Delegate.</param>
126
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
127
+ public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < IContainerProvider , INavigationService , INavigationBuilder > createWindow ) =>
128
+ builder . CreateWindow ( ( c , n ) => createWindow ( c , n ) . NavigateAsync ( ) ) ;
67
129
68
- public static PrismAppBuilder CreateWindow ( this PrismAppBuilder builder , Func < IContainerProvider , INavigationService , INavigationBuilder > CreateWindowed ) =>
69
- builder . CreateWindow ( ( c , n ) => CreateWindowed ( c , n ) . NavigateAsync ( ) ) ;
70
130
131
+ /// <summary>
132
+ /// Provides a configuration delegate to add services to the <see cref="MauiAppBuilder.Services"/>
133
+ /// </summary>
134
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
135
+ /// <param name="configureServices">Configuration Delegate</param>
136
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
71
137
public static PrismAppBuilder ConfigureServices ( this PrismAppBuilder builder , Action < IServiceCollection > configureServices )
72
138
{
73
139
configureServices ( builder . MauiBuilder . Services ) ;
74
140
return builder ;
75
141
}
76
142
143
+ /// <summary>
144
+ /// Provides a delegate to configure Logging within the Maui application
145
+ /// </summary>
146
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
147
+ /// <param name="configureLogging"></param>
148
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
77
149
public static PrismAppBuilder ConfigureLogging ( this PrismAppBuilder builder , Action < ILoggingBuilder > configureLogging )
78
150
{
79
151
configureLogging ( builder . MauiBuilder . Logging ) ;
80
152
return builder ;
81
153
}
82
154
155
+ /// <summary>
156
+ /// Provides a configuration Delegate to the <see cref="ViewModelLocationProvider"/> to set the
157
+ /// DefaultViewTypeToViewModelTypeResolver.
158
+ /// </summary>
159
+ /// <param name="builder">The <see cref="PrismAppBuilder"/>.</param>
160
+ /// <param name="viewModelTypeResolver">The Configuration Delegate for the Default ViewType to ViewModelType Resolver.</param>
161
+ /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
83
162
public static PrismAppBuilder ConfigureViewTypeToViewModelTypeResolver ( this PrismAppBuilder builder , Func < Type , Type > viewModelTypeResolver )
84
163
{
85
164
ViewModelLocationProvider . SetDefaultViewTypeToViewModelTypeResolver ( viewModelTypeResolver ) ;
0 commit comments