private static void SerializeClass(CodeCompileUnit compileUnit, AS3CodeProvider provider) { var options = new CodeGeneratorOptions(); var FileName = ((ClassNameDef)compileUnit.UserData["NameDef"]).FileName; FileName = Path.Combine(OutputDirectory, FileName); StreamWriter writer = new StreamWriter(FileName, false); writer.WriteLine(header); options.IndentString = "\t"; options.VerbatimOrder = false; try { provider.GenerateCodeFromCompileUnit(compileUnit, writer, options); }finally { writer.Close(); } Console.WriteLine("Created file: " + FileName); }
static void Main(string[] args) { ImportLookup["Element"] = "randori.webkit.dom.Element"; ImportLookup["Document"] = "randori.webkit.dom.Document"; ImportLookup["XMLHttpRequest"] = "randori.webkit.xml.XMLHttpRequest"; ImportLookup["Vector.<Element>"] = "randori.webkit.dom.Element"; if (Directory.Exists(OutputDirectory) == false) { Directory.CreateDirectory(OutputDirectory); } else { var files = Directory.EnumerateFiles(OutputDirectory).ToList<string>(); files.ForEach(f => File.Delete(f)); } ReadSourceDirectory().ForEach(e => Entry2Class(e)); if (ClassLookup.ContainsKey("Promise")) { var classDefPromise = ClassLookup["Promise"]; var classDefDeferred = ClassLookup["Deferred"]; AddMethodsToPromise(classDefPromise, classDefDeferred); } foreach(var key in ClassLookup.Keys) { var Class = ClassLookup[key]; AddImports(Class, Builder.Class2Unit[key]); if (Class.Name == "JQueryStatic") { var method = Builder.AddMethod(Class, "J", "JQuery"); var parameter = Builder.AddParameter("list", "object[]", method, null, false); parameter.UserData["IsRestParams"] = true; Builder.AddMethodAttributeArgument(method, "name", ""); Class.Members.Cast<CodeTypeMember>().ToList<CodeTypeMember>().ForEach(m => m.Attributes = m.Attributes | MemberAttributes.Static); } } var provider = new AS3CodeProvider(Builder); foreach (var unit in Builder.Units) { SerializeClass(unit, provider); } Console.WriteLine("Finished, press any key..."); Console.ReadKey(); }
static void Main(string[] args) { ImportLookup["Element"] = "randori.webkit.dom.Element"; ImportLookup["Document"] = "randori.webkit.dom.Document"; ImportLookup["XMLHttpRequest"] = "randori.webkit.xml.XMLHttpRequest"; ImportLookup["Vector.<Element>"] = "randori.webkit.dom.Element"; if (Directory.Exists(OutputDirectory) == false) { Directory.CreateDirectory(OutputDirectory); } else { var files = Directory.EnumerateFiles(OutputDirectory).ToList<string>(); files.ForEach(f => File.Delete(f)); } ReadSourceDirectory().ForEach(e => Entry2Class(e)); foreach(var key in ClassLookup.Keys) { var Class = ClassLookup[key]; AddImports(Class, Builder.Class2Unit[key]); } var provider = new AS3CodeProvider(Builder); foreach (var unit in Builder.Units) { if (unit.Namespaces[0].Types[0].Members.Count > 0) { SerializeClass(unit, provider); } } Console.WriteLine("Finished, press any key..."); Console.ReadKey(); }
static void Main(string[] args) { InitializeUnknownTypes(UnknownTypes); if (Directory.Exists(OutputDirectory) == false) { Directory.CreateDirectory(OutputDirectory); } CleanOutputDirectry(); var files = Directory.EnumerateFiles(JSONDir).ToList<string>(); files.ForEach(f => ProcessJSONFile(f)); var provider = new AS3CodeProvider(Builder); Builder.Units.ForEach(c => WriteFile(c, provider)); Console.WriteLine("Finished, press any key to continue..."); Console.ReadKey(); }