/// <summary> /// 生成扩展代码 /// </summary> protected override void CreateExCode(string path) { string file = Path.Combine(path, Entity.Name + ".cpp"); var code = new StringBuilder(); code.Append($@"#include <stdafx.h> #include ""{Entity.Name}.h"" {FriendInc(Entity)} using namespace std; using namespace Agebull::Tson; #pragma unmanaged "); using (var scope = CppNameSpaceScope.CreateScope(code, Project.NameSpace)) { scope.Append(Function()); scope.Append(SetValueFromDb()); //scope.Append(ClrHelper()); } code.Append(Friend(Entity)); //code.Append(Clr()); SaveCode(file, code.ToString()); }
/// <summary> /// 生成扩展代码 /// </summary> protected override void CreateExCode(string path) { if (Entity.IsReference || Entity.IsInternal) return; var code = new StringBuilder(); code.Append($@"#ifdef CLR #include <stdafx.h> #include ""{Entity.EntityName}_clr.h"" {FriendInc(Entity)} using namespace std; using namespace Agebull::Tson; #pragma managed /*-------------------------------CLR代码开始-----------------------------------*/ #include <msclr\marshal.h> using namespace System; using namespace msclr::interop; using namespace Runtime::InteropServices;"); code.Append(Clr()); using (var scope = CppNameSpaceScope.CreateScope(code, Project.NameSpace)) { scope.Append($@" #ifndef CLIENT {ClrHelper()} #endif"); } code.Append(@" #pragma unmanaged /*-------------------------------CLR代码结束-----------------------------------*/ #endif"); var file = Path.Combine(path, Entity.EntityName + "_clr.cpp"); SaveCode(file, code.ToString()); }
public static CppNameSpaceScope CreateScope(StringBuilder code, string nameSpace) { var scope = new CppNameSpaceScope { _coder = code, _namespace = nameSpace?.Split('.') }; scope.Begin(); return(scope); }
/// <summary> /// 生成实体代码 /// </summary> protected override void CreateBaCode(string path) { if (Entity.IsReference || Entity.IsInternal) { return; } var h = Project.NameSpace?.Replace('.', '_').ToUpper() ?? ""; var code = new StringBuilder(); code.Append($@"#pragma once #ifdef CLR #ifndef _{h}_{Entity.Name.ToUpper()}_CLR_H #define _{h}_{Entity.Name.ToUpper()}_CLR_H #pragma unmanaged #include <stdafx.h> #include ""{Entity.EntityName}.h"""); if (!Entity.IsClass) { code.Append(@" #include <DataModel/ModelBase.h> #include <NetCommand/command_def.h>"); } code.Append($@" {FriendInc(Entity)} using namespace std; using namespace Agebull::Tson; #pragma managed /*-------------------------------CLR代码开始-----------------------------------*/ #include <msclr\marshal.h> using namespace System; using namespace msclr::interop; using namespace Runtime::InteropServices; "); code.Append(ClrDef()); using (var scope = CppNameSpaceScope.CreateScope(code, Project.NameSpace)) { scope.Append($@" struct {Entity.Name}; #ifndef CLIENT {ClrHelperDef()} #endif"); } code.Append(@" #pragma unmanaged /*-------------------------------CLR代码结束-----------------------------------*/ #endif #endif"); SaveCode(Path.Combine(path, Entity.EntityName + "_clr.h"), code.ToString()); }
/// <summary> /// 生成实体代码 /// </summary> protected override void CreateBaCode(string path) { var h = Project.NameSpace?.Replace('.', '_').ToUpper() ?? ""; var code = new StringBuilder(); code.Append("#pragma once"); if (Entity.IsReference) { code.Append($@" #ifdef {Entity.Parent.Name}"); } code.Append($@" #ifndef _{h}_{Entity.Name.ToUpper()}_H #define _{h}_{Entity.Name.ToUpper()}_H #pragma unmanaged #include <stdafx.h>"); if (!Entity.IsReference && !Entity.NoDataBase) { code.Append(@" #include <DataModel/ModelBase.h> #include <NetCommand/command_def.h>"); } if (Entity.IsReference) { code.Append(@" #include ""Es/EsForeignApiStruct.h"" #include ""Es/TapQuoteAPIDataType.h"" using namespace ESForeign;"); } code.Append($@" {FriendInc(Entity)} using namespace std; using namespace Agebull::Tson; "); using (var scope = CppNameSpaceScope.CreateScope(code, Project.NameSpace)) { scope.Append(Index()); if (!Entity.IsReference) { scope.Append($@" struct {Entity.Name};"); } scope.Append(FunctionDef()); scope.Append(StructCode()); scope.Append(Operator()); //if (!Entity.IsInternal) // scope.Append(ClrHelperDef()); } if (Entity.IsReference) { code.Append(FriendDef(Entity)); } //if (!Entity.IsInternal) // code.Append(ClrDef()); code.Append(@" #endif"); if (Entity.IsReference) { code.Append(@" #endif"); } SaveCode(Path.Combine(path, Entity.Name + ".h"), code.ToString()); }