|
@@ -1,5 +1,7 @@
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using AngleSharp.Common;
|
|
|
|
|
|
namespace Masuit.Tools.Strings
|
|
|
{
|
|
@@ -41,6 +43,29 @@ namespace Masuit.Tools.Strings
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 设置变量
|
|
|
+ /// </summary>
|
|
|
+ public Template Set(object obj)
|
|
|
+ {
|
|
|
+ var dic = obj.ToDictionary();
|
|
|
+ Set(dic);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设置变量
|
|
|
+ /// </summary>
|
|
|
+ public Template Set(Dictionary<string, string> dic)
|
|
|
+ {
|
|
|
+ foreach (var x in dic)
|
|
|
+ {
|
|
|
+ Content = Content.Replace("{{" + x.Key + "}}", x.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 渲染模板
|
|
|
/// </summary>
|
|
@@ -60,4 +85,4 @@ namespace Masuit.Tools.Strings
|
|
|
return Content;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|