예제 #1
0
 /// <summary>
 /// Tries to set the current target application to the specified one.
 /// </summary>
 /// <param name="sname"></param>
 /// <param name="app"></param>
 /// <returns></returns>
 public static bool TrySetCurrentApp(this PSCmdlet cmdlet, string sname, out TargetApp app)
 {
     if (!cmdlet.TryGetKnownApp(sname, out app))
     {
         return(false);
     }
     cmdlet.GetPppmState().CurrentTargetApp?.DefaultRepository?.UnregisterDefaultRepository();
     cmdlet.GetPppmState().CurrentTargetApp = app;
     app.DefaultRepository.RegisterDefaultRepository();
     return(true);
 }
예제 #2
0
 public static bool TryGetKnownApp(this PSCmdlet cmdlet, string sname, out TargetApp app) =>
 cmdlet.GetPppmState().KnownTargetApps.TryGetValue(sname, out app);