From c729f2401f8542bb56e924b0a7632605e8decf7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9A=93=E6=9C=88?= <353374337@qq.com> Date: Wed, 17 Oct 2018 22:54:58 +0800 Subject: [PATCH] =?UTF-8?q?Java=E4=BB=A3=E7=A0=81=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 63 +++++ .gitignore | 261 ++++++++++++++++++++ CoderEngine/AjaxCodeWrite.cs | 132 ++++++++++ CoderEngine/CoderEngine.csproj | 48 ++++ CoderEngine/JavaCodeWrite.cs | 136 ++++++++++ CoderEngine/ModleReader.cs | 139 +++++++++++ CoderEngine/Properties/AssemblyInfo.cs | 36 +++ ServParam2ClientModelEngine.sln | 28 +++ UseEngineConsolo/Program.cs | 54 ++++ UseEngineConsolo/Properties/AssemblyInfo.cs | 36 +++ UseEngineConsolo/UseEngineConsolo.csproj | 53 ++++ 11 files changed, 986 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 CoderEngine/AjaxCodeWrite.cs create mode 100644 CoderEngine/CoderEngine.csproj create mode 100644 CoderEngine/JavaCodeWrite.cs create mode 100644 CoderEngine/ModleReader.cs create mode 100644 CoderEngine/Properties/AssemblyInfo.cs create mode 100644 ServParam2ClientModelEngine.sln create mode 100644 UseEngineConsolo/Program.cs create mode 100644 UseEngineConsolo/Properties/AssemblyInfo.cs create mode 100644 UseEngineConsolo/UseEngineConsolo.csproj diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/CoderEngine/AjaxCodeWrite.cs b/CoderEngine/AjaxCodeWrite.cs new file mode 100644 index 0000000..705a3cf --- /dev/null +++ b/CoderEngine/AjaxCodeWrite.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CoderEngine +{ + public class AjaxCodeWrite + { + private string CodeStr = ""; + + /// + /// 一个代码缩进 + /// + private string tabstr = " "; + + /// + /// 逐行添加代码 + /// + /// + /// + public void CoderAddLine(string CodeLine) + { + CodeStr += CodeLine + "\n"; + } + + public string ModelToJavaCode(string _AssemblyName, string _TypeName) + { + TypeMode tm = new ModleReader().ModelCheck(_AssemblyName, _TypeName); + ModelToJavaCodeWriter(tm); + return CodeStr; + } + + public void ModelToJavaCodeWriter(TypeMode TopMode) + { + //如果有代码嵌套的下级类 在本类外 写入新的类 + if (TopMode.TypeList != null && TopMode.TypeList.Count > 0) + { + CoderAddLine(tabstr); + JsCodeDownRecursion(TopMode); + } + } + + + public void JsCodeDownRecursion(TypeMode TopMode) + { + string ClassName = ""; + //如果自己就是集合类型 则取类型下名字 + if (TopMode.MemberType.Name == "List`1") + { + //FullName的值为 "System.Collections.Generic.List`1[[ --集合内嵌类型名称--, CoderEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" + //其中包含内嵌List的名称 我们要将其取出 得到的值例如 “程序集.*.*类型” + var SonParamName = TopMode.MemberType.FullName.Substring(TopMode.MemberType.FullName.IndexOf("[") + 2); + SonParamName = SonParamName.Substring(0, SonParamName.IndexOf(",")); + ClassName = SonParamName.Substring(SonParamName.LastIndexOf(".")+1); + } + else + ClassName = TopMode.MemberType.Name; + + + CoderAddLine("public class " + ClassName + " {"); + foreach (var tl in TopMode.TypeList) + { + CoderAddLine(tabstr + "@SerializedName(value = \"" + tl.Name + "\")"); + CoderAddLine(tabstr + "public " + CSharpToJavaScriptTypeName(tl.MemberType) + " " + tl.Name + ";"); + } + + CoderAddLine("}"); + + + foreach (var tl in TopMode.TypeList) + { + if(tl.MemberType.Name == "List`1") + { + if (tl.TypeList != null && tl.TypeList.Count > 0) + { + CoderAddLine(""); + JsCodeDownRecursion(tl); + } + } + + } + + } + + /// + /// 转换成Java代码 + /// + /// + public string CSharpToJavaScriptTypeName(Type myType) + { + var oneinfo = CSharpToJavaScriptTypeItem.Where(w => w.Key == myType.Name).FirstOrDefault(); + if (oneinfo.Value != null) + { + return oneinfo.Value; + } + else + { + if(myType.Name == "List`1") + { + var SonParamName = myType.FullName.Substring(myType.FullName.IndexOf("[") + 2); + SonParamName = SonParamName.Substring(0, SonParamName.IndexOf(",")); + return "List<" + SonParamName.Substring(SonParamName.LastIndexOf('.')+1) + ">"; + } + else + return "string"; + } + } + + /// + /// C#和Java代码对照表 + /// + public System.Collections.Generic.Dictionary CSharpToJavaScriptTypeItem = + new Dictionary() { + { "int","int"}, + { "Int16","int"}, + { "Int32","int"}, + { "Int64","int"}, + { "int?","int"}, + { "long","long"}, + { "long?","long"}, + { "float","float"}, + { "float?","float"}, + { "double","double"}, + { "double?","double"}, + { "boolean","boolean"}, + { "string","string"}, + { "DateTime","DateTime"}, + { "DateTime?","DateTime"}, + }; + } +} diff --git a/CoderEngine/CoderEngine.csproj b/CoderEngine/CoderEngine.csproj new file mode 100644 index 0000000..2e6a385 --- /dev/null +++ b/CoderEngine/CoderEngine.csproj @@ -0,0 +1,48 @@ + + + + + Debug + AnyCPU + {B39AD89D-A3CF-4E36-B4D6-76C00BB492BF} + Library + Properties + CoderEngine + CoderEngine + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CoderEngine/JavaCodeWrite.cs b/CoderEngine/JavaCodeWrite.cs new file mode 100644 index 0000000..6b9d24e --- /dev/null +++ b/CoderEngine/JavaCodeWrite.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CoderEngine +{ + public class JavaCodeWrite + { + private string CodeStr = ""; + + /// + /// 一个代码缩进 + /// + private string tabstr = " "; + + /// + /// 逐行添加代码 + /// + /// + /// + public void CoderAddLine(string CodeLine) + { + CodeStr += CodeLine + "\n"; + } + + public string ModelToJavaCode(string _AssemblyName, string _TypeName) + { + TypeMode tm = new ModleReader().ModelCheck(_AssemblyName, _TypeName); + ModelToJavaCodeWriter(tm); + return CodeStr; + } + + public void ModelToJavaCodeWriter(TypeMode TopMode) + { + //如果有代码嵌套的下级类 在本类外 写入新的类 + if (TopMode.TypeList != null && TopMode.TypeList.Count > 0) + { + CoderAddLine(tabstr); + JavaCodeDownRecursion(TopMode); + } + } + + + public void JavaCodeDownRecursion(TypeMode TopMode) + { + string ClassName = ""; + //如果自己就是集合类型 则取类型下名字 + if (TopMode.MemberType.Name == "List`1") + { + //FullName的值为 "System.Collections.Generic.List`1[[ --集合内嵌类型名称--, CoderEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" + //其中包含内嵌List的名称 我们要将其取出 得到的值例如 “程序集.*.*类型” + var SonParamName = TopMode.MemberType.FullName.Substring(TopMode.MemberType.FullName.IndexOf("[") + 2); + SonParamName = SonParamName.Substring(0, SonParamName.IndexOf(",")); + ClassName = SonParamName.Substring(SonParamName.LastIndexOf(".")+1); + } + else + ClassName = TopMode.MemberType.Name; + + + 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("}"); + + + foreach (var tl in TopMode.TypeList) + { + if(tl.MemberType.Name == "List`1") + { + if (tl.TypeList != null && tl.TypeList.Count > 0) + { + CoderAddLine(""); + JavaCodeDownRecursion(tl); + } + } + + } + + } + + /// + /// 转换成Java代码 + /// + /// + public string CSharpToJavaTypeName(Type myType) + { + var oneinfo = CSharpToJavaTypeItem.Where(w => w.Key == myType.Name).FirstOrDefault(); + if (oneinfo.Value != null) + { + return oneinfo.Value; + } + else + { + if(myType.Name == "List`1") + { + var SonParamName = myType.FullName.Substring(myType.FullName.IndexOf("[") + 2); + SonParamName = SonParamName.Substring(0, SonParamName.IndexOf(",")); + return "List<" + SonParamName.Substring(SonParamName.LastIndexOf('.')+1) + ">"; + } + else + return "string"; + } + } + + /// + /// C#和Java代码对照表 + /// + public System.Collections.Generic.Dictionary CSharpToJavaTypeItem = + new Dictionary() { + { "int","int"}, + { "Int16","int"}, + { "Int32","int"}, + { "Int64","int"}, + { "int?","int"}, + { "long","long"}, + { "long?","long"}, + { "float","float"}, + { "float?","float"}, + { "double","double"}, + { "double?","double"}, + { "boolean","boolean"}, + { "string","string"}, + { "DateTime","DateTime"}, + { "DateTime?","DateTime"}, + }; + + + + + } +} diff --git a/CoderEngine/ModleReader.cs b/CoderEngine/ModleReader.cs new file mode 100644 index 0000000..9889d7a --- /dev/null +++ b/CoderEngine/ModleReader.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +//引用反射 +using System.Reflection; + +namespace CoderEngine +{ + + + + /// + /// 临时存储遍历出来的类型描述 + /// + public class TypeMode + { + /// + /// 字段名称 + /// + public Type MemberType { get; set; } + /// + /// 类型名称 + /// + public string Name { get; set; } + + /// + /// 是否有嵌套下级 + /// + public int IsHaveSou = 0; + /// + /// 嵌套类型 如果有包裹下级类型的话 则不为空 Null + /// + public List TypeList = null; + /// + /// 下级参数类型 + /// + public Type DownParamType { get; set; } + /// + /// 下级参数名称 + /// + public string DownParamName { get; set; } + } + /// + /// 模型读取 + /// + public class ModleReader + { + + public TypeMode TopType = new TypeMode(); + + + + /// + /// 检查程序及下的实体类 + /// + /// 程序集名称 + /// ModelClass类型名称 + /// + public TypeMode ModelCheck(string _AssemblyName, string _TypeName) + { + Console.WriteLine(""); + Console.WriteLine("====== C# 数据模型转Java实体类代码实现 ======"); + Console.WriteLine(""); + Console.WriteLine("读取程序集" + _AssemblyName + "下实体类" + _TypeName + ""); + + //取得类型 + Type PerentType = Assembly.Load(_AssemblyName).GetType(_AssemblyName + "." + _TypeName); + + if (PerentType == null) + { + Console.WriteLine("读取程序集或类不存在"); + } + + Console.WriteLine("已成功反射获取程序集"); + + TopType.MemberType = PerentType; + Console.WriteLine("对象类型:"+ TopType.MemberType); + TopType.Name = PerentType.Name; + Console.WriteLine("对象名称:" + TopType.Name); + //获取下级属性 + TopType.TypeList = ReadModel(PerentType); + //} + + return TopType; + } + + /// + /// 读取类型 + /// + /// + public List ReadModel(Type PerentType) + { + Console.WriteLine("对" + TopType.Name + "进行详细处理"); + //获取属性 + PropertyInfo[] Plist = PerentType.GetProperties(); + + List TypeList = new List(); + Console.WriteLine("遍历"+ TopType.Name + "属性: 属性数量为"+ Plist.Count()); + foreach (var m in Plist) + { + TypeMode TM = new TypeMode(); + TM.Name = m.Name; + Console.WriteLine("----" + TopType.Name + "下属性名:" + TM.Name); + TM.MemberType = m.PropertyType; + Console.WriteLine("----" + TopType.Name + "下属性" + TM.Name + " 类型为" + TM.MemberType.Name + "完整类型名" + TM.MemberType.Name); + //如果是List类型 则往下解析 + if (TM.MemberType.Name == "List`1") + { + + //注意:这里需要考虑排除无限极自我嵌套实体类型 否则出现死循环 + //暂未处理 + + + //TM.MemberType.Name的FullName的值为 "System.Collections.Generic.List`1[[ --集合内嵌类型名称--, CoderEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" + //其中包含内嵌List的名称 我们要将其取出 得到的值例如 “程序集.*.*类型” + var SonParamName = TM.MemberType.FullName.Substring(TM.MemberType.FullName.IndexOf("[") + 2); + SonParamName = SonParamName.Substring(0, SonParamName.IndexOf(",")); + //取出集合内子类型所属的程序集名字 + string SonParamFromAssemblyName = SonParamName.Substring(0,SonParamName.IndexOf('.')); + //反射载入子类型的类型 + Type SonType = Assembly.Load(SonParamFromAssemblyName).GetType(SonParamName); + + TM.IsHaveSou = 1; + TM.DownParamType = SonType; + TM.DownParamName = SonType.Name; + + Console.WriteLine("----对" + TopType.Name + "下属性" + TM.Name + " 嵌套泛型进行处理"); + TM.TypeList = ReadModel(SonType); + + + } + TypeList.Add(TM); + } + return TypeList; + } + + } +} diff --git a/CoderEngine/Properties/AssemblyInfo.cs b/CoderEngine/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0555cf8 --- /dev/null +++ b/CoderEngine/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("CoderEngine")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CoderEngine")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("b39ad89d-a3cf-4e36-b4d6-76c00bb492bf")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ServParam2ClientModelEngine.sln b/ServParam2ClientModelEngine.sln new file mode 100644 index 0000000..2269898 --- /dev/null +++ b/ServParam2ClientModelEngine.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoderEngine", "CoderEngine\CoderEngine.csproj", "{B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UseEngineConsolo", "UseEngineConsolo\UseEngineConsolo.csproj", "{F55B2D91-8D2D-4F14-A152-90C414BA52FC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}.Release|Any CPU.Build.0 = Release|Any CPU + {F55B2D91-8D2D-4F14-A152-90C414BA52FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F55B2D91-8D2D-4F14-A152-90C414BA52FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F55B2D91-8D2D-4F14-A152-90C414BA52FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F55B2D91-8D2D-4F14-A152-90C414BA52FC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/UseEngineConsolo/Program.cs b/UseEngineConsolo/Program.cs new file mode 100644 index 0000000..c95eb98 --- /dev/null +++ b/UseEngineConsolo/Program.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using CoderEngine; + +namespace UseEngineConsolo +{ + + + public class A + { + public int a { get; set; } + public int aa { get; set; } + public List Blist { get; set; } + } + + public class B + { + public string b { get; set; } + public List Clist { get; set; } + } + + public class C + { + public string string_b { get; set; } + } + + class Program + { + static void Main(string[] args) + { + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("=========================================="); + Console.WriteLine("====== 皓月跨语言实体类转换引擎 ======"); + Console.WriteLine("=========================================="); + Console.WriteLine(); + Console.WriteLine(); + + string JavaCode = new JavaCodeWrite().ModelToJavaCode("UseEngineConsolo", "A"); + + Console.WriteLine(); + Console.WriteLine("C#实体类动态转Java代码结果:"); + Console.WriteLine(); + + Console.WriteLine(JavaCode); + Console.ReadLine(); + } + } + + +} diff --git a/UseEngineConsolo/Properties/AssemblyInfo.cs b/UseEngineConsolo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5172f51 --- /dev/null +++ b/UseEngineConsolo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("UseEngineConsolo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UseEngineConsolo")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("f55b2d91-8d2d-4f14-a152-90c414ba52fc")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UseEngineConsolo/UseEngineConsolo.csproj b/UseEngineConsolo/UseEngineConsolo.csproj new file mode 100644 index 0000000..d7e0773 --- /dev/null +++ b/UseEngineConsolo/UseEngineConsolo.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {F55B2D91-8D2D-4F14-A152-90C414BA52FC} + Exe + UseEngineConsolo + UseEngineConsolo + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {b39ad89d-a3cf-4e36-b4d6-76c00bb492bf} + CoderEngine + + + + \ No newline at end of file