diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj.user b/CSharp/SQLTutorial/Cors-1-Start/Cors-1-Start.csproj.user
similarity index 100%
rename from CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj.user
rename to CSharp/SQLTutorial/Cors-1-Start/Cors-1-Start.csproj.user
diff --git a/CSharp/SQLTutorial/EFCore-3-AccessToken/EFCore-3-AccessToken.csproj b/CSharp/SQLTutorial/EFCore-3-AccessToken/EFCore-3-AccessToken.csproj
new file mode 100644
index 0000000..2811018
--- /dev/null
+++ b/CSharp/SQLTutorial/EFCore-3-AccessToken/EFCore-3-AccessToken.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net6.0
+ enable
+ enable
+ EFCore_3_AccessToken
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CSharp/SQLTutorial/EFCore-3-AccessToken/Program.cs b/CSharp/SQLTutorial/EFCore-3-AccessToken/Program.cs
new file mode 100644
index 0000000..6f41110
--- /dev/null
+++ b/CSharp/SQLTutorial/EFCore-3-AccessToken/Program.cs
@@ -0,0 +1,49 @@
+using System.Text;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.Services.AddAuthentication(options =>
+{
+ options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
+ options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+}).AddJwtBearer(options =>
+{
+ options.RequireHttpsMetadata = false;
+ options.SaveToken = true;
+ options.TokenValidationParameters = new TokenValidationParameters
+ {
+ ValidateIssuerSigningKey = true,
+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("123456789134567813")),
+ ValidIssuer = "Bunny",
+ ValidateAudience = true,
+ ValidAudience = "StudentApi",
+ ValidateLifetime = true
+ };
+});
+
+// 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.UseHttpsRedirection();
+// 身份验证
+app.UseAuthentication();
+// 授权
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
\ No newline at end of file
diff --git a/CSharp/SQLTutorial/EFCore-3-AccessToken/Properties/launchSettings.json b/CSharp/SQLTutorial/EFCore-3-AccessToken/Properties/launchSettings.json
new file mode 100644
index 0000000..265be8d
--- /dev/null
+++ b/CSharp/SQLTutorial/EFCore-3-AccessToken/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+锘縶
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:23235",
+ "sslPort": 44370
+ }
+ },
+ "profiles": {
+ "EFCore_3_AccessToken": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7264;http://localhost:5093",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/appsettings.Development.json b/CSharp/SQLTutorial/EFCore-3-AccessToken/appsettings.Development.json
similarity index 100%
rename from CSharp/WPFTutorial/ASP-1-WebApi/appsettings.Development.json
rename to CSharp/SQLTutorial/EFCore-3-AccessToken/appsettings.Development.json
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/appsettings.json b/CSharp/SQLTutorial/EFCore-3-AccessToken/appsettings.json
similarity index 100%
rename from CSharp/WPFTutorial/ASP-1-WebApi/appsettings.json
rename to CSharp/SQLTutorial/EFCore-3-AccessToken/appsettings.json
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj b/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj
deleted file mode 100644
index 413c47b..0000000
--- a/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- net8.0
- enable
- enable
- ASP_1_WebApi
-
-
-
-
-
-
-
-
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.http b/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.http
deleted file mode 100644
index bbc1227..0000000
--- a/CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.http
+++ /dev/null
@@ -1,6 +0,0 @@
-@ASP_1_WebApi_HostAddress = http://localhost:5076
-
-GET {{ASP_1_WebApi_HostAddress}}/weatherforecast/
-Accept: application/json
-
-###
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/Program.cs b/CSharp/WPFTutorial/ASP-1-WebApi/Program.cs
deleted file mode 100644
index 161f695..0000000
--- a/CSharp/WPFTutorial/ASP-1-WebApi/Program.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-var builder = WebApplication.CreateBuilder(args);
-
-// Add services to the container.
-// 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.UseHttpsRedirection();
-
-var summaries = new[]
-{
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
-};
-
-app.MapGet("/weatherforecast", () =>
- {
- var forecast = Enumerable.Range(1, 5).Select(index =>
- new WeatherForecast
- (
- DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
- Random.Shared.Next(-20, 55),
- summaries[Random.Shared.Next(summaries.Length)]
- ))
- .ToArray();
- return forecast;
- })
- .WithName("GetWeatherForecast")
- .WithOpenApi();
-
-app.Run();
-
-record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
-{
- public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-}
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/ASP-Demo-TODO.csproj b/CSharp/WPFTutorial/ASP-Demo-TODO/ASP-Demo-TODO.csproj
new file mode 100644
index 0000000..9a3dbf0
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/ASP-Demo-TODO.csproj
@@ -0,0 +1,12 @@
+
+
+
+ net5.0
+ ASP_Demo_TODO
+
+
+
+
+
+
+
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/Controllers/WeatherForecastController.cs b/CSharp/WPFTutorial/ASP-Demo-TODO/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..2610aab
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/Controllers/WeatherForecastController.cs
@@ -0,0 +1,39 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ASP_Demo_TODO.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]
+ public IEnumerable Get()
+ {
+ var rng = new Random();
+ return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+ {
+ Date = DateTime.Now.AddDays(index),
+ TemperatureC = rng.Next(-20, 55),
+ Summary = Summaries[rng.Next(Summaries.Length)]
+ })
+ .ToArray();
+ }
+ }
+}
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/Program.cs b/CSharp/WPFTutorial/ASP-Demo-TODO/Program.cs
new file mode 100644
index 0000000..37ce889
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/Program.cs
@@ -0,0 +1,19 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+
+namespace ASP_Demo_TODO
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args)
+ {
+ return Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); });
+ }
+ }
+}
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/ASP-1-WebApi/Properties/launchSettings.json b/CSharp/WPFTutorial/ASP-Demo-TODO/Properties/launchSettings.json
similarity index 56%
rename from CSharp/WPFTutorial/ASP-1-WebApi/Properties/launchSettings.json
rename to CSharp/WPFTutorial/ASP-Demo-TODO/Properties/launchSettings.json
index 551466e..2362304 100644
--- a/CSharp/WPFTutorial/ASP-1-WebApi/Properties/launchSettings.json
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/Properties/launchSettings.json
@@ -4,31 +4,11 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
- "applicationUrl": "http://localhost:53934",
- "sslPort": 44328
+ "applicationUrl": "http://localhost:9705",
+ "sslPort": 44384
}
},
"profiles": {
- "http": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5076",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "https": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:7295;http://localhost:5076",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
@@ -36,6 +16,16 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
+ },
+ "ASP_Demo_TODO": {
+ "commandName": "Project",
+ "dotnetRunMessages": "true",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:5001;http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
}
}
}
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/Startup.cs b/CSharp/WPFTutorial/ASP-Demo-TODO/Startup.cs
new file mode 100644
index 0000000..501847a
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/Startup.cs
@@ -0,0 +1,48 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.OpenApi.Models;
+
+namespace ASP_Demo_TODO
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers();
+ services.AddSwaggerGen(c =>
+ {
+ c.SwaggerDoc("v1", new OpenApiInfo { Title = "ASP_Demo_TODO", Version = "v1" });
+ });
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ app.UseSwagger();
+ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ASP_Demo_TODO v1"));
+ }
+
+ app.UseHttpsRedirection();
+
+ app.UseRouting();
+
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
+ }
+ }
+}
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/WeatherForecast.cs b/CSharp/WPFTutorial/ASP-Demo-TODO/WeatherForecast.cs
new file mode 100644
index 0000000..67e808c
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/WeatherForecast.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace ASP_Demo_TODO
+{
+ public class WeatherForecast
+ {
+ public DateTime Date { get; set; }
+
+ public int TemperatureC { get; set; }
+
+ public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
+
+ public string Summary { get; set; }
+ }
+}
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.Development.json b/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.Development.json
new file mode 100644
index 0000000..8983e0f
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.Development.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ }
+}
diff --git a/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.json b/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.json
new file mode 100644
index 0000000..d9d9a9b
--- /dev/null
+++ b/CSharp/WPFTutorial/ASP-Demo-TODO/appsettings.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/CSharp/WPFTutorial/Demo-TODO/App.xaml b/CSharp/WPFTutorial/Demo-TODO/App.xaml
new file mode 100644
index 0000000..3ee803c
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/App.xaml
@@ -0,0 +1,16 @@
+锘
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/Demo-TODO/App.xaml.cs b/CSharp/WPFTutorial/Demo-TODO/App.xaml.cs
new file mode 100644
index 0000000..9b64eec
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/App.xaml.cs
@@ -0,0 +1,21 @@
+锘縰sing System.Windows;
+using Prism.DryIoc;
+using Prism.Ioc;
+
+namespace Demo_TODO
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : PrismApplication
+ {
+ protected override void RegisterTypes(IContainerRegistry containerRegistry)
+ {
+ }
+
+ protected override Window CreateShell()
+ {
+ return Container.Resolve();
+ }
+ }
+}
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/Demo-TODO/AssemblyInfo.cs b/CSharp/WPFTutorial/Demo-TODO/AssemblyInfo.cs
new file mode 100644
index 0000000..4a05c7d
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj b/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj
new file mode 100644
index 0000000..dfebb65
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj
@@ -0,0 +1,28 @@
+锘
+
+
+ WinExe
+ net5.0-windows
+ Demo_TODO
+ enable
+ true
+
+
+
+
+
+
+
+
+
+ ..\..\..\..\..\..\..\software\Plugins\nuget\materialdesignthemes\5.2.2-ci998\lib\net8.0\MaterialDesignThemes.Wpf.dll
+
+
+
+
+
+ Always
+
+
+
+
diff --git a/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj.DotSettings.user b/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj.DotSettings.user
new file mode 100644
index 0000000..2d29cdf
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/Demo-TODO.csproj.DotSettings.user
@@ -0,0 +1,3 @@
+锘
+
+ ..\..\..\..\..\..\..\software\Plugins\nuget\materialdesignthemes\4.1.0\lib\netcoreapp3.1\MaterialDesignThemes.Wpf.dll\Themes\MaterialDesign3.Defaults.xaml
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/Demo-TODO/Images/Avatar.jpg b/CSharp/WPFTutorial/Demo-TODO/Images/Avatar.jpg
new file mode 100644
index 0000000..a899a73
Binary files /dev/null and b/CSharp/WPFTutorial/Demo-TODO/Images/Avatar.jpg differ
diff --git a/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml b/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml
new file mode 100644
index 0000000..b40f07b
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml
@@ -0,0 +1,120 @@
+锘
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml.cs b/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml.cs
new file mode 100644
index 0000000..d0795ea
--- /dev/null
+++ b/CSharp/WPFTutorial/Demo-TODO/MainWindow.xaml.cs
@@ -0,0 +1,40 @@
+锘縰sing System.Windows;
+using System.Windows.Input;
+
+namespace Demo_TODO
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ // 鏈灏忓寲鎸夐挳
+ MinButton.Click += (_, _) => { WindowState = WindowState.Minimized; };
+
+ // 鏀惧ぇ缂╁皬鎸夐挳
+ MaxButton.Click += (_, _) =>
+ {
+ WindowState = WindowState == WindowState.Maximized ? WindowState.Minimized : WindowState.Maximized;
+ };
+
+ // 鍏抽棴鎸夐挳
+ CloseButton.Click += (_, _) => { Close(); };
+
+ // 鎷栨嫿绐楀彛鎷栧姩
+ ColorZone.MouseDown += (_, eventArgs) =>
+ {
+ if (eventArgs.LeftButton == MouseButtonState.Pressed) DragMove();
+ };
+
+ // 鍙屽嚮鏀惧ぇ鍜岀缉灏
+ ColorZone.MouseDoubleClick += (_, _) =>
+ {
+ WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/CSharp/WPFTutorial/WPFTutorial.sln.DotSettings.user b/CSharp/WPFTutorial/WPFTutorial.sln.DotSettings.user
index 55066c3..6e0745b 100644
--- a/CSharp/WPFTutorial/WPFTutorial.sln.DotSettings.user
+++ b/CSharp/WPFTutorial/WPFTutorial.sln.DotSettings.user
@@ -14,4 +14,5 @@
ForceIncluded
ForceIncluded
ForceIncluded
- ForceIncluded
\ No newline at end of file
+ ForceIncluded
+ ForceIncluded
\ No newline at end of file