言语有限,代码如下;

 public IServiceProvider ConfigureServices(IServiceCollection services)
{
services
.AddCors()
.AddMvc();
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}; //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSwaggerGen(option =>
{
option.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
option.IncludeXmlComments(xmlPath);
}); var builder = new ContainerBuilder();
//Register your own services within Autofac
var selfServices = Assembly.Load("WuMing.Service");
//Assembly.LoadFile(Path.Combine(HostingEnvironment.WebRootPath, "AUO.SmartCaring.Service.dll"));
builder.RegisterAssemblyTypes(selfServices).AsImplementedInterfaces();
var selfRepos_Repo = Assembly.Load("WuMing.Repository");
//Assembly.LoadFile(Path.Combine(HostingEnvironment.WebRootPath, "AUO.SmartCaring.Repository.dll"));
builder.RegisterAssemblyTypes(selfRepos_Repo).AsImplementedInterfaces();
var selfEntity_Repo = Assembly.Load("WuMing.Entity");
//Assembly.LoadFile(Path.Combine(HostingEnvironment.WebRootPath, "AUO.SmartCaring.Repository.dll"));
builder.RegisterAssemblyTypes(selfEntity_Repo).AsImplementedInterfaces();
var selfapi_Repo = Assembly.Load("WuMing.Interface");
//Assembly.LoadFile(Path.Combine(HostingEnvironment.WebRootPath, "AUO.SmartCaring.Repository.dll"));
builder.RegisterAssemblyTypes(selfapi_Repo).AsImplementedInterfaces();
// //Put the framework services into Autofac
builder.Populate(services); //Build and return the Autofac collection
this.ApplicationContainer = builder.Build(); return new AutofacServiceProvider(this.ApplicationContainer); }

  

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseErrorHandling();
app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
);
app.UseMvc();
}

  

最新文章

  1. 基于react实现无限分级菜单
  2. 【Java每日一题】20161212
  3. [原创]在使用SDK 23(6.0)版本后org.apache.http相关的类找不到的解决办法
  4. socket传数据并记录到文件中
  5. [CareerCup] 10.6 Find Duplicate URLs 找重复的URL链接
  6. 聊聊HTTPS和SSL_TLS协议
  7. WEB可用性、可访问性、可维护性
  8. Linux系统下查看某文件修改的时间戳
  9. 【转】SQL Server查询字段说明
  10. 迭代器Iteration
  11. Redhat7.3更换CentOS7 yum源
  12. zookeeper 图形化的客户端工具:ZooInspector
  13. 帆软:不使用 __parameters__ 传参,问题。
  14. django,flask接口初试
  15. SSL和TLS协议的区别
  16. PSP个人项目耗时对比记录表:四则运算
  17. get_class_vars
  18. 本地如何搭建IPv6环境测试你的APP(转)
  19. sqlserver学习2---java执行存储过程
  20. Cocos2d-x中使用第三方so库

热门文章

  1. es bulk 批量删除
  2. ARM VM安装Linux Diagnostic 2.3扩展
  3. Django基于JWT实现微信小程序的登录和鉴权
  4. [转]Linux下paste命令详解
  5. [ CQOI 2009 ] 中位数图
  6. [ NOIP 2014 ] TG
  7. 【转】Centos7 ftp 配置及报错处理
  8. Java final和static 修饰符
  9. 简单TCP代码
  10. Ajax——php基础知识(一)