public void Run() { try { Console.WriteLine("Generating translators..."); LogManager.LogFactory = new ConsoleLogFactory(); var parser = new Parser(System.Environment.CommandLine, this); parser.Parse(); var modelAssembly = Assembly.LoadFile(ModelAssemblyPath); var modelAssemblyTypes = modelAssembly.GetTypes(); log.DebugFormat("Found {0} types in Assembly", modelAssemblyTypes.Count()); foreach (var type in modelAssemblyTypes) { var attrs = type.GetCustomAttributes(typeof(TranslateAttribute), false).ToList(); var extensionAttrs = type.GetCustomAttributes(typeof(TranslateExtensionAttribute), false).ToList(); if (attrs.Count == 0 && extensionAttrs.Count == 0) { continue; } var outPath = Path.Combine(this.OutputDir, type.Name + ".generated.cs"); if (!DoGenerateTranslator(outPath)) { continue; } if (attrs.Count > 0) { var attr = (TranslateAttribute)attrs[0]; var generator = new TranslatorClassGenerator(CodeLang.CSharp); generator.Write(attr, outPath); } if (extensionAttrs.Count > 0) { var generator = new ExtensionTranslatorClassGenerator(CodeLang.CSharp); generator.Write(type, this.OutputDir); } } } catch (Exception ex) { Console.Error.Write(ex.GetType() + ": " + ex.Message + "\n" + ex.StackTrace); throw; } }
public void Run() { try { Console.WriteLine("Generating translators..."); LogManager.LogFactory = new ConsoleLogFactory(); var parser = new Parser(System.Environment.CommandLine, this); parser.Parse(); var modelAssembly = Assembly.LoadFile(ModelAssemblyPath); var modelAssemblyTypes = modelAssembly.GetTypes(); log.DebugFormat("Found {0} types in Assembly", modelAssemblyTypes.Count()); foreach (var type in modelAssemblyTypes) { var attrs = type.GetCustomAttributes(typeof(TranslateAttribute), false).ToList(); var extensionAttrs = type.GetCustomAttributes(typeof(TranslateExtensionAttribute), false).ToList(); if (attrs.Count == 0 && extensionAttrs.Count == 0) continue; var outPath = Path.Combine(this.OutputDir, type.Name + ".generated.cs"); if (!DoGenerateTranslator(outPath)) continue; if (attrs.Count > 0) { var attr = (TranslateAttribute)attrs[0]; var generator = new TranslatorClassGenerator(CodeLang.CSharp); generator.Write(attr, outPath); } if (extensionAttrs.Count > 0) { var generator = new ExtensionTranslatorClassGenerator(CodeLang.CSharp); generator.Write(type, this.OutputDir); } } } catch (Exception ex) { Console.Error.Write(ex.GetType() + ": " + ex.Message + "\n" + ex.StackTrace); throw; } }