From df0116e2d80530f884f96ed65fa57dbec5296686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9A=93=E6=9C=88?= <353374337@qq.com> Date: Fri, 19 Oct 2018 01:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=BA=E5=B8=A6=E6=8A=8AC#=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=8A=E5=90=A7=20233333?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CodeShowWeb/Index.aspx | 21 ++++++++++++++---- CodeShowWeb/Index.aspx.cs | 40 ++++++++++++++++++++++++++++------ CoderEngine/CSharpCodeWrite.cs | 2 +- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/CodeShowWeb/Index.aspx b/CodeShowWeb/Index.aspx index f1e4148..4d7d7bc 100644 --- a/CodeShowWeb/Index.aspx +++ b/CodeShowWeb/Index.aspx @@ -3,7 +3,7 @@ - highlight + 服务端参数跨语言代码转换引擎 @@ -13,15 +13,28 @@

服务端参数跨语言代码转换引擎 Ver 0.1.0 -- 皓月

是一个C#服务端API参数实体类、转换成于各类语言客户端解析参数代码,减少客户端开发人员重复工作量

+ PS:文档引用本页调用方法 {http://引擎url}?lang={要转换到的目标语言类型}&Assembly={程序集命名空间}&ReqM={请求参数在服务端的实体类名}&ReqM={请求参数在服务端的实体类名}

请选择目前支持转换到的目标语言:

-

Java/AndroidSwift/iOSAjax/JavascriptPHPGolang、...

+

Java/AndroidSwift/iOSAjax/JavascriptPHPGolang

+

C#MarkDown参数表格编码皓月转换引擎实体类转译Json

选择你喜欢的代码配色方案

-

已转换为目标语种为"<%=GetLang() %>"代码结果:

+

已转换为目标语种为"<%=GetLangCodeShowName() %>"代码结果:

+ +

+

请求参数代码:

+
+    
+        <%=GetCode() %>
+                
+            
+
+

+

返回参数代码:

-                
+                
         <%=GetCode() %>
                 
             
diff --git a/CodeShowWeb/Index.aspx.cs b/CodeShowWeb/Index.aspx.cs index 01c80ba..d83fc43 100644 --- a/CodeShowWeb/Index.aspx.cs +++ b/CodeShowWeb/Index.aspx.cs @@ -17,25 +17,36 @@ namespace CodeShowWeb public string GetCode() { - string CodeLang = GetLang(); + string CodeLang = GetLangParam(); + + string CodeStr = ""; if (CodeLang == "Java") { - return new JavaCodeWrite().ModelToJavaCode("CoderEngine", "A"); + CodeStr = new JavaCodeWrite().ModelToJavaCode("CoderEngine", "A"); } else if (CodeLang == "Swift") { - return new SwiftCodeWrite().ModelToSwiftCode("CoderEngine", "A"); + CodeStr = new SwiftCodeWrite().ModelToSwiftCode("CoderEngine", "A"); } else if (CodeLang == "JavaScript") { - return new AjaxCodeWrite().ModelToAjaxCode("CoderEngine", "A"); + CodeStr = new AjaxCodeWrite().ModelToAjaxCode("CoderEngine", "A"); + } + + else if (CodeLang == "CSharp") + { + CodeStr = new CSharpCodeWrite().ModelToCSCode("CoderEngine", "A"); } - return "代码语言尚未支持"; + //避免类似 List 这类的< >被识别为html标签显示异常 + CodeStr = CodeStr.Replace("<", "<"); + CodeStr = CodeStr.Replace(">", ">"); + + return CodeStr; } - public string GetLang() + public string GetLangParam() { var lang = Request.QueryString["Lang"]; if (lang != null && lang != "") @@ -46,9 +57,20 @@ namespace CodeShowWeb return "Java"; } + public string GetLangCodeShowName() + { + string str = GetLangParam(); + switch (str) + { + case "Java": return "java"; + case "C#": return "C#"; + default:return str; + } + } + public string GetCodeStyle() { - string CodeLang = GetLang(); + string CodeLang = GetLangParam(); if (CodeLang == "Java") { return "androidstudio.css"; @@ -61,6 +83,10 @@ namespace CodeShowWeb { return "codepen-embed.css"; } + else if (CodeLang == "CSharp") + { + return "atelier-plateau-dark.css"; + } return "代码语言尚未支持"; } diff --git a/CoderEngine/CSharpCodeWrite.cs b/CoderEngine/CSharpCodeWrite.cs index bc15760..a9101dd 100644 --- a/CoderEngine/CSharpCodeWrite.cs +++ b/CoderEngine/CSharpCodeWrite.cs @@ -24,7 +24,7 @@ namespace CoderEngine CodeStr += CodeLine + "\n"; } - public string ModelToJavaCode(string _AssemblyName, string _TypeName) + public string ModelToCSCode(string _AssemblyName, string _TypeName) { TypeMode tm = new _ModleReader().ModelCheck(_AssemblyName, _TypeName); ModelToCSCodeWriter(tm);