Beispiel #1
0
 public override void SetDocumentClass(string path, bool isMain)
 {
     CompileTargets.Clear();
     if (isMain)
     {
         SetCompileTarget(path, true);
     }
 }
Beispiel #2
0
        public static ICompiler GetCompiler(CompileTargets target)
        {
            ICompiler compiler;
            if (!_compilers.TryGetValue(target, out compiler))
            {
                switch (target)
                {
                    case CompileTargets.Java: compiler = new JavaCompiler(); break;
                    default: throw new NotImplementedException();
                }

                _compilers[target] = compiler;
            }

            return compiler;
        }
Beispiel #3
0
        public void Compile(string fileName, CompileTargets target)
        {
            string source = _canvasController.GetCanvasXml();
            XmlDocument document = new XmlDocument();

            document.LoadXml(source);

            ICompiler compiler = CompilerFactory.GetCompiler(target);
            string className = Path.GetFileNameWithoutExtension(fileName);
            string javaSource = compiler.Compile(document, className);

            using (FileStream fs = File.Open(fileName, FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(fs, Encoding.ASCII))
                {
                    writer.Write(javaSource);
                }
            }
        }