From 339fac6010e44f638f8556f38f8c511719e5f834 Mon Sep 17 00:00:00 2001 From: wanggaofeng <15601716045@163.com> Date: Tue, 2 Jan 2024 14:25:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0VS=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpClientStudy.Core/Class1.cs | 7 +++ .../HttpClientStudy.Core.csproj | 13 ++++++ HttpClientStudy.Model/Class1.cs | 7 +++ .../HttpClientStudy.Model.csproj | 9 ++++ HttpClientStudy.UnitTest/GlobalUsings.cs | 1 + .../HttpClientStudy.UnitTest.csproj | 29 +++++++++++++ HttpClientStudy.UnitTest/UnitTest1.cs | 11 +++++ .../Controllers/WeatherForecastController.cs | 33 ++++++++++++++ .../HttpClientStudy.WebApp.csproj | 18 ++++++++ .../HttpClientStudy.WebApp.http | 6 +++ HttpClientStudy.WebApp/Program.cs | 34 +++++++++++++++ .../Properties/launchSettings.json | 31 +++++++++++++ HttpClientStudy.WebApp/WeatherForecast.cs | 13 ++++++ .../appsettings.Development.json | 8 ++++ HttpClientStudy.WebApp/appsettings.json | 9 ++++ HttpClientStudy.sln | 43 +++++++++++++++++++ 16 files changed, 272 insertions(+) create mode 100644 HttpClientStudy.Core/Class1.cs create mode 100644 HttpClientStudy.Core/HttpClientStudy.Core.csproj create mode 100644 HttpClientStudy.Model/Class1.cs create mode 100644 HttpClientStudy.Model/HttpClientStudy.Model.csproj create mode 100644 HttpClientStudy.UnitTest/GlobalUsings.cs create mode 100644 HttpClientStudy.UnitTest/HttpClientStudy.UnitTest.csproj create mode 100644 HttpClientStudy.UnitTest/UnitTest1.cs create mode 100644 HttpClientStudy.WebApp/Controllers/WeatherForecastController.cs create mode 100644 HttpClientStudy.WebApp/HttpClientStudy.WebApp.csproj create mode 100644 HttpClientStudy.WebApp/HttpClientStudy.WebApp.http create mode 100644 HttpClientStudy.WebApp/Program.cs create mode 100644 HttpClientStudy.WebApp/Properties/launchSettings.json create mode 100644 HttpClientStudy.WebApp/WeatherForecast.cs create mode 100644 HttpClientStudy.WebApp/appsettings.Development.json create mode 100644 HttpClientStudy.WebApp/appsettings.json create mode 100644 HttpClientStudy.sln diff --git a/HttpClientStudy.Core/Class1.cs b/HttpClientStudy.Core/Class1.cs new file mode 100644 index 0000000..5fc3f40 --- /dev/null +++ b/HttpClientStudy.Core/Class1.cs @@ -0,0 +1,7 @@ +namespace HttpClientStudy.Core +{ + public class Class1 + { + + } +} diff --git a/HttpClientStudy.Core/HttpClientStudy.Core.csproj b/HttpClientStudy.Core/HttpClientStudy.Core.csproj new file mode 100644 index 0000000..0ccbef8 --- /dev/null +++ b/HttpClientStudy.Core/HttpClientStudy.Core.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/HttpClientStudy.Model/Class1.cs b/HttpClientStudy.Model/Class1.cs new file mode 100644 index 0000000..6a829c0 --- /dev/null +++ b/HttpClientStudy.Model/Class1.cs @@ -0,0 +1,7 @@ +namespace HttpClientStudy.Model +{ + public class Class1 + { + + } +} diff --git a/HttpClientStudy.Model/HttpClientStudy.Model.csproj b/HttpClientStudy.Model/HttpClientStudy.Model.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/HttpClientStudy.Model/HttpClientStudy.Model.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/HttpClientStudy.UnitTest/GlobalUsings.cs b/HttpClientStudy.UnitTest/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/HttpClientStudy.UnitTest/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/HttpClientStudy.UnitTest/HttpClientStudy.UnitTest.csproj b/HttpClientStudy.UnitTest/HttpClientStudy.UnitTest.csproj new file mode 100644 index 0000000..8c57447 --- /dev/null +++ b/HttpClientStudy.UnitTest/HttpClientStudy.UnitTest.csproj @@ -0,0 +1,29 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/HttpClientStudy.UnitTest/UnitTest1.cs b/HttpClientStudy.UnitTest/UnitTest1.cs new file mode 100644 index 0000000..e307966 --- /dev/null +++ b/HttpClientStudy.UnitTest/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace HttpClientStudy.UnitTest +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/HttpClientStudy.WebApp/Controllers/WeatherForecastController.cs b/HttpClientStudy.WebApp/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..34bcdec --- /dev/null +++ b/HttpClientStudy.WebApp/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace HttpClientStudy.WebApp.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/HttpClientStudy.WebApp/HttpClientStudy.WebApp.csproj b/HttpClientStudy.WebApp/HttpClientStudy.WebApp.csproj new file mode 100644 index 0000000..3888da3 --- /dev/null +++ b/HttpClientStudy.WebApp/HttpClientStudy.WebApp.csproj @@ -0,0 +1,18 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + diff --git a/HttpClientStudy.WebApp/HttpClientStudy.WebApp.http b/HttpClientStudy.WebApp/HttpClientStudy.WebApp.http new file mode 100644 index 0000000..93ed8b9 --- /dev/null +++ b/HttpClientStudy.WebApp/HttpClientStudy.WebApp.http @@ -0,0 +1,6 @@ +@HttpClientStudy.WebApp_HostAddress = http://localhost:5189 + +GET {{HttpClientStudy.WebApp_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/HttpClientStudy.WebApp/Program.cs b/HttpClientStudy.WebApp/Program.cs new file mode 100644 index 0000000..6edcd90 --- /dev/null +++ b/HttpClientStudy.WebApp/Program.cs @@ -0,0 +1,34 @@ + +namespace HttpClientStudy.WebApp +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + + builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } + } +} diff --git a/HttpClientStudy.WebApp/Properties/launchSettings.json b/HttpClientStudy.WebApp/Properties/launchSettings.json new file mode 100644 index 0000000..09a0d0c --- /dev/null +++ b/HttpClientStudy.WebApp/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:24286", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5189", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/HttpClientStudy.WebApp/WeatherForecast.cs b/HttpClientStudy.WebApp/WeatherForecast.cs new file mode 100644 index 0000000..36cc3e2 --- /dev/null +++ b/HttpClientStudy.WebApp/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace HttpClientStudy.WebApp +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/HttpClientStudy.WebApp/appsettings.Development.json b/HttpClientStudy.WebApp/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/HttpClientStudy.WebApp/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/HttpClientStudy.WebApp/appsettings.json b/HttpClientStudy.WebApp/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/HttpClientStudy.WebApp/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/HttpClientStudy.sln b/HttpClientStudy.sln new file mode 100644 index 0000000..699e9e6 --- /dev/null +++ b/HttpClientStudy.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientStudy.Core", "HttpClientStudy.Core\HttpClientStudy.Core.csproj", "{FFE91C0C-A652-471A-8740-E30E1CD8CE43}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientStudy.Model", "HttpClientStudy.Model\HttpClientStudy.Model.csproj", "{E1FB0047-B5D7-48D5-9220-21E01592FF03}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientStudy.WebApp", "HttpClientStudy.WebApp\HttpClientStudy.WebApp.csproj", "{D073CC8A-FB75-4957-AF64-5A2C695D93E6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientStudy.UnitTest", "HttpClientStudy.UnitTest\HttpClientStudy.UnitTest.csproj", "{A64DAAE3-9FDA-4B37-AE87-FA0812DBF5A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FFE91C0C-A652-471A-8740-E30E1CD8CE43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFE91C0C-A652-471A-8740-E30E1CD8CE43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFE91C0C-A652-471A-8740-E30E1CD8CE43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFE91C0C-A652-471A-8740-E30E1CD8CE43}.Release|Any CPU.Build.0 = Release|Any CPU + {E1FB0047-B5D7-48D5-9220-21E01592FF03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1FB0047-B5D7-48D5-9220-21E01592FF03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1FB0047-B5D7-48D5-9220-21E01592FF03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1FB0047-B5D7-48D5-9220-21E01592FF03}.Release|Any CPU.Build.0 = Release|Any CPU + {D073CC8A-FB75-4957-AF64-5A2C695D93E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D073CC8A-FB75-4957-AF64-5A2C695D93E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D073CC8A-FB75-4957-AF64-5A2C695D93E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D073CC8A-FB75-4957-AF64-5A2C695D93E6}.Release|Any CPU.Build.0 = Release|Any CPU + {A64DAAE3-9FDA-4B37-AE87-FA0812DBF5A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A64DAAE3-9FDA-4B37-AE87-FA0812DBF5A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A64DAAE3-9FDA-4B37-AE87-FA0812DBF5A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A64DAAE3-9FDA-4B37-AE87-FA0812DBF5A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F88C0CDB-806E-4AC6-A3BD-A60964216F23} + EndGlobalSection +EndGlobal