Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sunxiaotianmg
Mozi.HttpEmbedded
提交
221e37d6
M
Mozi.HttpEmbedded
项目概览
sunxiaotianmg
/
Mozi.HttpEmbedded
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mozi.HttpEmbedded
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
221e37d6
编写于
7月 10, 2021
作者:
JasonWcx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
开始实现模板引擎
上级
684dd61b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
104 addition
and
44 deletion
+104
-44
Mozi.HttpEmbedded/Document/Example.html
Mozi.HttpEmbedded/Document/Example.html
+19
-19
Mozi.HttpEmbedded/Document/Home.html
Mozi.HttpEmbedded/Document/Home.html
+1
-1
Mozi.HttpEmbedded/HttpServer.cs
Mozi.HttpEmbedded/HttpServer.cs
+2
-2
Mozi.HttpEmbedded/Middleware/IMiddleware.cs
Mozi.HttpEmbedded/Middleware/IMiddleware.cs
+1
-1
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
+2
-2
Mozi.HttpEmbedded/Mozi.HttpEmbedded.svg
Mozi.HttpEmbedded/Mozi.HttpEmbedded.svg
+3
-0
Mozi.HttpEmbedded/Page/BasePage.cs
Mozi.HttpEmbedded/Page/BasePage.cs
+1
-1
Mozi.HttpEmbedded/Template/PageEngine.cs
Mozi.HttpEmbedded/Template/PageEngine.cs
+75
-18
未找到文件。
Mozi.HttpEmbedded/Document/Example
Page
.html
→
Mozi.HttpEmbedded/Document/Example.html
浏览文件 @
221e37d6
...
...
@@ -31,28 +31,28 @@
<div>
${goods.Price}
</div>
<
%
end
%
>
<!--if conditional-->
<
%
if
page=
=1
%
>
<div>
if condition
</div>
<
%
else
if
%
>
<div>
else if condition
</div>
<
%
end
%
>
<!--if conditional-->
<
%
if
page=
=1
%
>
<div>
if condition
</div>
<
%
else
if
%
>
<div>
else if condition
</div>
<
%
end
%
>
<!--switch statement-->
<
%
switch
(
pagecount
)%
>
<
%
case
%
>
<!--switch statement-->
<
%
switch
(
pagecount
)%
>
<
%
case
%
>
<
%
break
%
>
<
%
end
%
>
<
%
break
%
>
<
%
end
%
>
<!--Math function-->
<p>
<div>
$math.abs(-1),$math.ceil(1.2)
</div>
</p>
<!--Math function-->
<p>
<div>
$math.abs(-1),$math.ceil(1.2)
</div>
</p>
<!--format function-->
<p>
<div>
$format("{0},{1}",Title,Content)
</div>
</p>
<!--format function-->
<p>
<div>
$format("{0},{1}",Title,Content)
</div>
</p>
</body>
</html>
\ No newline at end of file
Mozi.HttpEmbedded/Document/Home.html
浏览文件 @
221e37d6
...
...
@@ -24,6 +24,6 @@
<p>
能看到此页面,证明服务器已正常启动,配置一个默认首页就能使此页面不再显示。服务器使用说明请参看源代码和相关文档。
</p>
<p>
意见建议请联系软件作者,或提交至Issue。
</p>
<hr
style=
"border: 0; border-bottom: 1px solid #dedede;"
/>
<p><em>
版本:v${Info.VersionName}
</em></p>
<p><em>
$format("版本:v{0}",Info.VersionName)
</em></p>
</body>
</html>
\ No newline at end of file
Mozi.HttpEmbedded/HttpServer.cs
浏览文件 @
221e37d6
...
...
@@ -262,7 +262,7 @@ namespace Mozi.HttpEmbedded
string
doc
=
DocLoader
.
Load
(
"Error.html"
);
PageEngine
pc
=
new
PageEngine
();
pc
.
LoadFromText
(
doc
);
pc
.
Set
Parameter
(
"Error"
,
new
pc
.
Set
(
"Error"
,
new
{
Code
=
StatusCode
.
InternalServerError
.
Code
.
ToString
(),
Title
=
StatusCode
.
InternalServerError
.
Text
,
...
...
@@ -363,7 +363,7 @@ namespace Mozi.HttpEmbedded
var
doc
=
DocLoader
.
Load
(
"Home.html"
);
PageEngine
pc
=
new
PageEngine
();
pc
.
LoadFromText
(
doc
);
pc
.
Set
Parameter
(
"Info"
,
new
pc
.
Set
(
"Info"
,
new
{
VersionName
=
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
GetName
().
Version
.
ToString
(),
});
...
...
Mozi.HttpEmbedded/Middleware/IMiddleware.cs
浏览文件 @
221e37d6
...
...
@@ -5,6 +5,6 @@
/// </summary>
public
interface
IMiddleware
{
void
Invoke
();
}
}
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
浏览文件 @
221e37d6
...
...
@@ -105,7 +105,7 @@
<Compile
Include=
"HttpVersion.cs"
/>
<Compile
Include=
"Common\Log.cs"
/>
<Compile
Include=
"Page\BaseApi.cs"
/>
<Compile
Include=
"Page\
Abs
Page.cs"
/>
<Compile
Include=
"Page\
Base
Page.cs"
/>
<Compile
Include=
"Serialize\DataSerializeType.cs"
/>
<Compile
Include=
"Cache\Global.cs"
/>
<Compile
Include=
"Template\PageEngine.cs"
/>
...
...
@@ -170,7 +170,7 @@
<ItemGroup>
<EmbeddedResource
Include=
"Document\Home.html"
/>
<EmbeddedResource
Include=
"Document\Error.html"
/>
<EmbeddedResource
Include=
"Document\Example
Page
.html"
/>
<EmbeddedResource
Include=
"Document\Example.html"
/>
<Content
Include=
"Source\mime.data"
/>
<Content
Include=
"WebDav\Icon.png"
/>
</ItemGroup>
...
...
Mozi.HttpEmbedded/Mozi.HttpEmbedded.svg
0 → 100644
浏览文件 @
221e37d6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
version=
"1.1"
width=
"791px"
height=
"498px"
viewBox=
"-0.5 -0.5 791 498"
content=
"<mxfile host="app.diagrams.net" modified="2021-07-10T10:05:01.234Z" agent="5.0 (Windows)" etag="zMLJLe5Bo3q3GYsHUGHe" version="14.8.5" type="device"><diagram id="0SU5S7vlTBd-NNq4Iu0A" name="Page-1">3VpLc6M4EP41PiaFJBD2MU4ymdqa3UpNDjtz2lJAAXYwYoQc2/n1K4xkEPIzAePsxWU1enZ//Und0gjdzpYPnOTxnyyk6Qg64XKE7kYQTlwof0vBqhJgACpBxJOwEjUET8kbVUJHSedJSAujomAsFUluCgOWZTQQhoxwzhZmtReWmqPmJKKW4CkgqS39OwlFXEnH0K/lX2kSxXpkgCfVlxnRldVKipiEbNEQofsRuuWMierfbHlL01J3Wi9Vuy87vm4mxmkmjmnweD/9469/HpzIf/09K+By/ibcK4TV5MRKr5iGUgGqyLiIWcQykt7X0iln8yykZbeOLNV1vjGWSyGQwn+pECtlTTIXTIpiMUvVVzljvvqh2q8LP8vCtaeLd8vmx7uVLi0T8UP3If83WslS3ags6DbV+spF7dSbEhVszgO6T1kKf4RHVOypV3WorPBA2YzKRciGnKZEJK/mRIgCaLSpt2n6yBI5RegoX0KeAt1Klx2zi2oBqlWNBPmnMY1atMbHCVjx3EGwomzuGDb39xt9AzBgAsw/hLAB0IL7QQtwHRMtyDO7qCZmoeWGc7JqVMvLCsXucaDTGmfimTR0Wn35p5pBp9BVtngl6Vzp84kFv6h4ovyVcgvWJmgXcSLoU07W1l7IXc4EqOqackGX+0Fj21jrxDd1ArEqL+otB2i9xc3tZtyigCYuDP8/VWN6BkNtDPVe8NNw1N7dFuB+yNvxt5u4Y3fEoDUOaJ0KDs3LrN+POwJs+6OQ2g2+JCktBndHT1HSRie+Z7sj3OKObZt25o0esJRyXm/0B3NHvxd39PVhRocl7nHu2JkH+JYH3OTJ4MjHE1MtHhwa+e54YOTDwZA/7gX53mRg5I8t5D+WMfjQ0PfQpUEfDU36JyF/XXqkPJGLl0fqzt1Bq/5gPIWc7XY+2m8+ZDQ9zQa8v7O5uIAgw5tgA+AIDw7wQRMKZhIJHplQODFj1aUD6PTnIQf4cATzMaN6l2PUY7NEn8CocFhWAxarfRUi/05/z2khLIMfIDPT2h1Qm9sOerfmT5BNbf3lTxD8VJv3OxLrZeH9+/1hFusp8HPKdTXB4vpjs5MdafRTMzHtEFOP02tmxTsuriwt9I0809SED0mTKJP/A2mt0qbT0iuTgKQ36sMsCcMKqbRI3sjzur/S8EoZsnNvOvLu9rm1uqlTjUeb+7EmSPa41E4SuHKuHaSvG5XOr9SYH42ZTHZptWcvLwXt58Zl6OD3XSTiXBCJ9BNDYwjORCLtaP08JDKxSGRriP4pWcTbAQnVvSQRx0MmiaBOSMTsFKBzkQiyI9LKmlKOU6mq6bMMTnEk1mwhxds2jEJw9mvzAgKaBi9ikpf1ZsuofANy/ZKyRRATLq5DGiRFwrIdAW4HRz8M/LYravM1Dn/+xD77tW/Pu0vWo0FYu8uwFp4xBMLHkjnqhcvb9+Rw3Lon74jJQeuOFzn778kP1O+J+S8qagHnA6E76QVc7dtV98zJdtfeyau4vchZVlxA0h2YIN9cRjS4G501J4ntTMe0fEV4AQncNlFdwCMR11KWfabgu8AmNSH6OzmWNFNUjLM+o6wPMLcsZWWYkbGMdmMUgM3Tx7asur/FKKg3m9hvK/iONN3/wwDtt1NjbBkAbzEAPN0Aslg/160oun7zjO7/Aw==</diagram></mxfile>"
><defs/><g><path
d=
"M 330 147 L 370.63 147"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 375.88 147 L 368.88 150.5 L 370.63 147 L 368.88 143.5 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><path
d=
"M 230 192 L 160 192 L 106.37 192"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 101.12 192 L 108.12 188.5 L 106.37 192 L 108.12 195.5 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"230"
y=
"57"
width=
"100"
height=
"180"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 98px; height: 1px; padding-top: 147px; margin-left: 231px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
SocketServer
</div></div></div></foreignObject><text
x=
"280"
y=
"151"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
SocketServer
</text></switch></g><path
d=
"M 577 72 L 577 7 L 267 7 L 267 50.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 267 55.88 L 263.5 48.88 L 267 50.63 L 270.5 48.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"555"
y=
"72"
width=
"120"
height=
"60"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 102px; margin-left: 556px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
StaticFiles
</div></div></div></foreignObject><text
x=
"615"
y=
"106"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
StaticFiles
</text></switch></g><path
d=
"M 714 382 L 714 430.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 714 435.88 L 710.5 428.88 L 714 430.63 L 717.5 428.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"654"
y=
"322"
width=
"120"
height=
"60"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 352px; margin-left: 655px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
Api
</div></div></div></foreignObject><text
x=
"714"
y=
"356"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
Api
</text></switch></g><path
d=
"M 554 382 L 554 430.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 554 435.88 L 550.5 428.88 L 554 430.63 L 557.5 428.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"494"
y=
"322"
width=
"120"
height=
"60"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 352px; margin-left: 495px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
Page
</div></div></div></foreignObject><text
x=
"554"
y=
"356"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
Page
</text></switch></g><path
d=
"M 616 222 L 616 242 L 617 242 L 617 243.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 617 248.88 L 613.5 241.88 L 617 243.63 L 620.5 241.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"556"
y=
"162"
width=
"120"
height=
"60"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 192px; margin-left: 557px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
Router
</div></div></div></foreignObject><text
x=
"616"
y=
"196"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
Router
</text></switch></g><path
d=
"M 480 102 L 548.63 102"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 553.88 102 L 546.88 105.5 L 548.63 102 L 546.88 98.5 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><path
d=
"M 480 192 L 549.63 192"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 554.88 192 L 547.88 195.5 L 549.63 192 L 547.88 188.5 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"377"
y=
"57"
width=
"103"
height=
"180"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 101px; height: 1px; padding-top: 147px; margin-left: 378px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
HttpRequest
</div></div></div></foreignObject><text
x=
"429"
y=
"151"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
HttpRequest
</text></switch></g><path
d=
"M 660.5 275 L 714 275 L 714 315.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 714 320.88 L 710.5 313.88 L 714 315.63 L 717.5 313.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 298px; margin-left: 715px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; "
>
Api
</div></div></div></foreignObject><text
x=
"715"
y=
"301"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"11px"
text-anchor=
"middle"
>
Api
</text></switch></g><path
d=
"M 581.5 275 L 554 275 L 554 315.63"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 554 320.88 L 550.5 313.88 L 554 315.63 L 557.5 313.88 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 298px; margin-left: 555px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; "
>
Page
</div></div></div></foreignObject><text
x=
"555"
y=
"301"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"11px"
text-anchor=
"middle"
>
Page
</text></switch></g><path
d=
"M 617 250 L 656.5 275 L 617 300 L 577.5 275 Z"
fill=
"#ffffff"
stroke=
"#000000"
stroke-width=
"2"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 77px; height: 1px; padding-top: 275px; margin-left: 579px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
Page
<br
/>
or Api
</div></div></div></foreignObject><text
x=
"617"
y=
"279"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
Page...
</text></switch></g><path
d=
"M 100 102 L 130 102 L 223.63 102"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 228.88 102 L 221.88 105.5 L 223.63 102 L 221.88 98.5 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><path
d=
"M 470 467 L 267 467 L 267 243.37"
fill=
"none"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"stroke"
/><path
d=
"M 267 238.12 L 270.5 245.12 L 267 243.37 L 263.5 245.12 Z"
fill=
"#000000"
stroke=
"#000000"
stroke-miterlimit=
"10"
pointer-events=
"all"
/><rect
x=
"470"
y=
"437"
width=
"320"
height=
"60"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 318px; height: 1px; padding-top: 467px; margin-left: 471px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
HttpResponse
</div></div></div></foreignObject><text
x=
"630"
y=
"471"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
HttpResponse
</text></switch></g><rect
x=
"0"
y=
"57"
width=
"100"
height=
"180"
fill=
"#ffffff"
stroke=
"#000000"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 98px; height: 1px; padding-top: 147px; margin-left: 1px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "
>
Browser
</div></div></div></foreignObject><text
x=
"50"
y=
"151"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
Browser
</text></switch></g><rect
x=
"125"
y=
"162"
width=
"70"
height=
"30"
fill=
"none"
stroke=
"none"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 177px; margin-left: 160px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: nowrap; "
><br
/>
response
</div></div></div></foreignObject><text
x=
"160"
y=
"181"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>


response
</text></switch></g><rect
x=
"130"
y=
"83"
width=
"60"
height=
"20"
fill=
"none"
stroke=
"none"
pointer-events=
"all"
/><g
transform=
"translate(-0.5 -0.5)"
><switch><foreignObject
style=
"overflow: visible; text-align: left;"
pointer-events=
"none"
width=
"100%"
height=
"100%"
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
><div
xmlns=
"http://www.w3.org/1999/xhtml"
style=
"display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 93px; margin-left: 160px;"
><div
style=
"box-sizing: border-box; font-size: 0; text-align: center; "
><div
style=
"display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: nowrap; "
>
request
</div></div></div></foreignObject><text
x=
"160"
y=
"97"
fill=
"#000000"
font-family=
"Helvetica"
font-size=
"12px"
text-anchor=
"middle"
>
request
</text></switch></g></g><switch><g
requiredFeatures=
"http://www.w3.org/TR/SVG11/feature#Extensibility"
/><a
transform=
"translate(0,-5)"
xlink:href=
"https://www.diagrams.net/doc/faq/svg-export-text-problems"
target=
"_blank"
><text
text-anchor=
"middle"
font-size=
"10px"
x=
"50%"
y=
"100%"
>
Viewer does not support full SVG 1.1
</text></a></switch></svg>
\ No newline at end of file
Mozi.HttpEmbedded/Page/
Abs
Page.cs
→
Mozi.HttpEmbedded/Page/
Base
Page.cs
浏览文件 @
221e37d6
...
...
@@ -3,7 +3,7 @@
/// <summary>
/// 页面抽象类
/// </summary>
public
abstract
class
Abs
Page
public
abstract
class
Base
Page
{
protected
HttpContext
Context
{
get
;
set
;
}
/// <summary>
...
...
Mozi.HttpEmbedded/Template/PageEngine.cs
浏览文件 @
221e37d6
...
...
@@ -8,8 +8,6 @@ using System.Text.RegularExpressions;
namespace
Mozi.HttpEmbedded.Template
{
//TODO 2021/07/06 考虑将这个模板引擎单独剥离成一个项目
//TODO 需要实现一个模板引擎或考虑通过Razor引擎提高通用性
//2021/06/08 文档模板仅仅实现类建议参数注入功能
/// <summary>
/// 页面生成器
/// </summary>
...
...
@@ -36,9 +34,13 @@ namespace Mozi.HttpEmbedded.Template
internal
PageEngine
LoadFromStream
(
Stream
stream
)
{
Prepare
();
return
this
;
}
/// <summary>
/// 从文本载入模板
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
public
PageEngine
LoadFromText
(
string
template
)
{
_template
=
template
;
...
...
@@ -47,8 +49,23 @@ namespace Mozi.HttpEmbedded.Template
public
PageEngine
Prepare
()
{
_page
=
_template
;
ApplyAll
();
return
this
;
}
/// <summary>
/// 应用所有规则
/// </summary>
/// <returns></returns>
private
PageEngine
ApplyAll
()
{
//首先解析语句
//填充全局变量
InflateGlobal
();
//填充变量
InflateValues
();
//填充format指令执行结果
InflateExpressionFormat
();
return
this
;
}
/// <summary>
...
...
@@ -70,18 +87,10 @@ namespace Mozi.HttpEmbedded.Template
foreach
(
var
m
in
matchesParam
)
{
var
param
=
m
.
ToString
().
Trim
(
new
char
[]
{
'$'
,
'{'
,
'}'
});
if
(!
param
.
Contains
(
"."
))
var
paramValue
=
GetPatternValue
(
param
);
if
(
paramValue
!=
null
)
{
_page
=
_page
.
Replace
(
m
.
ToString
(),
GetParameter
(
param
).
ToString
());
}
else
{
string
[]
target
=
param
.
Split
(
new
char
[]
{
'.'
});
object
pValue
=
_params
[
target
[
0
]];
PropertyInfo
props
=
pValue
.
GetType
().
GetProperty
(
target
[
1
],
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
IgnoreCase
);
var
targetValue
=
props
.
GetValue
(
pValue
,
null
);
_page
=
_page
.
Replace
(
m
.
ToString
(),
targetValue
.
ToString
());
_page
=
_page
.
Replace
(
m
.
ToString
(),
paramValue
);
}
}
return
this
;
...
...
@@ -106,13 +115,61 @@ namespace Mozi.HttpEmbedded.Template
{
return
this
;
}
private
string
GetPatternValue
(
string
pattern
)
{
string
result
=
null
;
if
(!
pattern
.
Contains
(
"."
))
{
result
=
Get
(
pattern
).
ToString
();
}
else
{
string
[]
target
=
pattern
.
Split
(
new
char
[]
{
'.'
});
object
pValue
=
_params
[
target
[
0
]];
private
PageEngine
ParseExpressionMath
()
PropertyInfo
props
=
pValue
.
GetType
().
GetProperty
(
target
[
1
],
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
IgnoreCase
);
var
targetValue
=
props
.
GetValue
(
pValue
,
null
);
result
=
targetValue
.
ToString
();
}
return
result
;
}
private
PageEngine
InflateExpressionMath
()
{
Regex
regParam
=
new
Regex
(
"\\$math\\.\\d+\\(.*\\)"
);
MatchCollection
matchesParam
=
regParam
.
Matches
(
_page
);
foreach
(
var
m
in
matchesParam
)
{
var
pattern
=
m
.
ToString
().
Trim
(
new
char
[]
{
'$'
,
'{'
,
'}'
});
var
paramValue
=
GetPatternValue
(
pattern
);
if
(
paramValue
!=
null
)
{
_page
=
_page
.
Replace
(
m
.
ToString
(),
paramValue
);
}
}
return
this
;
}
private
PageEngine
ParseExpressionFormat
()
/// <summary>
/// 应用函数format
/// </summary>
/// <returns></returns>
private
PageEngine
InflateExpressionFormat
()
{
Regex
regParam
=
new
Regex
(
"\\$format\\(.*\\)"
);
MatchCollection
matchesParam
=
regParam
.
Matches
(
_page
);
foreach
(
var
m
in
matchesParam
)
{
var
pattern
=
m
.
ToString
().
Replace
(
"$format"
,
""
).
Trim
(
new
char
[]
{
'('
,
')'
});
var
splitIndex
=
pattern
.
IndexOf
(
"\","
);
var
format
=
pattern
.
Substring
(
1
,
splitIndex
-
1
);
var
paramexp
=
pattern
.
Substring
(
splitIndex
+
2
);
var
pms
=
paramexp
.
Split
(
new
char
[]
{
','
});
var
pmvs
=
new
object
[
pms
.
Length
];
for
(
int
i
=
0
;
i
<
pms
.
Length
;
i
++)
{
pmvs
[
i
]
=
GetPatternValue
(
pms
[
i
]);
}
_page
=
_page
.
Replace
(
m
.
ToString
(),
string
.
Format
(
format
,
pmvs
));
}
return
this
;
}
/// <summary>
...
...
@@ -138,7 +195,7 @@ namespace Mozi.HttpEmbedded.Template
/// </summary>
/// <param name="paramName"></param>
/// <returns></returns>
public
object
Get
Parameter
(
string
paramName
)
public
object
Get
(
string
paramName
)
{
if
(
_params
.
ContainsKey
(
paramName
))
{
...
...
@@ -155,7 +212,7 @@ namespace Mozi.HttpEmbedded.Template
/// <param name="paramName">参数名</param>
/// <param name="paramValue">参数值</param>
/// <returns></returns>
public
PageEngine
Set
Parameter
(
string
paramName
,
object
paramValue
)
public
PageEngine
Set
(
string
paramName
,
object
paramValue
)
{
if
(
_params
.
ContainsKey
(
paramName
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录