예제 #1
0
        public override bool Execute()
        {
            CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("en");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en");

            string javaOutputPath = "";

            try
            {
                var xmlConfig = new XmlDocument();
                xmlConfig.Load(ProjectDirectory + "\\" + configFileName);

                javaOutputPath = xmlConfig.GetElementsByTagName("JavaOutput").Item(0).InnerText;
            }
            catch (Exception)
            {
                Log.LogError("Invalid misharp_config");
                return(false);
            }

            try
            {
                var translatorTool = new TranslatorTool();
                translatorTool.Translate(ProjectDirectory, new List <string>(), javaOutputPath);
            }
            catch (Exception exception)
            {
                string file              = (string)exception.Data["file"];
                var    startLineNumber   = exception.Data["startLineNumber"];
                var    endLineNumber     = exception.Data["endLineNumber"];
                var    startColumnNumber = exception.Data["startColumnNumber"];
                var    endColumnNumber   = exception.Data["endColumnNumber"];

                int intStartLineNumber   = (int?)startLineNumber ?? 0;
                int intEndLineNumber     = (int?)endLineNumber ?? 0;
                int intStartColumnNumber = (int?)startColumnNumber ?? 0;
                int intEndColumnNumber   = (int?)endColumnNumber ?? 0;
                Log.LogError("",
                             "",
                             "",
                             file,
                             intStartLineNumber,
                             intStartColumnNumber,
                             intEndLineNumber,
                             intEndColumnNumber,
                             "Misharp translation error!!! " + exception.Message);
                return(false);
            }
            return(true);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var options = new Options();
            var succeed = CommandLine.Parser.Default.ParseArguments(args, options);

            if (succeed)
            {
                if (string.IsNullOrEmpty(options.SourcesPath))
                {
                    options.SourcesPath = Environment.CurrentDirectory;
                }
                if (options.AssembliesFiles == null)
                {
                    options.AssembliesFiles = new List <string>();
                }
                var translator = new TranslatorTool();
                translator.Translate(options.SourcesPath, options.AssembliesFiles, options.JavaOutputPath);
            }
            else
            {
                System.Console.WriteLine(options.GetUsage());
            }
        }