示例#1
0
        private static bool DoCompile(string[] aArgs, String aDirectoryName, FileInfo[] aSourceFileList, ProgramArguments aArguments)
        {
            bool result = false;
            Console.WriteLine("Done");
            foreach (FileInfo sourceFile in aSourceFileList)
            {
                SourceCode sourceCode = new SourceCode(sourceFile, aArguments);
                if (!sourceCode.DoesHaveCode())
                    throw new ArgumentException(String.Format("There is no C# source code in the file: {0}", sourceFile.Name));

                if (File.Exists(sourceCode.GetJavaDestinationFullName()))
                    File.Delete(sourceCode.GetJavaDestinationFullName());

                Generator gen = new Generator(aDirectoryName, sourceCode, true);
                gen.Run();

                Console.WriteLine();
                if (gen.HasErrors())
                {
                    Console.WriteLine("\nPlease resolve the following errors first:\n ");

                    foreach (String error in gen.GetErrors())
                        Console.WriteLine("- {0}", error);

                    GeneralUtils.WriteErrorFile(aDirectoryName, gen.GetErrors());
                    Console.WriteLine();
                }
                else
                    result = true;
            }
            return result;
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("C# For Blackberry Version " + GeneralUtils.GetVersionNumber());
            Console.WriteLine("GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.html\n\n");
            bool debugMode = false; // TODO: Read this from application config

            try
            {
                if (!debugMode && args.Length == 0)
                    throw new ArgumentException("Pass the directory location to convert all C# files.");

                String directoryName = GetWorkDirectory(args, debugMode);
                FileInfo[] sourceFileList = GetSourceFiles(directoryName);

                ProgramArguments arguments = new ProgramArguments(args);

                bool compileSuccessful = false;
                CSharpCompile comp = new CSharpCompile(sourceFileList);
                if (comp.Run())
                    compileSuccessful = DoCompile(args, directoryName, sourceFileList, arguments);

                if (compileSuccessful)
                    new BlackberryCompile(directoryName, arguments).Run();

                if (debugMode)
                {
                    Console.WriteLine("In debugging mode, press any key to continue...");
                    Console.ReadLine();
                }
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (CompileErrorException ex)
            {
                Console.WriteLine("\nCompiler halt error, unable to continue because: \n");
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Compiler Error: {0}, {1}", ex.Message, ex.StackTrace);
            }
        }
示例#3
0
 /// <summary>
 /// Create a new source code from C# file
 /// </summary>
 /// <param name="aSourceFile"></param>
 public SourceCode(FileInfo aSourceFiles, ProgramArguments aArguments)
 {
     this.sourceFile = aSourceFiles;
     this.Arguments = aArguments;
     ReadSourceCode();
 }
 public BlackberryCompile(string directoryName, ProgramArguments aArguments)
 {
     this.directoryName = directoryName;
     this.arguments = aArguments;
 }