refactor: 设置默认Builder配置函数和Application配置函数
新增修改BlogEssay工具函数
This commit is contained in:
parent
5f8db267d9
commit
9d68c675cf
|
@ -31,8 +31,10 @@ public sealed class BlogApplicationBuilder : IHostApplicationBuilder
|
||||||
|
|
||||||
public BlogApplication Build()
|
public BlogApplication Build()
|
||||||
{
|
{
|
||||||
this.ConfigureBlogApplication();
|
this.ConfigureDefaultBlogApplicationBuilder();
|
||||||
return new BlogApplication(_hostApplicationBuilder.Build());
|
BlogApplication application = new(_hostApplicationBuilder.Build());
|
||||||
|
application.ConfigureDefaultBlogApplication();
|
||||||
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureContainer<TContainerBuilder>(
|
public void ConfigureContainer<TContainerBuilder>(
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace YaeBlog.Core.Extensions;
|
||||||
|
|
||||||
public static class BlogApplicationBuilderExtension
|
public static class BlogApplicationBuilderExtension
|
||||||
{
|
{
|
||||||
internal static void ConfigureBlogApplication(this BlogApplicationBuilder builder)
|
internal static void ConfigureDefaultBlogApplicationBuilder(this BlogApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||||
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json",
|
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json",
|
||||||
|
|
|
@ -7,6 +7,11 @@ namespace YaeBlog.Core.Extensions;
|
||||||
|
|
||||||
public static class BlogApplicationExtension
|
public static class BlogApplicationExtension
|
||||||
{
|
{
|
||||||
|
internal static void ConfigureDefaultBlogApplication(this BlogApplication application)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void UsePreRenderProcessor<T>(this BlogApplication application)
|
public static void UsePreRenderProcessor<T>(this BlogApplication application)
|
||||||
where T : IPreRenderProcessor
|
where T : IPreRenderProcessor
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,22 @@ public class BlogEssay
|
||||||
|
|
||||||
public required string HtmlContent { get; init; }
|
public required string HtmlContent { get; init; }
|
||||||
|
|
||||||
|
public BlogEssay WithNewHtmlContent(string newHtmlContent)
|
||||||
|
{
|
||||||
|
var essay = new BlogEssay
|
||||||
|
{
|
||||||
|
Title = Title,
|
||||||
|
FileName = FileName,
|
||||||
|
PublishTime = PublishTime,
|
||||||
|
Description = Description,
|
||||||
|
WordCount = WordCount,
|
||||||
|
HtmlContent = newHtmlContent
|
||||||
|
};
|
||||||
|
essay.Tags.AddRange(Tags);
|
||||||
|
|
||||||
|
return essay;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{Title}-{PublishTime}";
|
return $"{Title}-{PublishTime}";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user