ow
This commit is contained in:
commit
f05d2d215f
678 files changed
+73865
No files matched your search
@@ -0,0 +1,60 @@
|
||||
using CloudBuilder.Core.Application.Builders;
|
||||
using CloudBuilder.Core.Application.Options;
|
||||
using CloudBuilder.Core.DatabaseAccessor;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Core.Application.Packs
|
||||
{
|
||||
/// <summary>
|
||||
/// CloudBuilder核心模块
|
||||
/// </summary>
|
||||
[Description("CloudBuilder核心模块")]
|
||||
[PackLevel(0)]
|
||||
public class CloudBuilderCorePack : CloudBuilderPack
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取 模块级别
|
||||
/// </summary>
|
||||
public override PackLevel Level => PackLevel.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 将全局应用添加到依赖注入服务容器中
|
||||
/// </summary>
|
||||
/// <param name="services">依赖注入服务容器</param>
|
||||
/// <returns></returns>
|
||||
public override IServiceCollection AddServices(IServiceCollection services, CloudBuilderBuilder builder)
|
||||
{
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddSingleton(new WebService(services));
|
||||
|
||||
services.AddScoped<IApplicationService, ApplicationService>();
|
||||
|
||||
//services.TryAddSingleton<IInputDtoTypeFinder, InputDtoTypeFinder>();
|
||||
//services.TryAddSingleton<IOutputDtoTypeFinder, OutputDtoTypeFinder>();
|
||||
//services.TryAddSingleton<ICancellationTokenProvider, NoneCancellationTokenProvider>();
|
||||
//services.TryAddSingleton<IEmailSender, DefaultEmailSender>();
|
||||
|
||||
//services.TryAddSingleton<ICacheService, CacheService>();
|
||||
//services.TryAddScoped<IFilterService, FilterService>();
|
||||
|
||||
//services.TryAddTransient<IClientHttpCrypto, ClientHttpCrypto>();
|
||||
//services.AddTransient<ClientHttpCryptoHandler>();
|
||||
|
||||
//services.AddDistributedMemoryCache();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using CloudBuilder.Core.Application.Builders;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Core.Application.Packs
|
||||
{
|
||||
/// <summary>
|
||||
/// CloudBuilder模块基类
|
||||
/// </summary>
|
||||
public abstract class CloudBuilderPack
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取 模块级别,级别越小越先启动
|
||||
/// </summary>
|
||||
public virtual PackLevel Level => PackLevel.Business;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 模块启动顺序,模块启动的顺序先按级别启动,同一级别内部再按此顺序启动,
|
||||
/// 级别默认为0,表示无依赖,需要在同级别有依赖顺序的时候,再重写为>0的顺序值
|
||||
/// </summary>
|
||||
public virtual int Order => 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 是否已可用
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// 将模块服务添加到依赖注入服务容器中
|
||||
/// </summary>
|
||||
/// <param name="services">依赖注入服务容器</param>
|
||||
/// <returns></returns>
|
||||
public virtual IServiceCollection AddServices(IServiceCollection services, CloudBuilderBuilder builder)
|
||||
{
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用模块服务
|
||||
/// </summary>
|
||||
/// <param name="provider">服务提供者</param>
|
||||
public virtual void UsePack(IServiceProvider provider)
|
||||
{
|
||||
IsEnabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Core.Application.Packs
|
||||
{
|
||||
/// <summary>
|
||||
/// 模块级别,级别越核心,优先启动
|
||||
/// </summary>
|
||||
public enum PackLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// 核心级别,表示系统的核心模块,
|
||||
/// 这些模块不涉及第三方组件,在系统运行中是不可替换的,核心模块将始终加载
|
||||
/// </summary>
|
||||
Core = 1,
|
||||
/// <summary>
|
||||
/// 框架级别,表示涉及第三方组件的基础模块
|
||||
/// </summary>
|
||||
Framework = 10,
|
||||
/// <summary>
|
||||
/// 应用级别,表示涉及应用数据的基础模块
|
||||
/// </summary>
|
||||
Application = 20,
|
||||
/// <summary>
|
||||
/// 业务级别,表示涉及真实业务处理的模块
|
||||
/// </summary>
|
||||
Business = 30
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Core.Application.Packs
|
||||
{
|
||||
public class PackLevelAttribute : Attribute
|
||||
{
|
||||
public PackLevelAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public PackLevelAttribute(int level)
|
||||
{
|
||||
this.Level = level;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取权限名称
|
||||
/// </summary>
|
||||
public int Level { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user