public static MessagingExporterResult ExportAsTypeScriptCode(string solutionFilePath, IDictionary <string, string> usedPropertyNames = null) { var directory = Path.GetDirectoryName(solutionFilePath); if (directory == null) { return(new MessagingExporterResult { ErrorMessage = "directory is null.@solutionFilePath:" + solutionFilePath }); } var messageFileName = "Message.tsx"; var messageFilePath = Directory.GetFiles(directory, "*.tsx", SearchOption.AllDirectories).LastOrDefault(f => f.EndsWith(messageFileName)); if (messageFilePath == null) { return(new MessagingExporterResult { ErrorMessage = $"messageFilePath not found.You must specify named file like:{messageFileName}" }); } var firstLine = File.ReadAllLines(messageFilePath).FirstOrDefault(line => string.IsNullOrWhiteSpace(line) == false); var config = MessagingExporterInputLineParser.Parse(firstLine); return(new MessagingExporterResult { GeneratedCode = ExportGroupAsTypeScriptCode(config.GroupName, usedPropertyNames), TargetFilePath = messageFilePath }); }
public static MessagingExporterResult ExportAsCSharpCode(ExportAsCSharpCodeData data) { var solutionFilePath = data.solutionFilePath; var directory = Path.GetDirectoryName(solutionFilePath); if (directory == null) { return(new MessagingExporterResult { ErrorMessage = "directory is null.@solutionFilePath:" + solutionFilePath }); } var messageFileName = "Message.designer.cs"; var messageFilePath = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories).LastOrDefault(f => f.EndsWith(messageFileName)); if (messageFilePath == null) { return(new MessagingExporterResult { ErrorMessage = $"messageFilePath not found.You must specify named file like:{messageFileName}" }); } if (data.RemoveUnusedProperties) { data.usedPropertyNames = new Dictionary <string, string>(); BOAPlugins.RemoveUnusedMessagesInTypescriptCodes.Handler.HandleForCs(directory, data.usedPropertyNames, messageFilePath); } var firstLine = File.ReadAllLines(messageFilePath).FirstOrDefault(line => string.IsNullOrWhiteSpace(line) == false); var config = MessagingExporterInputLineParser.Parse(firstLine); return(new MessagingExporterResult { GeneratedCode = ExportAsCSharpCode(config.GroupName, config.NamespaceName, data.usedPropertyNames), TargetFilePath = messageFilePath }); }