diff --git a/exercises/04-integration/after/Divergent.Customers.API/ConsoleEx.cs b/exercises/04-integration/after/Divergent.Customers.API/ConsoleEx.cs new file mode 100644 index 000000000..ea9bedcf1 --- /dev/null +++ b/exercises/04-integration/after/Divergent.Customers.API/ConsoleEx.cs @@ -0,0 +1,15 @@ +using System.Runtime.InteropServices; + +namespace Divergent.Customers.API +{ + static class ConsoleEx + { + public static void TryMinimize() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + WindowsNativeMethods.ShowWindow(WindowsNativeMethods.GetConsoleWindow(), WindowsNativeMethods.SW_SHOWMINIMIZED); + } + } + } +} diff --git a/exercises/04-integration/after/Divergent.Customers.API/Divergent.Customers.API.csproj b/exercises/04-integration/after/Divergent.Customers.API/Divergent.Customers.API.csproj index a9d402252..f14ded808 100644 --- a/exercises/04-integration/after/Divergent.Customers.API/Divergent.Customers.API.csproj +++ b/exercises/04-integration/after/Divergent.Customers.API/Divergent.Customers.API.csproj @@ -3,7 +3,7 @@ latest Exe - net461 + net471 diff --git a/exercises/04-integration/after/Divergent.Customers.API/Program.cs b/exercises/04-integration/after/Divergent.Customers.API/Program.cs index 1c140f202..d0b94bb7a 100644 --- a/exercises/04-integration/after/Divergent.Customers.API/Program.cs +++ b/exercises/04-integration/after/Divergent.Customers.API/Program.cs @@ -10,6 +10,7 @@ class Program public static async Task Main(string[] args) { Console.Title = MethodBase.GetCurrentMethod().DeclaringType.Namespace; + ConsoleEx.TryMinimize(); var tcs = new TaskCompletionSource(); Console.CancelKeyPress += (sender, e) => { tcs.SetResult(null); }; diff --git a/exercises/04-integration/after/Divergent.Customers.API/WindowsNativeMethods.cs b/exercises/04-integration/after/Divergent.Customers.API/WindowsNativeMethods.cs new file mode 100644 index 000000000..0778acf53 --- /dev/null +++ b/exercises/04-integration/after/Divergent.Customers.API/WindowsNativeMethods.cs @@ -0,0 +1,16 @@ +using System; +using System.Runtime.InteropServices; + +namespace Divergent.Customers.API +{ + static class WindowsNativeMethods + { + public const int SW_SHOWMINIMIZED = 2; + + [DllImport("kernel32.dll")] + public static extern IntPtr GetConsoleWindow(); + + [DllImport("user32.dll")] + public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + } +}