public static void CheckingIfNamedProfileExists() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var(exists, _) = profiles.Use("does-not-exist"); // Do something else if it doesn't exist WriteOut.Line($"The profile does {(exists ? "" : "not")} exist."); }
public static void Match() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); profiles .Use("does-not-exist") .Match( () => { WriteOut.Line("The profile does not exist."); }, WriteOut.EnvironmentalVariables); }
public static void UseNamedProfile() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var(exists, profile) = profiles.Use("does-not-exist"); try { // You can not just use it. If the profile is missing, it will blow up! WriteOut.EnvironmentalVariables(profile); } catch (NullReferenceException) { WriteOut.Line("The profile was null and it caused an exception!"); } }