예제 #1
0
        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
            });
        }
예제 #2
0
        public void Handle()
        {
            var path   = @"D:\work\BOA.BusinessModules\Dev\BOA.CardGeneral.DebitCard\BOA.CardGeneral.DebitCard.sln";
            var result = Handler.Handle(path);

            Assert.IsNull(result.ErrorMessage);


            var result2 = MessagingExporter.ExportAsTypeScriptCode(path);

            Assert.IsNull(result2.ErrorMessage);

            var data = new ExportAsCSharpCodeData
            {
                solutionFilePath       = path,
                RemoveUnusedProperties = true
            };

            result2 = MessagingExporter.ExportAsCSharpCode(data);
            Assert.IsNull(result2.ErrorMessage);
        }