vengine初步实现增删改查
This commit is contained in:
77
visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs
Normal file
77
visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Tnb.Core;
|
||||
|
||||
namespace Tnb.Vengine;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class TemplateContext
|
||||
{
|
||||
#region 模板文件名,同时作为模板Key
|
||||
public const string KeyAppService = "AppService";
|
||||
public const string KeyDto = "AppServiceDto";
|
||||
public const string KeyEntity = "EntityInfo";
|
||||
public const string KeyEntityDto = "EntityDto";
|
||||
public const string KeyEntityAppService = "EntityController";
|
||||
public const string KeyEntityPageVue = "EntityPageVue";
|
||||
public const string KeyTableForeigns = "TableForeigns";
|
||||
public const string KeyVmodel = "Vmodel";
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public TemplateContext(string moduleCode)
|
||||
{
|
||||
#if DEBUG
|
||||
BasePath = CodeHelper.GetSolutionDirectoryPath(false)!;
|
||||
#else
|
||||
BasePath = EApp.Options.App.AcmenBasePath;
|
||||
#endif
|
||||
ModuleCode = moduleCode;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BasePath { get; set; }
|
||||
private string ModuleCode { get; }
|
||||
|
||||
private string ModulePath => Path.Combine(BasePath, $"{ModuleCode}.Acmen");
|
||||
private string UiProjPath => Path.Combine(BasePath, "ItMgrWeb");
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string AppServicePath => Path.Combine(ModulePath, "AppServices");
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string PagePath => Path.Combine(UiProjPath, "src", "views");
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCsName(string name)
|
||||
{
|
||||
name = Regex.Replace(name.TrimStart('@', '.'), @"[^\w]", "_");
|
||||
name = char.IsLetter(name, 0) ? name : string.Concat("_", name);
|
||||
IEnumerable<string> arrs = name.Split('_');
|
||||
//if (arrs.Count() > 1 && Config.IsRemovePrefix) { arrs = arrs.Skip(1); }
|
||||
//if (Config.IsSnakeCaseToPascalCase) { arrs = arrs.Select(a => a.ToPascalCase()); }
|
||||
if (arrs.Count() > 0) { arrs = arrs.Select(a => a.ToPascal()); }
|
||||
|
||||
return string.Join("", arrs);
|
||||
}
|
||||
}
|
||||
|
||||
public enum eLambdaType
|
||||
{
|
||||
Join,
|
||||
ManyToMany,
|
||||
Where,
|
||||
MemberBinding,
|
||||
OneToMany
|
||||
}
|
||||
Reference in New Issue
Block a user