mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-28 12:46:36 +08:00
优化扩展
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库扩展
|
||||
/// </summary>
|
||||
public static class DataBaseExtension
|
||||
{
|
||||
public static IServiceCollection AddDataBaseService<IocOptios>(this IServiceCollection services , string appsettings)
|
||||
{
|
||||
Appsettings.app<IocOptios>(appsettings);
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void UseDataBaseService(this IApplicationBuilder app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Model;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用跨域扩展
|
||||
/// </summary>
|
||||
public static class IocExtension
|
||||
{
|
||||
public static IServiceCollection AddIocService(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
#region
|
||||
//配置文件使用配置
|
||||
#endregion
|
||||
services.AddSingleton(new Appsettings(configuration));
|
||||
|
||||
#region
|
||||
//数据库配置
|
||||
#endregion
|
||||
services.AddScoped<DbContext, DataContext>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static IServiceCollection AddRabbitMQService(this IServiceCollection services)
|
||||
{
|
||||
Appsettings.app<RabbitMQOptions>("RabbitConn");
|
||||
services.Configure<RabbitMQOptions>(Appsettings.appConfiguration("RabbitConn"));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static IServiceCollection AddRedisService(this IServiceCollection services)
|
||||
{
|
||||
Appsettings.app<RedisConnOptions>("RedisConn");
|
||||
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConn"));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库扩展
|
||||
/// </summary>
|
||||
public static class SqliteExtension
|
||||
{
|
||||
public static IServiceCollection AddSqliteService(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<SqliteOptions>(Appsettings.appConfiguration("SqliteConn"));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
//为 Swagger JSON and UI设置xml文档注释路径
|
||||
//获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux)
|
||||
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
||||
var apiXmlPath = Path.Combine(basePath, @"ApiDoc.xml");//控制器层注释
|
||||
var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
||||
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
|
||||
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
||||
c.IncludeXmlComments(entityXmlPath);
|
||||
c.IncludeXmlComments(apiXmlPath);
|
||||
|
||||
//添加控制器注释
|
||||
//c.DocumentFilter<SwaggerDocTag>();
|
||||
|
||||
Reference in New Issue
Block a user