private void ExportMessageParser(string outputDir, MessageGroup encodeGroup, MessageGroup decodeGroup, StringContext context) { context.Add(CONTEXT_ENCODE_MESSAGE_GROUP_KEY, encodeGroup); context.Add(CONTEXT_DECODE_MESSAGE_GROUP_KEY, decodeGroup); string outputFilePath = $"{outputDir}/{context.Get<string>(CONTEXT_PLATFORM_KEY)}MessageParser{GetExtension()}"; string outputContent = TemplateEngine.Execute(context, exportData.parserTemplateContent, new string[] { typeof(MessageConfig).Assembly.Location }); if (!string.IsNullOrEmpty(outputContent)) { File.WriteAllText(outputFilePath, outputContent); } context.Remove(CONTEXT_ENCODE_MESSAGE_GROUP_KEY); context.Remove(CONTEXT_DECODE_MESSAGE_GROUP_KEY); }
private void ExportMessageParser(string outputDir) { StringContext context = new StringContext(); context.Add(CONTEXT_SPACE_KEY, exportData.messageConfig.Space); if (exportData.platformType == OutputPlatformType.All || exportData.platformType == OutputPlatformType.Client) { context.Add(CONTEXT_PLATFORM_KEY, "Client"); ExportMessageParser(outputDir, exportData.messageConfig.C2SGroup, exportData.messageConfig.S2CGroup, context); context.Remove(CONTEXT_PLATFORM_KEY); } if (exportData.platformType == OutputPlatformType.All || exportData.platformType == OutputPlatformType.Server) { context.Add(CONTEXT_PLATFORM_KEY, "Server"); ExportMessageParser(outputDir, exportData.messageConfig.S2CGroup, exportData.messageConfig.C2SGroup, context); context.Remove(CONTEXT_PLATFORM_KEY); } context.Clear(); }
private void ExportMessageID(string outputDir, MessageGroup group, StringContext context) { context.Add(CONTEXT_MESSAGE_GROUP_KEY, group); string outputFilePath = $"{outputDir}/{group.Name}_ID{GetExtension()}"; string outputContent = TemplateEngine.Execute(context, exportData.idTemplateContent, new string[] { typeof(MessageGroup).Assembly.Location }); if (!string.IsNullOrEmpty(outputContent)) { File.WriteAllText(outputFilePath, outputContent); } context.Remove(CONTEXT_MESSAGE_GROUP_KEY); }