export-table-pulgin-csharp 1.0.33 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/ExportCSPlugin.d.ts +8 -0
  2. package/dist/ExportCSPlugin.d.ts.map +1 -0
  3. package/dist/ExportCSPlugin.js +319 -0
  4. package/dist/ExportUnityCSJsonPlugin.d.ts +9 -0
  5. package/dist/ExportUnityCSJsonPlugin.d.ts.map +1 -0
  6. package/dist/ExportUnityCSJsonPlugin.js +103 -0
  7. package/dist/index.d.ts +3 -8
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +5 -318
  10. package/package.json +1 -1
  11. package/src/ExportCSPlugin.ts +295 -0
  12. package/src/ExportUnityCSJsonPlugin.ts +92 -0
  13. package/src/index.ts +4 -295
  14. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/210/227/350/241/250.asset +15 -0
  15. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/210/227/350/241/250.cs +1 -1
  16. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/210/227/350/241/250Loader.cs +18 -0
  17. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/245/226/345/212/261.asset +15 -0
  18. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/245/226/345/212/261.cs +1 -1
  19. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/345/245/226/345/212/261Loader.cs +18 -0
  20. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/346/227/266/351/231/220.asset +15 -0
  21. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/346/227/266/351/231/220.cs +1 -1
  22. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/346/227/266/351/231/220Loader.cs +18 -0
  23. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/350/247/246/345/217/221/347/272/246/346/235/237/351/205/215/350/241/250.asset +15 -0
  24. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/350/247/246/345/217/221/347/272/246/346/235/237/351/205/215/350/241/250.cs +1 -1
  25. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-/344/273/273/345/212/241/350/247/246/345/217/221/347/272/246/346/235/237/351/205/215/350/241/250Loader.cs +18 -0
  26. package/test/dist/SceneConfig-SceneConfig.asset +15 -0
  27. package/test/dist/SceneConfig-SceneConfigLoader.cs +18 -0
  28. package/test/dist/SceneConfig-Sheet2.asset +15 -0
  29. package/test/dist/SceneConfig-Sheet2.cs +1 -1
  30. package/test/dist/SceneConfig-Sheet2Loader.cs +18 -0
  31. package/test/dist/SceneConfig.cs +1 -1
  32. package/test/dist//345/257/271/350/257/235/350/241/250-/345/257/271/350/257/235/350/241/250.asset +15 -0
  33. package/test/dist//345/257/271/350/257/235/350/241/250-/345/257/271/350/257/235/350/241/250.cs +1 -1
  34. package/test/dist//345/257/271/350/257/235/350/241/250-/345/257/271/350/257/235/350/241/250Loader.cs +18 -0
  35. package/test/dist//350/277/207/345/234/272/345/274/225/345/257/274-/350/277/207/345/234/272/345/274/225/345/257/274.asset +15 -0
  36. package/test/dist//350/277/207/345/234/272/345/274/225/345/257/274-/350/277/207/345/234/272/345/274/225/345/257/274.cs +364 -0
  37. package/test/dist//350/277/207/345/234/272/345/274/225/345/257/274-/350/277/207/345/234/272/345/274/225/345/257/274Loader.cs +18 -0
  38. package/test/src//350/277/207/345/234/272/345/274/225/345/257/274.xlsx +0 -0
  39. package/test/{test.bat → testCS.bat} +0 -0
  40. package/test/testUJson.bat +1 -0
  41. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-TaskConfig.cs +0 -135
  42. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-TaskRewards.cs +0 -68
  43. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-TaskTriggerConfig.cs +0 -145
  44. package/test/dist/EGBL/344/273/273/345/212/241/351/205/215/347/275/256-TimeLimit.cs +0 -55
package/dist/index.js CHANGED
@@ -1,322 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ExportPlugins = exports.ExportPlugin = exports.export_stuff = void 0;
27
- const export_table_lib_1 = require("export-table-lib");
28
- const fs = __importStar(require("fs-extra"));
29
- function export_stuff(paras) {
30
- let { datas, fields, inject, name, objects, packagename, tables, xxtea, } = paras;
31
- let firstLetterUpper = function (str) {
32
- return str.charAt(0).toUpperCase() + str.slice(1);
33
- };
34
- let firstLetterLower = function (str) {
35
- return str.charAt(0).toLowerCase() + str.slice(1);
36
- };
37
- let convMemberName = function (str) {
38
- return str.split("_").map(s => firstLetterUpper(s)).join("");
39
- };
40
- let convVarName = firstLetterLower;
41
- let RowClass = firstLetterUpper(name);
42
- let initFunc = name + "Init";
43
- let mapfield = fields.find(a => a.type == "key"); //如果是map,则生成对应的map
44
- let mapName = name + "Map";
45
- let getFieldType = function (f) {
46
- let t = f.type;
47
- if (t == "object") {
48
- throw new Error("invalid type <object>");
49
- }
50
- else if (t == "object[]") {
51
- throw new Error("invalid type <object[]>");
52
- }
53
- else if (t == "number") {
54
- return "double";
55
- }
56
- else if (t == "number[]") {
57
- return "double[]";
58
- }
59
- else if (t == "uid") {
60
- return "int";
61
- }
62
- else if (t == "bool") {
63
- return "bool";
64
- }
65
- else if (t == "bool[]") {
66
- return "bool[]";
67
- }
68
- else if (t == "string") {
69
- return "string";
70
- }
71
- else if (t == "string[]") {
72
- return "string[]";
73
- }
74
- else if (t == "fk") {
75
- return "int";
76
- }
77
- else if (t == "fk[]") {
78
- return "int[]";
79
- }
80
- else if (t == "any") {
81
- console.log(f);
82
- throw new Error(`invalid type ${f.name}:<any>`);
83
- }
84
- else if (t == "key") {
85
- return "string";
86
- }
87
- else {
88
- throw new Error(`invalid type ${f.name}:<unkown>`);
89
- }
90
- return t;
91
- };
92
- let getFkFieldType = function (field) {
93
- return tables.find(a => a.name == field.fkTableName).fields.find(a => a.name == field.fkFieldName).type;
94
- };
95
- const genValue = (value, f) => {
96
- let t = f.type;
97
- if (t == "object") {
98
- throw new Error("invalid type <object>");
99
- }
100
- else if (t == "object[]") {
101
- throw new Error("invalid type <object[]>");
102
- }
103
- else if (t == "number") {
104
- return `${value}`;
105
- }
106
- else if (t == "number[]") {
107
- let values = value;
108
- return `new double[]{${values.join(", ")}}`;
109
- }
110
- else if (t == "uid") {
111
- return `${value}`;
112
- }
113
- else if (t == "bool") {
114
- return `${value}`;
115
- }
116
- else if (t == "bool[]") {
117
- let values = value;
118
- return `new bool[]{${values.join(", ")}}`;
119
- }
120
- else if (t == "string") {
121
- // return `"${value}"`
122
- return JSON.stringify(value);
123
- }
124
- else if (t == "string[]") {
125
- let values = value;
126
- return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`;
127
- }
128
- else if (t == "fk") {
129
- return `${value}`;
130
- }
131
- else if (t == "fk[]") {
132
- let values = value;
133
- return `new int[]{${values.join(", ")}}`;
134
- }
135
- else if (t == "any") {
136
- console.log(f);
137
- throw new Error(`invalid type ${f.name}:<any>`);
138
- }
139
- else if (t == "key") {
140
- return `${value}`;
141
- }
142
- throw new Error(`invalid type ${f.name}:<unkown>`);
143
- };
144
- const getTitle = (v) => {
145
- return v.describe.split("\n")[0];
146
- };
147
- const getDescripts = (v) => {
148
- return v.describe.split("\n");
149
- };
150
- let temp = `
151
- using System.Collections.Generic;
152
- using System.Linq;
153
-
154
- namespace MEEC.ExportedConfigs{
155
- public class ${RowClass} {
156
-
157
- public static List<${RowClass}> Configs = new List<${RowClass}>()
158
- {
159
- ${(0, export_table_lib_1.foreach)(datas, data => ` new ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`)}
160
- };
161
-
162
- public ${RowClass}() { }
163
- public ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map(f => `${getFieldType(f)} ${convVarName(f.name)}`).join(", "))})
164
- {
165
- ${(0, export_table_lib_1.foreach)(fields, f => ` this.${convMemberName(f.name)} = ${convVarName(f.name)};`)}
166
- }
167
-
168
- public virtual ${RowClass} MergeFrom(${RowClass} source)
169
- {
170
- ${(0, export_table_lib_1.foreach)(fields, f => ` this.${convMemberName(f.name)} = source.${convMemberName(f.name)};`)}
171
- return this;
172
- }
173
-
174
- public virtual ${RowClass} Clone()
175
- {
176
- var config = new ${RowClass}();
177
- config.MergeFrom(this);
178
- return config;
179
- }
180
-
181
- ${(0, export_table_lib_1.cmm)( /**生成字段 */)}
182
- ${(0, export_table_lib_1.foreach)(fields, f => `
183
- /// <summary>
184
- ${(0, export_table_lib_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
185
- /// </summary>
186
- public ${getFieldType(f)} ${convMemberName(f.name)};`)}
187
-
188
- ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
189
- #region get字段
190
- ${(0, export_table_lib_1.foreach)(fields, f => {
191
- if (f.nameOrigin != f.name) {
192
- return ` public ${getFieldType(f)} ${getTitle(f).replace(" ", "_")} => ${convMemberName(f.name)};`;
193
- }
194
- else {
195
- return "";
196
- }
197
- })}
198
- #endregion
199
-
200
- #region uid map
201
- ${(0, export_table_lib_1.foreach)(fields, f => {
202
- if (f.isUnique) {
203
- return `
204
- protected static Dictionary<${getFieldType(f)}, ${RowClass}> _tempDictBy${convMemberName(f.name)};
205
- public static ${RowClass} GetConfigBy${convMemberName(f.name)}(${getFieldType(f)} ${convMemberName(f.name)})
206
- {
207
- if (_tempDictBy${convMemberName(f.name)} == null)
208
- {
209
- _tempDictBy${convMemberName(f.name)} = new Dictionary<${getFieldType(f)}, ${RowClass}>();
210
- Configs.ForEach(c =>
211
- {
212
- _tempDictBy${convMemberName(f.name)}.Add(c.${convMemberName(f.name)}, c);
213
- });
214
- }
215
- return _tempDictBy${convMemberName(f.name)}.GetValueOrDefault(${convMemberName(f.name)});
216
- }
217
- `;
218
- }
219
- else if (f.type == "number" || f.type == "string") {
220
- return `
221
- protected static Dictionary<${getFieldType(f)}, ${RowClass}[]> _tempRecordsDictBy${convMemberName(f.name)} = new Dictionary<${getFieldType(f)}, ${RowClass}[]>();
222
- public static ${RowClass}[] GetConfigsBy${convMemberName(f.name)}(${getFieldType(f)} ${convMemberName(f.name)})
223
- {
224
- if (_tempRecordsDictBy${convMemberName(f.name)}.ContainsKey(${convMemberName(f.name)}))
225
- {
226
- return _tempRecordsDictBy${convMemberName(f.name)}.GetValueOrDefault(${convMemberName(f.name)});
227
- }
228
- else
229
- {
230
- var records = Configs.Where(c => c.${convMemberName(f.name)} == ${convMemberName(f.name)}).ToArray();
231
- _tempRecordsDictBy${convMemberName(f.name)}.Add(${convMemberName(f.name)}, records);
232
- return records;
233
- }
234
- }
235
- `;
236
- }
237
- else {
238
- return "";
239
- }
240
- })}
241
-
242
- #endregion uid map
243
-
244
- #region 生成fk.get/set
245
- ${(0, export_table_lib_1.foreach)(fields, f => `
246
- ${(0, export_table_lib_1.iff)(f.type == "fk", () => `
247
- ${(0, export_table_lib_1.iff)(getFkFieldType(f).toLowerCase() != "uid", () => `
248
- protected ${convMemberName(f.fkTableName)}[] _fk${convMemberName(f.name)}=null;
249
- /**
250
- * ${f.describe}
251
- **/
252
- public virtual ${convMemberName(f.fkTableName)}[] ${convMemberName(f.name)}DataList{
253
- get{
254
- if(this._fk${convMemberName(f.name)}==null){
255
- if(null==this.${convMemberName(f.name)}){
256
- this._fk${convMemberName(f.name)} = new ${convMemberName(f.fkTableName)}[0];
257
- }else{
258
- this._fk${convMemberName(f.name)}=${convMemberName(f.fkTableName)}.FindAll(a=>a.${convMemberName(f.fkFieldName)}!=null && this.${convMemberName(f.name)}==a.${convMemberName(f.fkFieldName)}).ToArray();
259
- }
260
- }
261
- return this._fk${convMemberName(f.name)};
262
- }
263
- }
264
- `).else(() => `
265
- protected ${convMemberName(f.fkTableName)} _fk${convMemberName(f.name)}=null;
266
- /**
267
- * ${f.describe}
268
- **/
269
- public virtual ${convMemberName(f.fkTableName)} ${convMemberName(f.name)}Data{
270
- get{
271
- if(this._fk${convMemberName(f.name)}==null){
272
- this._fk${convMemberName(f.name)}=${convMemberName(f.fkTableName)}.Find(a=>a.${convMemberName(f.fkFieldName)}==this.${convMemberName(f.name)});
273
- }
274
- return this._fk${convMemberName(f.name)};
275
- }
276
- }
277
- `)}
278
- `)}
279
- ${(0, export_table_lib_1.iff)(f.type == "fk[]", () => `
280
- protected ${convMemberName(f.fkTableName)}[] _fk${convMemberName(f.name)}=null;
281
- /**
282
- * ${f.describe}
283
- **/
284
- public virtual ${convMemberName(f.fkTableName)}[] ${convMemberName(f.name)}DataList{
285
- get{
286
- if(this._fk${convMemberName(f.name)}==null){
287
- if(null==this.${convMemberName(f.name)}){
288
- this._fk${convMemberName(f.name)} = new ${convMemberName(f.fkTableName)}[0];
289
- }else{
290
- this._fk${convMemberName(f.name)}=MEEC.ExportedConfigs.${convMemberName(f.fkTableName)}.Configs.FindAll(a=>a.${convMemberName(f.fkFieldName)}!=null && this.${convMemberName(f.name)}!.Contains(a.${convMemberName(f.fkFieldName)})).ToArray();
291
- }
292
- }
293
- return this._fk${convMemberName(f.name)};
294
- }
295
- }
296
- `)}
297
- `)}
298
- #endregion 生成fk.get/set
299
- }
300
- }
301
- `;
302
- return temp;
303
- }
304
- exports.export_stuff = export_stuff;
305
- class ExportPlugin extends export_table_lib_1.PluginBase {
306
- constructor() {
307
- super(...arguments);
308
- this.name = "csharp";
309
- this.tags = ["cs"];
310
- }
311
- handleSheet(paras) {
312
- let content = export_stuff(paras);
313
- if (content != null) {
314
- fs.outputFileSync(paras.outFilePath.fullPath, content, "utf-8");
315
- }
316
- return content;
317
- }
318
- }
319
- exports.ExportPlugin = ExportPlugin;
3
+ exports.ExportPlugins = void 0;
4
+ const ExportCSPlugin_1 = require("./ExportCSPlugin");
5
+ const ExportUnityCSJsonPlugin_1 = require("./ExportUnityCSJsonPlugin");
320
6
  exports.ExportPlugins = [
321
- new ExportPlugin(),
7
+ new ExportCSPlugin_1.ExportPlugin(),
8
+ new ExportUnityCSJsonPlugin_1.ExportUJsonPlugin(),
322
9
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.0.33",
3
+ "version": "1.0.36",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,295 @@
1
+
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, iff } from "export-table-lib"
3
+ import * as fs from "fs-extra"
4
+
5
+ export function export_stuff(paras: HandleSheetParams): string | null {
6
+ let {
7
+ datas,
8
+ fields,
9
+ inject,
10
+ name,
11
+ objects,
12
+ packagename,
13
+ tables,
14
+ xxtea,
15
+ } = paras;
16
+
17
+ let firstLetterUpper = function (str: string) {
18
+ return str.charAt(0).toUpperCase() + str.slice(1);
19
+ };
20
+ let firstLetterLower = function (str: string) {
21
+ return str.charAt(0).toLowerCase() + str.slice(1);
22
+ };
23
+ let convMemberName = function (str: string) {
24
+ return str.split("_").map(s => firstLetterUpper(s)).join("")
25
+ }
26
+ let convVarName = firstLetterLower
27
+
28
+ let RowClass = firstLetterUpper(name)
29
+ let initFunc = name + "Init"
30
+ let mapfield = fields.find(a => a.type == "key")//如果是map,则生成对应的map
31
+ let mapName = name + "Map"
32
+
33
+ let getFieldType = function (f: Field) {
34
+ let t = f.type
35
+ if (t == "object") {
36
+ throw new Error("invalid type <object>")
37
+ } else if (t == "object[]") {
38
+ throw new Error("invalid type <object[]>")
39
+ } else if (t == "number") {
40
+ return "double";
41
+ } else if (t == "number[]") {
42
+ return "double[]";
43
+ } else if (t == "uid") {
44
+ return "int";
45
+ } else if (t == "bool") {
46
+ return "bool";
47
+ } else if (t == "bool[]") {
48
+ return "bool[]";
49
+ } else if (t == "string") {
50
+ return "string";
51
+ } else if (t == "string[]") {
52
+ return "string[]";
53
+ } else if (t == "fk") {
54
+ return "int";
55
+ } else if (t == "fk[]") {
56
+ return "int[]";
57
+ } else if (t == "any") {
58
+ console.log(f)
59
+ throw new Error(`invalid type ${f.name}:<any>`)
60
+ } else if (t == "key") {
61
+ return "string";
62
+ } else {
63
+ throw new Error(`invalid type ${f.name}:<unkown>`)
64
+ }
65
+ return t;
66
+ }
67
+
68
+ let getFkFieldType = function (field: Field) {
69
+ return tables.find(a => a.name == field.fkTableName)!.fields!.find(a => a.name == field.fkFieldName)!.type
70
+ }
71
+
72
+ const genValue = (value: any, f: Field): string => {
73
+ let t = f.type
74
+ if (t == "object") {
75
+ throw new Error("invalid type <object>")
76
+ } else if (t == "object[]") {
77
+ throw new Error("invalid type <object[]>")
78
+ } else if (t == "number") {
79
+ return `${value}`
80
+ } else if (t == "number[]") {
81
+ let values = value as number[]
82
+ return `new double[]{${values.join(", ")}}`
83
+ } else if (t == "uid") {
84
+ return `${value}`
85
+ } else if (t == "bool") {
86
+ return `${value}`
87
+ } else if (t == "bool[]") {
88
+ let values = value as boolean[]
89
+ return `new bool[]{${values.join(", ")}}`
90
+ } else if (t == "string") {
91
+ // return `"${value}"`
92
+ return JSON.stringify(value)
93
+ } else if (t == "string[]") {
94
+ let values = value as string[]
95
+ return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`
96
+ } else if (t == "fk") {
97
+ return `${value}`
98
+ } else if (t == "fk[]") {
99
+ let values = value as number[]
100
+ return `new int[]{${values.join(", ")}}`
101
+ } else if (t == "any") {
102
+ console.log(f)
103
+ throw new Error(`invalid type ${f.name}:<any>`)
104
+ } else if (t == "key") {
105
+ return `${value}`
106
+ }
107
+
108
+ throw new Error(`invalid type ${f.name}:<unkown>`)
109
+ }
110
+
111
+ const getTitle = (v: Field) => {
112
+ return v.describe.split("\n")[0]
113
+ }
114
+
115
+ const getDescripts = (v: Field) => {
116
+ return v.describe.split("\n")
117
+ }
118
+
119
+ let temp = `
120
+ using System.Collections.Generic;
121
+ using System.Linq;
122
+
123
+ namespace MEEC.ExportedConfigs{
124
+ public partial class ${RowClass} {
125
+
126
+ public static List<${RowClass}> Configs = new List<${RowClass}>()
127
+ {
128
+ ${foreach(datas, data =>
129
+ ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`
130
+ )}
131
+ };
132
+
133
+ public ${RowClass}() { }
134
+ public ${RowClass}(${st(() => fields.map(f => `${getFieldType(f)} ${convVarName(f.name)}`).join(", "))})
135
+ {
136
+ ${foreach(fields, f =>
137
+ ` this.${convMemberName(f.name)} = ${convVarName(f.name)};`
138
+ )}
139
+ }
140
+
141
+ public virtual ${RowClass} MergeFrom(${RowClass} source)
142
+ {
143
+ ${foreach(fields, f =>
144
+ ` this.${convMemberName(f.name)} = source.${convMemberName(f.name)};`
145
+ )}
146
+ return this;
147
+ }
148
+
149
+ public virtual ${RowClass} Clone()
150
+ {
151
+ var config = new ${RowClass}();
152
+ config.MergeFrom(this);
153
+ return config;
154
+ }
155
+
156
+ ${cmm(/**生成字段 */)}
157
+ ${foreach(fields, f => `
158
+ /// <summary>
159
+ ${foreach(getDescripts(f), line =>
160
+ ` /// ${line}`
161
+ )}
162
+ /// </summary>
163
+ public ${getFieldType(f)} ${convMemberName(f.name)};`
164
+ )}
165
+
166
+ ${cmm(/**生成get字段 */)}
167
+ #region get字段
168
+ ${foreach(fields, f => {
169
+ if (f.nameOrigin != f.name) {
170
+ return ` public ${getFieldType(f)} ${getTitle(f).replace(" ", "_")} => ${convMemberName(f.name)};`
171
+ } else {
172
+ return ""
173
+ }
174
+ }
175
+ )}
176
+ #endregion
177
+
178
+ #region uid map
179
+ ${foreach(fields, f => {
180
+ if (f.isUnique) {
181
+ return `
182
+ protected static Dictionary<${getFieldType(f)}, ${RowClass}> _tempDictBy${convMemberName(f.name)};
183
+ public static ${RowClass} GetConfigBy${convMemberName(f.name)}(${getFieldType(f)} ${convMemberName(f.name)})
184
+ {
185
+ if (_tempDictBy${convMemberName(f.name)} == null)
186
+ {
187
+ _tempDictBy${convMemberName(f.name)} = new Dictionary<${getFieldType(f)}, ${RowClass}>();
188
+ Configs.ForEach(c =>
189
+ {
190
+ _tempDictBy${convMemberName(f.name)}.Add(c.${convMemberName(f.name)}, c);
191
+ });
192
+ }
193
+ return _tempDictBy${convMemberName(f.name)}.GetValueOrDefault(${convMemberName(f.name)});
194
+ }
195
+ `
196
+ } else if (f.type == "number" || f.type == "string") {
197
+ return `
198
+ protected static Dictionary<${getFieldType(f)}, ${RowClass}[]> _tempRecordsDictBy${convMemberName(f.name)} = new Dictionary<${getFieldType(f)}, ${RowClass}[]>();
199
+ public static ${RowClass}[] GetConfigsBy${convMemberName(f.name)}(${getFieldType(f)} ${convMemberName(f.name)})
200
+ {
201
+ if (_tempRecordsDictBy${convMemberName(f.name)}.ContainsKey(${convMemberName(f.name)}))
202
+ {
203
+ return _tempRecordsDictBy${convMemberName(f.name)}.GetValueOrDefault(${convMemberName(f.name)});
204
+ }
205
+ else
206
+ {
207
+ var records = Configs.Where(c => c.${convMemberName(f.name)} == ${convMemberName(f.name)}).ToArray();
208
+ _tempRecordsDictBy${convMemberName(f.name)}.Add(${convMemberName(f.name)}, records);
209
+ return records;
210
+ }
211
+ }
212
+ `
213
+ } else {
214
+ return ""
215
+ }
216
+ }
217
+ )}
218
+
219
+ #endregion uid map
220
+
221
+ #region 生成fk.get/set
222
+ ${foreach(fields, f => `
223
+ ${iff(f.type == "fk", () => `
224
+ ${iff(getFkFieldType(f).toLowerCase() != "uid", () => `
225
+ protected ${convMemberName(f.fkTableName!)}[] _fk${convMemberName(f.name)}=null;
226
+ /**
227
+ * ${f.describe}
228
+ **/
229
+ public virtual ${convMemberName(f.fkTableName!)}[] ${convMemberName(f.name)}DataList{
230
+ get{
231
+ if(this._fk${convMemberName(f.name)}==null){
232
+ if(null==this.${convMemberName(f.name)}){
233
+ this._fk${convMemberName(f.name)} = new ${convMemberName(f.fkTableName!)}[0];
234
+ }else{
235
+ this._fk${convMemberName(f.name)}=${convMemberName(f.fkTableName!)}.FindAll(a=>a.${convMemberName(f.fkFieldName!)}!=null && this.${convMemberName(f.name)}==a.${convMemberName(f.fkFieldName!)}).ToArray();
236
+ }
237
+ }
238
+ return this._fk${convMemberName(f.name)};
239
+ }
240
+ }
241
+ `).else(() => `
242
+ protected ${convMemberName(f.fkTableName!)} _fk${convMemberName(f.name)}=null;
243
+ /**
244
+ * ${f.describe}
245
+ **/
246
+ public virtual ${convMemberName(f.fkTableName!)} ${convMemberName(f.name)}Data{
247
+ get{
248
+ if(this._fk${convMemberName(f.name)}==null){
249
+ this._fk${convMemberName(f.name)}=${convMemberName(f.fkTableName!)}.Find(a=>a.${convMemberName(f.fkFieldName!)}==this.${convMemberName(f.name)});
250
+ }
251
+ return this._fk${convMemberName(f.name)};
252
+ }
253
+ }
254
+ `)}
255
+ `)}
256
+ ${iff(f.type == "fk[]", () => `
257
+ protected ${convMemberName(f.fkTableName!)}[] _fk${convMemberName(f.name)}=null;
258
+ /**
259
+ * ${f.describe}
260
+ **/
261
+ public virtual ${convMemberName(f.fkTableName!)}[] ${convMemberName(f.name)}DataList{
262
+ get{
263
+ if(this._fk${convMemberName(f.name)}==null){
264
+ if(null==this.${convMemberName(f.name)}){
265
+ this._fk${convMemberName(f.name)} = new ${convMemberName(f.fkTableName!)}[0];
266
+ }else{
267
+ this._fk${convMemberName(f.name)}=MEEC.ExportedConfigs.${convMemberName(f.fkTableName!)}.Configs.FindAll(a=>a.${convMemberName(f.fkFieldName!)}!=null && this.${convMemberName(f.name)}!.Contains(a.${convMemberName(f.fkFieldName!)})).ToArray();
268
+ }
269
+ }
270
+ return this._fk${convMemberName(f.name)};
271
+ }
272
+ }
273
+ `)}
274
+ `)}
275
+ #endregion 生成fk.get/set
276
+ }
277
+ }
278
+ `
279
+
280
+ return temp
281
+
282
+ }
283
+
284
+ export class ExportPlugin extends PluginBase {
285
+ name = "csharp"
286
+ tags: string[] = ["cs"]
287
+
288
+ handleSheet(paras: HandleSheetParams) {
289
+ let content = export_stuff(paras)
290
+ if (content != null) {
291
+ fs.outputFileSync(paras.outFilePath.fullPath, content, "utf-8")
292
+ }
293
+ return content
294
+ }
295
+ }