Skip to content

Commit

Permalink
丰富注释
Browse files Browse the repository at this point in the history
  • Loading branch information
Surbowl committed Feb 6, 2020
1 parent ebdd9e3 commit 5d6e6a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Routine/Routine.APi/Controllers/CompaniesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public class CompaniesController : ControllerBase

public CompaniesController(ICompanyRepository companyRepository, IMapper mapper)
{
_companyRepository = companyRepository ??
throw new ArgumentNullException(nameof(companyRepository));
_companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository));
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
}

Expand Down
2 changes: 1 addition & 1 deletion Routine/Routine.APi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void Main(string[] args)
{
try
{
//每次运行都把数据库删了重建
//每次运行都把数据库删了重建(视频P1)
var dbContext = scope.ServiceProvider.GetService<RoutineDbContext>();
dbContext.Database.EnsureDeleted();
dbContext.Database.Migrate();
Expand Down
6 changes: 3 additions & 3 deletions Routine/Routine.APi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void ConfigureServices(IServiceCollection services)
/*
* .Net Core 默认使用 Problem details for HTTP APIs RFC (7807) 标准
* - 为所需错误信息的应用,定义了通用的错误格式
* - 可以识别出问题属于哪个 API
* - 可以识别问题属于哪个 API
*/

//以下是一种较旧的写法,在本项目中不使用(视频P8)
Expand Down Expand Up @@ -93,7 +93,7 @@ public void ConfigureServices(IServiceCollection services)
//使用 AutoMapper,扫描当前应用域的所有 Assemblies 寻找 AutoMapper 的配置文件(视频P12)
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

//AddScoped 针对每一个 HTTP 请求都会建立一个新的实例
//AddScoped 针对每一次 HTTP 请求都会建立一个新的实例(视频P1)
services.AddScoped<ICompanyRepository, CompanyRepository>();

services.AddDbContext<RoutineDbContext>(options =>
Expand All @@ -107,7 +107,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
/*
* 添加中间件的顺序非常重要。如果你把授权中间件放在了Controller的后边,
* 那么即使需要授权,那么请求也会先到达Controller并执行里面的代码,这样的话授权就没有意义了。
* 那么即使需要授权,那么请求也会先到达Controller并执行里面的代码,这样的话授权就没有意义了。(视频P1)
*/

if (env.IsDevelopment())
Expand Down

0 comments on commit 5d6e6a8

Please sign in to comment.