using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BPA.MES.Base.Application.Services
{
///
/// 名 称 :
/// 创 建 人 :yangxiao
/// 创建时间 : 2023/7/17 16:13:10
/// 描 述 :
///
public class BaseService: ITransient, IDynamicApiController
{
private readonly ISqlSugarClient _dbContext;
public BaseService(ISqlSugarClient db)
{
_dbContext = db;
}
///
/// 初始化数据库
///
///
public string CreateDB()
{
var types = Assembly.Load("BPA.MES.Base.Application").GetTypes()
.Where(x => x.GetCustomAttribute() != null
&& x.Namespace == "BPA.MES.Base.Application.Entitys").ToArray();
_dbContext.CodeFirst.InitTables(types);
return "成功";
}
///
/// 测试
///
[AllowAnonymous]
public void Test()
{
//Type personType = Type.GetType("BPA.MES.Base.Application, DictDataAddInput");
//object person = Activator.CreateInstance(personType);
Type type = Type.GetType("BPA.MES.Base.Application.Services.DictService.Dtos");
string fullName = "BPA.MES.Base.Application.Services.DictDataAddInput";
Type? instanceClass = Assembly.Load("BPA.MES.Base.Application").GetType(fullName);
var myInstance = instanceClass?.Assembly.CreateInstance(fullName);
}
}
}