File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
7979 {
8080 switch ( dataSource . ToString ( ) )
8181 {
82- case "Rest" : UseRest ( ) ; break ;
82+ case "Rest" : if ( ! UseRest ( ) ) UseSqlite ( ) ; break ;
8383 default : UseSqlite ( ) ; break ;
8484 }
8585 }
@@ -125,11 +125,19 @@ public static void UseSqlite()
125125 /// Configures the app to use the REST data source. For convenience, a read-only source is provided.
126126 /// You can also deploy your own copy of the REST service locally or to Azure. See the README for details.
127127 /// </summary>
128- public static void UseRest ( )
128+ public static bool UseRest ( )
129129 {
130- var accessToken = Task . Run ( async ( ) => await MsalHelper . GetTokenAsync ( Constants . WebApiScopes ) ) . Result ;
130+ try
131+ {
132+ var accessToken = Task . Run ( async ( ) => await MsalHelper . GetTokenAsync ( Constants . WebApiScopes ) ) . Result ;
131133
132- Repository = new RestContosoRepository ( $ "{ Constants . ApiUrl } /api/", accessToken ) ;
134+ Repository = new RestContosoRepository ( $ "{ Constants . ApiUrl } /api/", accessToken ) ;
135+ }
136+ catch ( System . Exception ex )
137+ {
138+ return false ;
139+ }
140+ return true ;
133141 }
134142 }
135- }
143+ }
You can’t perform that action at this time.
0 commit comments