private bool GenerateSourceFiles(string location) { bool success = true; location = Path.Combine(location, ProjectName); fileNames.Clear(); foreach (IEntity entity in model.Entities) { TypeBase type = entity as TypeBase; if (type != null && !type.IsTypeNested) { SourceFileGenerator sourceFile = CreateSourceFileGenerator(type); try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } } } return(success); }
private bool GenerateSourceFiles(string location, bool sort_using, bool generate_document_comment, string compagny_name, string copyright_header, string author) { bool success = true; location = Path.Combine(location, ProjectName); FileNames.Clear( ); foreach (IEntity entity in Model.Entities) { TypeBase type = entity as TypeBase; if ((type != null) && !type.IsNested) { SourceFileGenerator sourceFile = CreateSourceFileGenerator(type, sort_using, generate_document_comment, compagny_name, copyright_header, author); try { string fileName = sourceFile.Generate(location); FileNames.Add(fileName); } catch (FileGenerationException) { success = false; } } } return(success); }
/// <exception cref="ArgumentException"> /// <paramref name="location"/> contains invalid path characters. /// </exception> public GenerationResult Generate(string location) { GenerationResult result = solutionGenerator.Generate(location); SourceFileGenerator.FinishWork(); return(result); }
/// <exception cref="ArgumentException"> /// <paramref name="location"/> contains invalid path characters. /// </exception> public GenerationResult Generate(string location, bool sort_using, bool generate_document_comment, string compagny_name, string copyright_header, string author) { GenerationResult result = solutionGenerator.Generate(location, sort_using, generate_document_comment, compagny_name, copyright_header, author); SourceFileGenerator.FinishWork(); return(result); }
private bool GenerateSourceFiles(string location) { bool success = true; location = Path.Combine(location, ProjectName); fileNames.Clear(); foreach (IEntity entity in model.Entities) { TypeBase type = entity as TypeBase; if (type != null && !type.IsNested) { SourceFileGenerator sourceFile = null; if (model.Language == JavaLanguage.Instance) { sourceFile = new JavaSourceFileGenerator(type, RootNamespace); try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } } if (model.Language == CSharpLanguage.Instance) { if (Settings.Default.GenerateCodeFromTemplates) { CSharpTemplateSourceFileGenerator templatesSourceFiles = new CSharpTemplateSourceFileGenerator(type, RootNamespace, model); try { List <string> files = templatesSourceFiles.GenerateFiles(location, true); fileNames.AddRange(files); } catch (FileGenerationException) { success = false; } } if (!Settings.Default.GenerateNHibernateMapping) { sourceFile = new CSharpSourceFileGenerator(type, RootNamespace, model); try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } } else { if (Settings.Default.DefaultMapping == MappingType.NHibernateAttributes) { sourceFile = new CSharpNHibernateAttributesSourceFileGenerator(type, RootNamespace, model); try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } continue; } sourceFile = new CSharpSourceFileGenerator(type, RootNamespace, model); try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } if (type is ClassType) { if (Settings.Default.DefaultMapping == MappingType.NHibernateXml) { sourceFile = new CSharpNHibernateXmlSourceFileGenerator(type, RootNamespace, model); } else if (Settings.Default.DefaultMapping == MappingType.FluentNHibernate) { sourceFile = new CSharpFluentNHibernateSourceFileGenerator(type, RootNamespace, model); } else if (Settings.Default.DefaultMapping == MappingType.NHibernateByCode) { sourceFile = new CSharpNHibernateByCodeSourceFileGenerator(type, RootNamespace, model); } try { string fileName = sourceFile.Generate(location); fileNames.Add(fileName); } catch (FileGenerationException) { success = false; } } } } } } if (model.Language == CSharpLanguage.Instance) { if (Settings.Default.GenerateCodeFromTemplates) { CSharpTemplateSourceFileGenerator templatesSourceFiles = new CSharpTemplateSourceFileGenerator(RootNamespace, model); try { List <string> files = templatesSourceFiles.GenerateFiles(location, false); fileNames.AddRange(files); } catch (FileGenerationException) { success = false; } } if (Settings.Default.GenerateSQLCode) { SourceFileGenerator sqlSourceFile = new CSharpSQLSourceFileGenerator(RootNamespace, model); string fileName = sqlSourceFile.Generate(location); fileNames.Add(fileName); } } return(success); }