Java代码转换实现

This commit is contained in:
皓月 2018-10-17 22:54:58 +08:00
parent 27137ecdc1
commit c729f2401f
11 changed files with 986 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -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

261
.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CoderEngine
{
public class AjaxCodeWrite
{
private string CodeStr = "";
/// <summary>
/// 一个代码缩进
/// </summary>
private string tabstr = " ";
/// <summary>
/// 逐行添加代码
/// </summary>
/// <param name="codeline"></param>
/// <returns></returns>
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);
}
}
}
}
/// <summary>
/// 转换成Java代码
/// </summary>
/// <returns></returns>
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";
}
}
/// <summary>
/// C#和Java代码对照表
/// </summary>
public System.Collections.Generic.Dictionary<string, string> CSharpToJavaScriptTypeItem =
new Dictionary<string, string>() {
{ "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"},
};
}
}

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B39AD89D-A3CF-4E36-B4D6-76C00BB492BF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CoderEngine</RootNamespace>
<AssemblyName>CoderEngine</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AjaxCodeWrite.cs" />
<Compile Include="JavaCodeWrite.cs" />
<Compile Include="ModleReader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CoderEngine
{
public class JavaCodeWrite
{
private string CodeStr = "";
/// <summary>
/// 一个代码缩进
/// </summary>
private string tabstr = " ";
/// <summary>
/// 逐行添加代码
/// </summary>
/// <param name="codeline"></param>
/// <returns></returns>
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);
}
}
}
}
/// <summary>
/// 转换成Java代码
/// </summary>
/// <returns></returns>
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";
}
}
/// <summary>
/// C#和Java代码对照表
/// </summary>
public System.Collections.Generic.Dictionary<string, string> CSharpToJavaTypeItem =
new Dictionary<string, string>() {
{ "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"},
};
}
}

139
CoderEngine/ModleReader.cs Normal file
View File

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//引用反射
using System.Reflection;
namespace CoderEngine
{
/// <summary>
/// 临时存储遍历出来的类型描述
/// </summary>
public class TypeMode
{
/// <summary>
/// 字段名称
/// </summary>
public Type MemberType { get; set; }
/// <summary>
/// 类型名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 是否有嵌套下级
/// </summary>
public int IsHaveSou = 0;
/// <summary>
/// 嵌套类型 如果有包裹下级类型的话 则不为空 Null
/// </summary>
public List<TypeMode> TypeList = null;
/// <summary>
/// 下级参数类型
/// </summary>
public Type DownParamType { get; set; }
/// <summary>
/// 下级参数名称
/// </summary>
public string DownParamName { get; set; }
}
/// <summary>
/// 模型读取
/// </summary>
public class ModleReader
{
public TypeMode TopType = new TypeMode();
/// <summary>
/// 检查程序及下的实体类
/// </summary>
/// <param name="_AssemblyName">程序集名称</param>
/// <param name="_TypeName">ModelClass类型名称</param>
/// <returns></returns>
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;
}
/// <summary>
/// 读取类型
/// </summary>
/// <param name="MethodItem"></param>
public List<TypeMode> ReadModel(Type PerentType)
{
Console.WriteLine("对" + TopType.Name + "进行详细处理");
//获取属性
PropertyInfo[] Plist = PerentType.GetProperties();
List<TypeMode> TypeList = new List<TypeMode>();
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<T>类型 则往下解析
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;
}
}
}

View File

@ -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")]

View File

@ -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

View File

@ -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<B> Blist { get; set; }
}
public class B
{
public string b { get; set; }
public List<C> 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();
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F55B2D91-8D2D-4F14-A152-90C414BA52FC}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>UseEngineConsolo</RootNamespace>
<AssemblyName>UseEngineConsolo</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CoderEngine\CoderEngine.csproj">
<Project>{b39ad89d-a3cf-4e36-b4d6-76c00bb492bf}</Project>
<Name>CoderEngine</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>