From 5d914f7034ef6b43f240d870646ead0dc5853ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=9A=93?= <353374337@qq.com> Date: Thu, 18 Oct 2018 10:59:53 +0800 Subject: [PATCH] =?UTF-8?q?Java=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoderEngine/JavaCodeWrite.cs | 43 ++++++++++++++++++++++++++++++++---- UseEngineConsolo/Program.cs | 14 ++++++------ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/CoderEngine/JavaCodeWrite.cs b/CoderEngine/JavaCodeWrite.cs index b865a3f..fd51453 100644 --- a/CoderEngine/JavaCodeWrite.cs +++ b/CoderEngine/JavaCodeWrite.cs @@ -61,13 +61,49 @@ namespace CoderEngine CoderAddLine("public class " + ClassName + " {"); foreach (var tl in TopMode.TypeList) { - CoderAddLine(tabstr + "@SerializedName(value = \"" + tl.Name + "\")"); - CoderAddLine(tabstr + "public " + CSharpToJavaTypeName(tl.MemberType) + " " + tl.Name + ";"); + CoderAddLine(""); + if (tl.MemberType.Name == "List`1") + { + + } + else + { + CoderAddLine(tabstr + "@SerializedName(value = \"" + tl.Name + "\")"); + } + + CoderAddLine(tabstr + "private " + CSharpToJavaTypeName(tl.MemberType) + " " + tl.Name + ";"); + } + CoderAddLine(""); + CoderAddLine(tabstr + "//"+ ClassName + "中所有属性对应get set 方法"); + + foreach (var tl in TopMode.TypeList) + { + CoderAddLine(""); + CoderAddLine(tabstr + "public " + CSharpToJavaTypeName(tl.MemberType) + " get" + tl.Name + "(){return " + tl.Name + ";}"); + CoderAddLine(""); + CoderAddLine(tabstr + "public void set" + tl.Name + "(" + CSharpToJavaTypeName(tl.MemberType) + " " + tl.Name + "){return this." + tl.Name + " = " + tl.Name + ";}"); + } + CoderAddLine(""); + CoderAddLine(tabstr+"//为该实体类生成的toString打印方法"); + CoderAddLine(tabstr+ "@Override"); + CoderAddLine(tabstr + "public String toString() {"); + CoderAddLine(tabstr + tabstr + "return \"CommentInfoModel{ \" +"); + foreach (var tl in TopMode.TypeList) + { + CoderAddLine(tabstr + tabstr + tabstr + "\"" + tl.Name + "='\" + " + tl.Name + " + '\\'' + \",\" "); + } + CoderAddLine(tabstr + tabstr + tabstr + "'}';"); + + CoderAddLine(tabstr + "}"); + CoderAddLine("}"); + + + foreach (var tl in TopMode.TypeList) { if(tl.MemberType.Name == "List`1") @@ -78,9 +114,8 @@ namespace CoderEngine JavaCodeDownRecursion(tl); } } - } - + } /// diff --git a/UseEngineConsolo/Program.cs b/UseEngineConsolo/Program.cs index 39054d0..ab58f9a 100644 --- a/UseEngineConsolo/Program.cs +++ b/UseEngineConsolo/Program.cs @@ -11,21 +11,21 @@ namespace UseEngineConsolo public class A { - public int a { get; set; } - public int aa { get; set; } - public DateTime? date { get; set; } - public List Blist { get; set; } + public string UserID { get; set; } + public int Sex { get; set; } + public DateTime? Birthday { get; set; } + public List SunList { get; set; } } public class B { - public string b { get; set; } - public List Clist { get; set; } + public string SouUserID { get; set; } + public List Girlfriends { get; set; } } public class C { - public string string_b { get; set; } + public string GirlName { get; set; } } class Program