/// <summary> /// 初始化模板 /// </summary> /// <returns></returns> public static IEnumerable<TemplateInfo> GetTemplateInfos()
{
var dbHelper =
new YbSqliteHelper();
// 加载保存到数据库中的模板 var result = dbHelper.FindTemplateInfosBy(StaticResources.PlugInGroupKey);
if (result ==
null || result.Count ==
0)
{
// 数据库中不包含该插件组的任何模板信息,则保存到数据库 return InstallTemplates(dbHelper);
}
return result;
}
/// <summary> /// 保存模板到数据库 /// </summary> /// <param name="dbHelper"></param> /// <returns></returns> private static IEnumerable<TemplateInfo> InstallTemplates(YbSqliteHelper dbHelper)
{
var templateInfos = StaticResources.GetDefaultTemplateInfos().ToList();
foreach (
var item
in templateInfos)
dbHelper.InsertTemplateInfo(item);
return templateInfos;
}
/// <summary> /// 默认模板信息 /// </summary> /// <returns></returns> public static IEnumerable<TemplateInfo> GetDefaultTemplateInfos()
{
var templateInfos =
new List<TemplateInfo>
{
new TemplateInfo()
{
Name =
" 实体对象模板 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\Entity\User.tt ",
Description =
" 实体对象模板 ",
DisplayOrder =
5,
Encoding = Encoding.Default,
ExportFileNameFormatString =
" %s.cs ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.Entities\%s ",
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = EntitiesPlugInTemplateTag|SolutionPlugInTemplateTag
},
new TemplateInfo()
{
Name =
" 实体对象后置代码模板 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\Entity\AutoGenerated.tt ",
Description =
" 实体对象后置代码模板 ",
DisplayOrder =
10,
Encoding = Encoding.Default,
ExportFileNameFormatString =
" %s.AutoGenerated.cs ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.Entities\%s ",
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = EntitiesPlugInTemplateTag|SolutionPlugInTemplateTag
},
new TemplateInfo()
{
Name =
" 实体项目模板 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\Entity\ProjectInfo.tt ",
Description =
" 实体项目模板 ",
DisplayOrder =
15,
Encoding = Encoding.Default,
ExportFileNameFormatString =
" YbRapidSolution.Entities.csproj ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.Entities\%s ",
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = SolutionPlugInTemplateTag|IsTableInfoListOfTemplateArg
},
new TemplateInfo()
{
Name =
" 对象页面文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\aspx.tt ",
Description =
" 对象页面文件 ",
DisplayOrder =
50,
ExportFileNameFormatString =
" %sadmin.aspx ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Admin\%s ",
Encoding = Encoding.UTF8,
SyntaxHighlightingName = SyntaxHighlighting.ASPX,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = UIPlugInTemplateTag|SolutionPlugInTemplateTag
},
new TemplateInfo()
{
Name =
" 对象页面后置文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\aspx.cs.tt ",
Description =
" 对象页面后置文件 ",
DisplayOrder =
55,
ExportFileNameFormatString =
" %sadmin.aspx.cs ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Admin\%s ",
Encoding = Encoding.UTF8,
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = UIPlugInTemplateTag|SolutionPlugInTemplateTag
},
new TemplateInfo()
{
Name =
" 对象页面设计时后置文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\aspx.designer.cs.tt ",
Description =
" 对象页面设计时后置文件 ",
DisplayOrder =
65,
ExportFileNameFormatString =
" %sadmin.aspx.designer.cs ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Admin\%s ",
Encoding = Encoding.Default,
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = UIPlugInTemplateTag|SolutionPlugInTemplateTag
},
new TemplateInfo()
{
Name =
" 对象页面后台起始页 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\Default.aspx.tt ",
Description =
" 对象页面后台起始页 ",
DisplayOrder =
70,
ExportFileNameFormatString =
" Default.aspx ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Admin\Default.aspx ",
Encoding = Encoding.UTF8,
SyntaxHighlightingName = SyntaxHighlighting.ASPX,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = SolutionPlugInTemplateTag|IsTableInfoListOfTemplateArg
},
new TemplateInfo()
{
Name =
" ASP.NET Global 后置代码文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\Global.asax.cs.tt ",
Description =
" SP.NET Global 后置代码文件 ",
DisplayOrder =
70,
EncodingName =
" Default ",
ExportFileNameFormatString =
" Global.asax.cs ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Global.asax.cs ",
Encoding = Encoding.Default,
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = SolutionPlugInTemplateTag|IsTableInfoListOfTemplateArg
},
new TemplateInfo()
{
Name =
" WebForm 项目文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\ProjectInfo.tt ",
Description =
" WebForm 项目文件 ",
DisplayOrder =
75,
ExportFileNameFormatString =
" YbRapidSolution.WebForms.csproj ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\%s ",
Encoding = Encoding.UTF8,
SyntaxHighlightingName = SyntaxHighlighting.CSharp,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = SolutionPlugInTemplateTag|IsTableInfoListOfTemplateArg
},
new TemplateInfo()
{
Name =
" Web.config 文件 ",
TemplateRelativePath =
@" Templates\CastleActiveRecord\WebForm\Web.config.tt ",
Description =
" Web.config 文件 ",
DisplayOrder =
80,
ExportFileNameFormatString =
" Web.config ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Web.config ",
Encoding = Encoding.UTF8,
SyntaxHighlightingName = SyntaxHighlighting.XML,
BuildEnable =
true,
PlugInGroupKey = StaticResources.PlugInGroupKey,
Tag = SolutionPlugInTemplateTag|IsTableInfoListOfTemplateArg
},
new TemplateInfo()
{
Name =
" 权限数据库表初始化脚本文件 ",
TemplateRelativePath =
@" Templates\ProviderInstallScript.sql ",
Description =
" 权限数据库表初始化脚本文件 ",
DisplayOrder =
100,
ExportFileNameFormatString =
@" ProviderInstallScript.sql ",
ExportRelativePathFormatString =
@" YbRapidSolution\YbRapidSolution.WebForms\Web.config ",
Encoding = Encoding.Default,
SyntaxHighlightingName = SyntaxHighlighting.XML,
BuildEnable =
false,
PlugInGroupKey = StaticResources.PlugInGroupKey
}
};
return templateInfos;
}