Browse Source

add COnsole app

master
2 9 months ago
parent
commit
273563d21b
  1. 17
      ConsoleApp/ConsoleApp1/ConsoleApp1.csproj
  2. 45
      ConsoleApp/ConsoleApp1/Program.cs
  3. 2
      WebApi/Properties/launchSettings.json

17
ConsoleApp/ConsoleApp1/ConsoleApp1.csproj

@ -5,4 +5,21 @@
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<OpenApiReference Include="..\..\swagger.json" CodeGenerator="NSwagCSharp" Namespace="NS" Link="OpenAPIs\swagger.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
</ItemGroup>
</Project> </Project>

45
ConsoleApp/ConsoleApp1/Program.cs

@ -1,4 +1,6 @@
using System; using System;
using System.Net.Http;
using System.Threading;
namespace ConsoleApp1 namespace ConsoleApp1
{ {
@ -6,7 +8,48 @@ namespace ConsoleApp1
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine("Hello World!"); using (var httpClient = new HttpClient())
{
Thread.Sleep(5000);
swaggerClient x = new swaggerClient("http://localhost:49746", httpClient);
while (true)
{
Field r = x.NewAsync().Result;
for (int ii = 0; ii < 5; ii++)
{
Thread.Sleep(500);
h_DrawField(r);
r = x.MoveAsync(r.Identifier).Result;
}
}
}
}
private static void h_DrawField(Field field)
{
Console.Clear();
h_WriteToConsole(field.Identifier, 4, 4, ConsoleColor.Gray);
foreach (var item in field.Figures)
{
ConsoleColor cc = item.FigureColor == 1 ? ConsoleColor.Blue : ConsoleColor.Green;
h_WriteToConsole("O", item.PosX, item.PosY, cc);
}
}
private static void h_WriteToConsole(string stringToWrite, int posX, int posY, ConsoleColor cc)
{
int realX = posX + 10;
int realY = posY + 10;
ConsoleColor oldCc = Console.ForegroundColor;
Console.ForegroundColor = cc;
Console.SetCursorPosition(realX, realY);
Console.Write(stringToWrite);
Console.ForegroundColor = oldCc;
} }
} }
} }

2
WebApi/Properties/launchSettings.json

@ -18,7 +18,7 @@
}, },
"WebApplication1": { "WebApplication1": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": "true", "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "http://localhost:5000", "applicationUrl": "http://localhost:5000",

Loading…
Cancel
Save