Merge pull request 'refactor: 😀代码优化' (#240) from jasondom/Admin.NET.Pro:v2 into v2
Reviewed-on: http://101.43.53.74:3000/Admin.NET/Admin.NET.Pro/pulls/240
This commit is contained in:
commit
9a2b9a48ae
128
Admin.NET/Admin.NET.Core/Extension/StringExtension.cs
Normal file
128
Admin.NET/Admin.NET.Core/Extension/StringExtension.cs
Normal file
@ -0,0 +1,128 @@
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
//
|
||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 字符串扩展方法
|
||||
/// </summary>
|
||||
public static class StringExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 字符串截断
|
||||
/// </summary>
|
||||
public static string Truncate(this string str, int maxLength, string ellipsis = "...")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str)) return str;
|
||||
if (maxLength <= 0) return string.Empty;
|
||||
if (str.Length <= maxLength) return str;
|
||||
|
||||
// 确保省略号不会导致字符串超出最大长度
|
||||
int ellipsisLength = ellipsis?.Length ?? 0;
|
||||
int truncateLength = Math.Min(maxLength, str.Length - ellipsisLength);
|
||||
return str[..truncateLength] + ellipsis;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单词首字母全部大写
|
||||
/// </summary>
|
||||
public static string ToTitleCase(this string str)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(str) ? str : System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含子串,忽略大小写
|
||||
/// </summary>
|
||||
public static bool ContainsIgnoreCase(this string str, string substring)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str) || string.IsNullOrWhiteSpace(substring)) return false;
|
||||
return str.Contains(substring, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否是 JSON 数据
|
||||
/// </summary>
|
||||
public static bool IsJson(this string str)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str)) return false;
|
||||
str = str.Trim();
|
||||
return (str.StartsWith("{") && str.EndsWith("}")) || (str.StartsWith("[") && str.EndsWith("]"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否是 HTML 数据
|
||||
/// </summary>
|
||||
public static bool IsHtml(this string str)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str)) return false;
|
||||
str = str.Trim();
|
||||
|
||||
// 检查是否以 <!DOCTYPE html> 或 <html> 开头
|
||||
if (str.StartsWith("<!DOCTYPE html>", StringComparison.OrdinalIgnoreCase) || str.StartsWith("<html>", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查是否包含 HTML 标签
|
||||
return Regex.IsMatch(str, @"<\s*[^>]+>.*<\s*/\s*[^>]+>|<\s*[^>]+\s*/>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串反转
|
||||
/// </summary>
|
||||
public static string Reverse(this string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return str;
|
||||
|
||||
// 使用 Span<char> 提高性能
|
||||
Span<char> charSpan = stackalloc char[str.Length];
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
charSpan[str.Length - 1 - i] = str[i];
|
||||
}
|
||||
return new string(charSpan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转首字母小写
|
||||
/// </summary>
|
||||
public static string ToFirstLetterLowerCase(this string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input)) return input;
|
||||
if (input.Length == 1) return input.ToLower(); // 处理单字符字符串
|
||||
|
||||
return char.ToLower(input[0]) + input[1..];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 渲染字符串,替换占位符
|
||||
/// </summary>
|
||||
/// <param name="template">模板内容</param>
|
||||
/// <param name="parameters">参数对象</param>
|
||||
/// <returns></returns>
|
||||
public static string Render(this string template, object parameters)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(template)) return template;
|
||||
|
||||
// 将参数转换为字典(忽略大小写)
|
||||
var paramDict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (var prop in parameters.GetType().GetProperties())
|
||||
{
|
||||
paramDict[prop.Name] = prop.GetValue(parameters)?.ToString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
// 使用正则表达式替换占位符
|
||||
return Regex.Replace(template, @"\{(\w+)\}", match =>
|
||||
{
|
||||
string key = match.Groups[1].Value; // 获取占位符中的 key
|
||||
return paramDict.TryGetValue(key, out string value) ? value : string.Empty;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
|
||||
.Select<CodeGenConfig>()
|
||||
.Mapper(u =>
|
||||
{
|
||||
u.NetType = (u.EffectType == "EnumSelector" || u.EffectType == "ConstSelector" ? u.DictTypeCode : u.NetType);
|
||||
u.NetType = (u.EffectType is "EnumSelector" or "ConstSelector" ? u.DictTypeCode : u.NetType);
|
||||
})
|
||||
.OrderBy(u => new { u.OrderNo, u.Id })
|
||||
.ToListAsync();
|
||||
|
||||
@ -88,10 +88,10 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
private List<SysCodeGenTemplateRelation> GetCodeGenTemplateRelation(long codeGenId, List<long> templateIds)
|
||||
{
|
||||
List<SysCodeGenTemplateRelation> list = new List<SysCodeGenTemplateRelation>();
|
||||
List<SysCodeGenTemplateRelation> list = new();
|
||||
foreach (var item in templateIds)
|
||||
{
|
||||
SysCodeGenTemplateRelation relation = new SysCodeGenTemplateRelation();
|
||||
SysCodeGenTemplateRelation relation = new();
|
||||
relation.CodeGenId = codeGenId;
|
||||
relation.TemplateId = item;
|
||||
list.Add(relation);
|
||||
@ -183,7 +183,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
var config = _dbConnectionOptions.ConnectionConfigs.FirstOrDefault(u => configId.Equals(u.ConfigId));
|
||||
|
||||
IEnumerable<EntityInfo> entityInfos = await GetEntityInfos(false); // 获取所有实体定义
|
||||
IEnumerable<EntityInfo> entityInfos = await GetEntityInfos(); // 获取所有实体定义
|
||||
entityInfos = entityInfos.OrderBy(u => u.EntityName.StartsWith("Sys") ? 1 : 0).ThenBy(u => u.EntityName);
|
||||
|
||||
var tableOutputList = new List<TableOutput>();
|
||||
@ -279,14 +279,14 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
if (entityType == null)
|
||||
return null;
|
||||
var config = _dbConnectionOptions.ConnectionConfigs.FirstOrDefault(u => u.ConfigId.ToString() == input.ConfigId);
|
||||
var dbTableName = config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(entityType.DbTableName) : entityType.DbTableName;
|
||||
var dbTableName = config!.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(entityType.DbTableName) : entityType.DbTableName;
|
||||
|
||||
int bracketIndex = dbTableName.IndexOf('{');
|
||||
if (bracketIndex != -1)
|
||||
{
|
||||
dbTableName = dbTableName.Substring(0, bracketIndex);
|
||||
var dbTableInfos = _db.AsTenant().GetConnectionScope(input.ConfigId).DbMaintenance.GetTableInfoList(false);
|
||||
var table = dbTableInfos.FirstOrDefault(x => x.Name.ToLower().StartsWith(config != null && config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(dbTableName) : dbTableName));
|
||||
var table = dbTableInfos.FirstOrDefault(x => x.Name.StartsWith(config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(dbTableName) : dbTableName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (table != null)
|
||||
dbTableName = table.Name;
|
||||
}
|
||||
@ -366,11 +366,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Type[] cosType = types.Where(u =>
|
||||
{
|
||||
return IsMyAttribute(Attribute.GetCustomAttributes(u, false));
|
||||
}
|
||||
).ToArray();
|
||||
Type[] cosType = types.Where(u => IsMyAttribute(Attribute.GetCustomAttributes(u, false))).ToArray();
|
||||
|
||||
var entityInfos = new List<EntityInfo>();
|
||||
foreach (var ct in cosType)
|
||||
@ -382,7 +378,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var des = ct.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
var description = des.Length > 0 ? ((DescriptionAttribute)des[0]).Description : "";
|
||||
|
||||
var sugarAttribute = ct.GetCustomAttributes(sugarTableType, true)?.FirstOrDefault();
|
||||
var sugarAttribute = ct.GetCustomAttributes(sugarTableType, true).FirstOrDefault();
|
||||
|
||||
entityInfos.Add(new EntityInfo()
|
||||
{
|
||||
@ -412,77 +408,19 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
[DisplayName("执行代码生成")]
|
||||
public async Task<dynamic> RunLocal(SysCodeGen input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.GenerateType))
|
||||
input.GenerateType = "200";
|
||||
if (string.IsNullOrEmpty(input.GenerateType)) input.GenerateType = "200";
|
||||
|
||||
string outputPath = Path.Combine(App.WebHostEnvironment.WebRootPath, "codeGen", input.TableName!);
|
||||
if (Directory.Exists(outputPath))
|
||||
Directory.Delete(outputPath, true);
|
||||
if (Directory.Exists(outputPath)) Directory.Delete(outputPath, true);
|
||||
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig() { CodeGenId = input.Id }); // 字段集合
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig { CodeGenId = input.Id }); // 字段集合
|
||||
|
||||
#region 构造前端需要验证的数据
|
||||
|
||||
foreach (var item in tableFieldList)
|
||||
{
|
||||
List<VerifyRuleItem> list = new List<VerifyRuleItem>();
|
||||
if (!string.IsNullOrWhiteSpace(item.Rules))
|
||||
{
|
||||
if (item.Rules != "[]")
|
||||
{
|
||||
list = JSON.Deserialize<List<VerifyRuleItem>>(item.Rules);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Rules = "[]";
|
||||
}
|
||||
item.RuleItems = list;
|
||||
item.WhetherRequired = list.Any(t => t.Type == "required") ? YesNoEnum.Y.ToString() : YesNoEnum.N.ToString();
|
||||
item.AnyRule = list.Count > 0;
|
||||
item.RemoteVerify = list.Any(t => t.Type == "remote");
|
||||
}
|
||||
|
||||
#endregion 构造前端需要验证的数据
|
||||
ProcessTableFieldList(tableFieldList); // 处理字段集合
|
||||
|
||||
var queryWhetherList = tableFieldList.Where(u => u.QueryWhether == YesNoEnum.Y.ToString()).ToList(); // 前端查询集合
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType == "Upload" || u.EffectType == "ForeignKey" || u.EffectType == "ApiTreeSelector").ToList(); // 需要连表查询的字段
|
||||
(string joinTableNames, string lowerJoinTableNames) = GetJoinTableStr(joinTableList); // 获取连表的实体名和别名
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType is "Upload" or "ForeignKey" or "ApiTreeSelector").ToList(); // 需要连表查询的字段
|
||||
|
||||
var data = new CustomViewEngine(_db)
|
||||
{
|
||||
ConfigId = input.ConfigId!, // 库定位器名
|
||||
AuthorName = input.AuthorName!, // 作者
|
||||
BusName = input.BusName!, // 业务名称
|
||||
NameSpace = input.NameSpace!, // 命名空间
|
||||
ClassName = input.TableName!, // 类名称
|
||||
PagePath = input.PagePath!, // 页面目录
|
||||
ProjectLastName = input.NameSpace!.Split('.').Last(), // 项目最后个名称,生成的时候赋值
|
||||
QueryWhetherList = queryWhetherList, // 查询条件
|
||||
TableField = tableFieldList, // 表字段配置信息
|
||||
IsJoinTable = joinTableList.Count > 0, // 是否联表
|
||||
IsUpload = joinTableList.Where(u => u.EffectType == "Upload").Any(), // 是否上传
|
||||
PrintType = input.PrintType!, // 支持打印类型
|
||||
PrintName = input.PrintName!, // 打印模板名称
|
||||
IsApiService = input.IsApiService,
|
||||
RemoteVerify = tableFieldList.Any(t => t.RemoteVerify == true), // 远程验证
|
||||
TreeName = input.TreeName,
|
||||
LowerTreeName = string.IsNullOrEmpty(input.TreeName) ? "" : input.TreeName[..1].ToLower() + input.TreeName[1..], // 首字母小写
|
||||
LeftTab = input.LeftTab,
|
||||
LeftKey = input.LeftKey!,
|
||||
LeftPrimaryKey = input.LeftPrimaryKey,
|
||||
LeftName = input.LeftName,
|
||||
LowerLeftTab = string.IsNullOrEmpty(input.LeftTab) ? "" : input.LeftTab[..1].ToLower() + input.LeftTab[1..], // 首字母小写
|
||||
LowerLeftKey = string.IsNullOrEmpty(input.LeftKey) ? "" : input.LeftKey[..1].ToLower() + input.LeftKey[1..], // 首字母小写
|
||||
LowerLeftPrimaryKey = string.IsNullOrEmpty(input.LeftPrimaryKey) ? "" : input.LeftPrimaryKey[..1].ToLower() + input.LeftPrimaryKey[1..], // 首字母小写
|
||||
//LowerLeftPrimaryKey = CodeGenUtil.CamelColumnName(input.LeftPrimaryKey, entityBasePropertyNames),
|
||||
BottomTab = input.BottomTab,
|
||||
BottomKey = input.BottomKey!,
|
||||
BottomPrimaryKey = input.BottomPrimaryKey,
|
||||
LowerBottomTab = string.IsNullOrEmpty(input.BottomTab) ? "" : input.BottomTab[..1].ToLower() + input.BottomTab[1..], // 首字母小写
|
||||
LowerBottomKey = string.IsNullOrEmpty(input.BottomKey) ? "" : input.BottomKey[..1].ToLower() + input.BottomKey[1..], // 首字母小写
|
||||
LowerBottomPrimaryKey = string.IsNullOrEmpty(input.BottomPrimaryKey) ? "" : input.BottomPrimaryKey[..1].ToLower() + input.BottomPrimaryKey[1..], // 首字母小写
|
||||
};
|
||||
var data = CreateCustomViewEngine(input, tableFieldList, queryWhetherList, joinTableList); // 创建视图引擎数据
|
||||
|
||||
// 获得菜单
|
||||
var menuList = await GetMenus(input.TableName!, input.BusName!, input.MenuPid ?? 0, input.MenuIcon!, input.PagePath!, tableFieldList);
|
||||
@ -496,55 +434,12 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var templatePath = Path.Combine(App.WebHostEnvironment.WebRootPath, "template");
|
||||
for (var i = 0; i < templateList.Count; i++)
|
||||
{
|
||||
string tResult = string.Empty; // 模板生成结果
|
||||
|
||||
var filename = templateList[i].Name;
|
||||
// 更改默认首页模板
|
||||
if (filename == "web_views_index.vue.vm")
|
||||
{
|
||||
filename = string.IsNullOrEmpty(input.LeftTab) ? filename : "web_views_LeftTree.vue.vm"; // 左树右列表
|
||||
filename = string.IsNullOrEmpty(input.BottomTab) ? filename : "web_views_BottomIndx.vue.vm"; // 左数右上列表下列表属性
|
||||
}
|
||||
var templateFilePath = Path.Combine(templatePath, filename);
|
||||
if (!File.Exists(templateFilePath)) continue;
|
||||
var tContent = File.ReadAllText(templateFilePath);
|
||||
|
||||
if (templateList[i].Type == CodeGenTypeEnum.SeedData)
|
||||
{
|
||||
// 种子模板
|
||||
var seedData = new
|
||||
{
|
||||
AuthorName = input.AuthorName!, // 作者
|
||||
BusName = input.BusName!, // 业务名称
|
||||
NameSpace = input.NameSpace!, // 命名空间
|
||||
ClassName = input.TableName!, // 类名称
|
||||
ConfigId = input.ConfigId, // 库标识
|
||||
MenuList = menuList, // 菜单集合
|
||||
PrintType = input.PrintType!
|
||||
};
|
||||
tResult = await _viewEngine.RunCompileAsync(tContent, seedData, builderAction: builder =>
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
tResult = await _viewEngine.RunCompileAsync(tContent, data, builderAction: builder =>
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
string tResult = await ProcessTemplate(templateList[i], input, templatePath, data, menuList); // 处理模板
|
||||
|
||||
string targetFile = templateList[i].OutputFile
|
||||
.Replace("{PagePath}", input.PagePath)
|
||||
.Replace("{TableName}", input.TableName)
|
||||
.Replace("{TableNameLower}", ToFirstLetterLowerCase(input.TableName!));
|
||||
.Replace("{TableNameLower}", input.TableName?.ToFirstLetterLowerCase() ?? "");
|
||||
|
||||
string tmpPath;
|
||||
if (!input.GenerateType.StartsWith('1'))
|
||||
@ -552,7 +447,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
if (templateList[i].Type == CodeGenTypeEnum.Frontend)
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.Parent!.FullName, _codeGenOptions.FrontRootPath, "src");
|
||||
else
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.FullName, input.NameSpace);
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.FullName, input.NameSpace!);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -563,17 +458,14 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var dirPath = new DirectoryInfo(targetFile).Parent!.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
Directory.CreateDirectory(dirPath);
|
||||
File.WriteAllText(targetFile, tResult, Encoding.UTF8);
|
||||
await File.WriteAllTextAsync(targetFile, tResult, Encoding.UTF8);
|
||||
}
|
||||
|
||||
// 非ZIP压缩返回空
|
||||
if (!input.GenerateType.StartsWith('1'))
|
||||
return null;
|
||||
if (!input.GenerateType.StartsWith('1')) return null;
|
||||
|
||||
var downloadPath = outputPath + ".zip";
|
||||
// 判断是否存在同名称文件
|
||||
if (File.Exists(downloadPath))
|
||||
File.Delete(downloadPath);
|
||||
if (File.Exists(downloadPath)) File.Delete(downloadPath); // 删除同名文件
|
||||
ZipFile.CreateFromDirectory(outputPath, downloadPath);
|
||||
return new { url = $"{App.HttpContext.Request.Scheme}://{App.HttpContext.Request.Host.Value}/codeGen/{input.TableName}.zip" };
|
||||
}
|
||||
@ -585,13 +477,47 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
[DisplayName("获取代码生成预览")]
|
||||
public async Task<Dictionary<string, string>> Preview(SysCodeGen input)
|
||||
{
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig() { CodeGenId = input.Id }); // 字段集合
|
||||
var tableFieldList = await _codeGenConfigService.GetList(new CodeGenConfig { CodeGenId = input.Id }); // 字段集合
|
||||
|
||||
#region 构造前端需要验证的数据
|
||||
ProcessTableFieldList(tableFieldList); // 处理字段集合
|
||||
|
||||
var queryWhetherList = tableFieldList.Where(u => u.QueryWhether == YesNoEnum.Y.ToString()).ToList(); // 前端查询集合
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType is "Upload" or "ForeignKey" or "ApiTreeSelector").ToList(); // 需要连表查询的字段
|
||||
|
||||
var data = CreateCustomViewEngine(input, tableFieldList, queryWhetherList, joinTableList); // 创建视图引擎数据
|
||||
|
||||
// 获取模板文件并替换
|
||||
var templateList = GetTemplateList(input);
|
||||
var templatePath = Path.Combine(App.WebHostEnvironment.WebRootPath, "template");
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var menuList = await GetMenus(input.TableName!, input.BusName!, input.MenuPid ?? 0, input.MenuIcon!,
|
||||
input.PagePath!, tableFieldList);
|
||||
var result = new Dictionary<string, string>();
|
||||
foreach (var template in templateList)
|
||||
{
|
||||
string tResult = await ProcessTemplate(template, input, templatePath, data, menuList); // 处理模板
|
||||
result.Add(template.Name?.TrimEnd(".vm")!, tResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理字段集合
|
||||
/// </summary>
|
||||
/// <param name="tableFieldList"></param>
|
||||
private void ProcessTableFieldList(List<CodeGenConfig> tableFieldList)
|
||||
{
|
||||
foreach (var item in tableFieldList)
|
||||
{
|
||||
List<VerifyRuleItem> list = new List<VerifyRuleItem>();
|
||||
List<VerifyRuleItem> list = new();
|
||||
if (!string.IsNullOrWhiteSpace(item.Rules))
|
||||
{
|
||||
if (item.Rules != "[]")
|
||||
@ -608,14 +534,19 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
item.AnyRule = list.Count > 0;
|
||||
item.RemoteVerify = list.Any(t => t.Type == "remote");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 构造前端需要验证的数据
|
||||
|
||||
var queryWhetherList = tableFieldList.Where(u => u.QueryWhether == YesNoEnum.Y.ToString()).ToList(); // 前端查询集合
|
||||
var joinTableList = tableFieldList.Where(u => u.EffectType == "Upload" || u.EffectType == "ForeignKey" || u.EffectType == "ApiTreeSelector").ToList(); // 需要连表查询的字段
|
||||
(string joinTableNames, string lowerJoinTableNames) = GetJoinTableStr(joinTableList); // 获取连表的实体名和别名
|
||||
|
||||
var data = new CustomViewEngine(_db)
|
||||
/// <summary>
|
||||
/// 创建视图引擎数据
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="tableFieldList"></param>
|
||||
/// <param name="queryWhetherList"></param>
|
||||
/// <param name="joinTableList"></param>
|
||||
/// <returns></returns>
|
||||
private CustomViewEngine CreateCustomViewEngine(SysCodeGen input, List<CodeGenConfig> tableFieldList, List<CodeGenConfig> queryWhetherList, List<CodeGenConfig> joinTableList)
|
||||
{
|
||||
return new CustomViewEngine(_db)
|
||||
{
|
||||
ConfigId = input.ConfigId!, // 库定位器名
|
||||
AuthorName = input.AuthorName!, // 作者
|
||||
@ -624,90 +555,94 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
ClassName = input.TableName!, // 类名称
|
||||
PagePath = input.PagePath!, // 页面目录
|
||||
ProjectLastName = input.NameSpace!.Split('.').Last(), // 项目最后个名称,生成的时候赋值
|
||||
TableUniqueConfigList = input.TableUniqueList ?? new(), // 唯一字段列表
|
||||
QueryWhetherList = queryWhetherList, // 查询条件
|
||||
TableField = tableFieldList, // 表字段配置信息
|
||||
IsJoinTable = joinTableList.Count > 0,//是否联表
|
||||
IsUpload = joinTableList.Where(u => u.EffectType == "Upload").Any(), // 是否上传
|
||||
IsJoinTable = joinTableList.Count > 0, // 是否联表
|
||||
IsUpload = joinTableList.Any(u => u.EffectType == "Upload"), // 是否上传
|
||||
PrintType = input.PrintType!, // 支持打印类型
|
||||
PrintName = input.PrintName!, // 打印模板名称
|
||||
IsApiService = input.IsApiService,
|
||||
RemoteVerify = tableFieldList.Any(t => t.RemoteVerify == true), // 远程验证
|
||||
RemoteVerify = tableFieldList.Any(t => t.RemoteVerify), // 远程验证
|
||||
TreeName = input.TreeName,
|
||||
LowerTreeName = string.IsNullOrEmpty(input.TreeName) ? "" : input.TreeName[..1].ToLower() + input.TreeName[1..], // 首字母小写
|
||||
LowerTreeName = input.TreeName?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
LeftTab = input.LeftTab,
|
||||
LeftKey = input.LeftKey!,
|
||||
LeftPrimaryKey = input.LeftPrimaryKey,
|
||||
LeftName = input.LeftName,
|
||||
LowerLeftTab = string.IsNullOrEmpty(input.LeftTab) ? "" : input.LeftTab[..1].ToLower() + input.LeftTab[1..], // 首字母小写
|
||||
LowerLeftKey = string.IsNullOrEmpty(input.LeftKey) ? "" : input.LeftKey[..1].ToLower() + input.LeftKey[1..], // 首字母小写
|
||||
LowerLeftPrimaryKey = string.IsNullOrEmpty(input.LeftPrimaryKey) ? "" : input.LeftPrimaryKey[..1].ToLower() + input.LeftPrimaryKey[1..], // 首字母小写
|
||||
//LowerLeftPrimaryKey = CodeGenUtil.CamelColumnName(input.LeftPrimaryKey, entityBasePropertyNames),
|
||||
LowerLeftTab = input.LeftTab?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
LowerLeftKey = input.LeftKey?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
LowerLeftPrimaryKey = input.LeftPrimaryKey?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
BottomTab = input.BottomTab,
|
||||
BottomKey = input.BottomKey!,
|
||||
BottomPrimaryKey = input.BottomPrimaryKey,
|
||||
LowerBottomTab = string.IsNullOrEmpty(input.BottomTab) ? "" : input.BottomTab[..1].ToLower() + input.BottomTab[1..], // 首字母小写
|
||||
LowerBottomKey = string.IsNullOrEmpty(input.BottomKey) ? "" : input.BottomKey[..1].ToLower() + input.BottomKey[1..], // 首字母小写
|
||||
LowerBottomPrimaryKey = string.IsNullOrEmpty(input.BottomPrimaryKey) ? "" : input.BottomPrimaryKey[..1].ToLower() + input.BottomPrimaryKey[1..], // 首字母小写
|
||||
LowerBottomTab = input.BottomTab?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
LowerBottomKey = input.BottomKey?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
LowerBottomPrimaryKey = input.BottomPrimaryKey?.ToFirstLetterLowerCase() ?? "", // 首字母小写
|
||||
};
|
||||
}
|
||||
|
||||
// 获取模板文件并替换
|
||||
var templateList = GetTemplateList(input);
|
||||
var templatePath = Path.Combine(App.WebHostEnvironment.WebRootPath, "template");
|
||||
/// <summary>
|
||||
/// 处理模板
|
||||
/// </summary>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="templatePath"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="menuList"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<string> ProcessTemplate(SysCodeGenTemplate template, SysCodeGen input, string templatePath, CustomViewEngine data, List<SysMenu> menuList)
|
||||
{
|
||||
string tResult;
|
||||
|
||||
var result = new Dictionary<string, string>();
|
||||
for (var i = 0; i < templateList.Count; i++)
|
||||
var filename = template.Name;
|
||||
// 更改默认首页模板
|
||||
if (filename == "web_views_index.vue.vm")
|
||||
{
|
||||
string tResult = string.Empty; // 模板生成结果
|
||||
filename = string.IsNullOrEmpty(input.LeftTab) ? filename : "web_views_LeftTree.vue.vm"; // 左树右列表
|
||||
filename = string.IsNullOrEmpty(input.BottomTab) ? filename : "web_views_BottomIndx.vue.vm"; // 左数右上列表下列表属性
|
||||
}
|
||||
var templateFilePath = Path.Combine(templatePath, filename);
|
||||
if (!File.Exists(templateFilePath)) return null;
|
||||
|
||||
var filename = templateList[i].Name;
|
||||
// 更改默认首页模板
|
||||
if (filename == "web_views_index.vue.vm")
|
||||
{
|
||||
filename = string.IsNullOrEmpty(input.LeftTab) ? filename : "web_views_LeftTree.vue.vm"; // 左树右列表
|
||||
filename = string.IsNullOrEmpty(input.BottomTab) ? filename : "web_views_BottomIndx.vue.vm"; // 左数右上列表下列表属性
|
||||
}
|
||||
var templateFilePath = Path.Combine(templatePath, filename);
|
||||
if (!File.Exists(templateFilePath)) continue;
|
||||
var tContent = File.ReadAllText(templateFilePath);
|
||||
var tContent = await File.ReadAllTextAsync(templateFilePath);
|
||||
|
||||
if (templateList[i].Type == CodeGenTypeEnum.SeedData)
|
||||
if (template.Type == CodeGenTypeEnum.SeedData)
|
||||
{
|
||||
// 种子模板
|
||||
var seedData = new
|
||||
{
|
||||
// 种子模板
|
||||
var menuList = await GetMenus(input.TableName!, input.BusName!, input.MenuPid ?? 0, input.MenuIcon!, input.PagePath!, tableFieldList);
|
||||
var seedData = new
|
||||
{
|
||||
AuthorName = input.AuthorName!, // 作者
|
||||
BusName = input.BusName!, // 业务名称
|
||||
NameSpace = input.NameSpace!, // 命名空间
|
||||
ClassName = input.TableName!, // 类名称
|
||||
ConfigId = input.ConfigId, // 库标识
|
||||
MenuList = menuList, // 菜单集合
|
||||
PrintType = input.PrintType!
|
||||
};
|
||||
tResult = await _viewEngine.RunCompileAsync(tContent, seedData, builderAction: builder =>
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
else
|
||||
AuthorName = input.AuthorName!, // 作者
|
||||
BusName = input.BusName!, // 业务名称
|
||||
NameSpace = input.NameSpace!, // 命名空间
|
||||
ClassName = input.TableName!, // 类名称
|
||||
ConfigId = input.ConfigId, // 库标识
|
||||
MenuList = menuList, // 菜单集合
|
||||
PrintType = input.PrintType!
|
||||
};
|
||||
tResult = await _viewEngine.RunCompileAsync(tContent, seedData, builderAction: builder =>
|
||||
{
|
||||
tResult = await _viewEngine.RunCompileFromCachedAsync(tContent, data, builderAction: builder =>
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
|
||||
result.Add(templateList[i].Name?.TrimEnd(".vm")!, tResult);
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddAssemblyReferenceByName("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
tResult = await _viewEngine.RunCompileAsync(tContent, data, builderAction: builder =>
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddAssemblyReferenceByName("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
return tResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -742,30 +677,29 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
private async Task AddMenu(List<SysMenu> menus, long pid)
|
||||
{
|
||||
var pPath = string.Empty;
|
||||
// 若 pid=0 为顶级则创建菜单目录
|
||||
if (pid == 0)
|
||||
{
|
||||
// 若已存在相同目录则删除本级和下级
|
||||
var menuType0 = menus.Where(u => u.Type == MenuTypeEnum.Dir && u.Pid == 0).FirstOrDefault();
|
||||
var menuType0 = menus.FirstOrDefault(u => u.Type == MenuTypeEnum.Dir && u.Pid == 0);
|
||||
var menuList0 = await _db.Queryable<SysMenu>().Where(u => u.Title == menuType0.Title && u.Type == menuType0.Type).ToListAsync();
|
||||
if (menuList0.Count > 0)
|
||||
{
|
||||
var listIds = menuList0.Select(u => u.Id).ToList();
|
||||
var childlistIds = new List<long>();
|
||||
var childrenIds = new List<long>();
|
||||
foreach (var item in listIds)
|
||||
{
|
||||
var childlist = await _db.Queryable<SysMenu>().ToChildListAsync(u => u.Pid, item);
|
||||
childlistIds.AddRange(childlist.Select(u => u.Id).ToList());
|
||||
var children = await _db.Queryable<SysMenu>().ToChildListAsync(u => u.Pid, item);
|
||||
childrenIds.AddRange(children.Select(u => u.Id).ToList());
|
||||
}
|
||||
listIds.AddRange(childlistIds);
|
||||
listIds.AddRange(childrenIds);
|
||||
await _db.Deleteable<SysMenu>().Where(u => listIds.Contains(u.Id)).ExecuteCommandAsync();
|
||||
await _db.Deleteable<SysRoleMenu>().Where(u => listIds.Contains(u.MenuId)).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
// 若已存在相同菜单则删除本级和下级
|
||||
var menuType = menus.Where(u => u.Type == MenuTypeEnum.Menu).FirstOrDefault();
|
||||
var menuType = menus.FirstOrDefault(u => u.Type == MenuTypeEnum.Menu);
|
||||
var menuListCurrent = await _db.Queryable<SysMenu>().Where(u => u.Title == menuType.Title && u.Type == menuType.Type).ToListAsync();
|
||||
if (menuListCurrent.Count > 0)
|
||||
{
|
||||
@ -799,11 +733,13 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
private async Task<List<SysMenu>> GetMenus(string className, string busName, long pid, string menuIcon, string pagePath, List<CodeGenConfig> tableFieldList)
|
||||
{
|
||||
var pPath = string.Empty;
|
||||
string pPath;
|
||||
// 若 pid=0 为顶级则创建菜单目录
|
||||
SysMenu menuType0 = null;
|
||||
long tempPid = pid;
|
||||
var menuList = new List<SysMenu>();
|
||||
var classNameLower = className.ToLower();
|
||||
var classNameFirstLower = className.ToFirstLetterLowerCase();
|
||||
if (pid == 0)
|
||||
{
|
||||
// 目录
|
||||
@ -814,8 +750,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Title = busName + "管理",
|
||||
Type = MenuTypeEnum.Dir,
|
||||
Icon = "robot",
|
||||
Path = "/" + className.ToLower() + "Manage",
|
||||
Name = className[..1].ToLower() + className[1..] + "Manage",
|
||||
Path = "/" + classNameLower + "Manage",
|
||||
Name = classNameFirstLower + "Manage",
|
||||
Component = "Layout",
|
||||
OrderNo = 100,
|
||||
CreateTime = DateTime.Now
|
||||
@ -835,11 +771,11 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Id = YitIdHelper.NextId(),
|
||||
Pid = pid,
|
||||
Title = busName + "管理",
|
||||
Name = className[..1].ToLower() + className[1..],
|
||||
Name = classNameFirstLower,
|
||||
Type = MenuTypeEnum.Menu,
|
||||
Icon = menuIcon,
|
||||
Path = pPath + "/" + className.ToLower(),
|
||||
Component = "/" + pagePath + "/" + className[..1].ToLower() + className[1..] + "/index",
|
||||
Path = pPath + "/" + classNameLower,
|
||||
Component = "/" + pagePath + "/" + classNameFirstLower + "/index",
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
|
||||
@ -852,7 +788,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Pid = menuPid,
|
||||
Title = "查询",
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/page",
|
||||
Permission = classNameFirstLower + "/page",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -866,7 +802,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Pid = menuPid,
|
||||
Title = "详情",
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/detail",
|
||||
Permission = classNameFirstLower + "/detail",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -880,7 +816,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Pid = menuPid,
|
||||
Title = "增加",
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/add",
|
||||
Permission = classNameFirstLower + "/add",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -894,7 +830,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Pid = menuPid,
|
||||
Title = "删除",
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/delete",
|
||||
Permission = classNameFirstLower + "/delete",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -908,7 +844,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
Pid = menuPid,
|
||||
Title = "编辑",
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/update",
|
||||
Permission = classNameFirstLower + "/update",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -918,15 +854,15 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
// 加入ForeignKey、Upload、ApiTreeSelector 等接口的权限
|
||||
// 在生成表格时,有些字段只是查询时显示,不需要填写(WhetherAddUpdate),所以这些字段没必要生成相应接口
|
||||
var fkTableList = tableFieldList.Where(u => u.EffectType == "ForeignKey" && (u.WhetherAddUpdate == "Y" || u.QueryWhether == "Y")).ToList();
|
||||
foreach (var @column in fkTableList)
|
||||
foreach (var column in fkTableList)
|
||||
{
|
||||
var menuType1 = new SysMenu
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Pid = menuPid,
|
||||
Title = "外键" + @column.ColumnName,
|
||||
Title = "外键" + column.ColumnName,
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/" + column.FkEntityName + column.ColumnName + "Dropdown",
|
||||
Permission = classNameFirstLower + "/" + column.FkEntityName + column.ColumnName + "Dropdown",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -934,15 +870,15 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
menuList.Add(menuType1);
|
||||
}
|
||||
var treeSelectTableList = tableFieldList.Where(u => u.EffectType == "ApiTreeSelector").ToList();
|
||||
foreach (var @column in treeSelectTableList)
|
||||
foreach (var column in treeSelectTableList)
|
||||
{
|
||||
var menuType1 = new SysMenu
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Pid = menuPid,
|
||||
Title = "树型" + @column.ColumnName,
|
||||
Title = "树型" + column.ColumnName,
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/" + column.FkEntityName + "Tree",
|
||||
Permission = classNameFirstLower + "/" + column.FkEntityName + "Tree",
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -950,15 +886,15 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
menuList.Add(menuType1);
|
||||
}
|
||||
var uploadTableList = tableFieldList.Where(u => u.EffectType == "Upload").ToList();
|
||||
foreach (var @column in uploadTableList)
|
||||
foreach (var column in uploadTableList)
|
||||
{
|
||||
var menuType1 = new SysMenu
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Pid = menuPid,
|
||||
Title = "上传" + @column.ColumnName,
|
||||
Title = "上传" + column.ColumnName,
|
||||
Type = MenuTypeEnum.Btn,
|
||||
Permission = className[..1].ToLower() + className[1..] + "/Upload" + column.ColumnName,
|
||||
Permission = classNameFirstLower + "/Upload" + column.ColumnName,
|
||||
OrderNo = menuOrder,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
@ -989,7 +925,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
.Where(u => u.Id == SqlFunc.Subqueryable<SysCodeGenTemplateRelation>().Where(s => s.CodeGenId == input.Id).GroupBy(s => s.TemplateId).Select(s => s.TemplateId))
|
||||
.ToList();
|
||||
}
|
||||
else if (input.GenerateType.Substring(1, 1).Contains('2'))
|
||||
|
||||
if (input.GenerateType.Substring(1, 1).Contains('2'))
|
||||
{
|
||||
return _codeGetTemplateRep.AsQueryable()
|
||||
.Where(u => u.Type == CodeGenTypeEnum.Backend)
|
||||
@ -1003,18 +940,4 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小驼峰命名法(camelCase):首字母小写
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToFirstLetterLowerCase(string input)
|
||||
{
|
||||
// 检查字符串是否为空或空格
|
||||
if (string.IsNullOrWhiteSpace(input)) return input;
|
||||
|
||||
// 只转换首字母为小写
|
||||
return char.ToLower(input[0]) + input.Substring(1);
|
||||
}
|
||||
}
|
||||
@ -488,6 +488,8 @@ public class SysDatabaseService : IDynamicApiController, ITransient
|
||||
{
|
||||
builder.AddAssemblyReferenceByName("System.Linq");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
builder.AddAssemblyReferenceByName("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Text.RegularExpressions");
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddUsing("System.Linq");
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user