private string GenerateTables(CodeDomProvider codeDomProvider, CodeGeneratorOptions options, CodeGenerationInfo generationInfo) { StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) { var codeGenerator = codeDomProvider.CreateGenerator(sw); CodeCompileUnit compileUnit = new CodeCompileUnit(); //compileUnit.AddCustomInclude("reader/include/crema/inidata"); compileUnit.AddInclude("crema/inidata"); compileUnit.AddCustomInclude("crema_datatypes"); //compileUnit.AddCustomInclude("crema_base"); CodeNamespace codeNamespace = new CodeNamespace(generationInfo.Namespace); codeNamespace.Imports.Add(new CodeNamespaceImport(generationInfo.ReaderNamespace)); foreach (var item in generationInfo.GetTables()) { H3RowClassCreator.Create(codeNamespace, item, generationInfo); } compileUnit.Namespaces.Add(codeNamespace); codeGenerator.GenerateCodeFromCompileUnit(compileUnit, sw, options); } return(sb.ToString()); }
public static void CreateTables(CodeNamespace codeNamespace, CodeGenerationInfo generationInfo) { foreach (var item in generationInfo.GetTables()) { CreateTable(codeNamespace, item, generationInfo); } CreateDataSet(codeNamespace, generationInfo); }
public static void CreateDataSet(CodeNamespace codeNamespace, CodeGenerationInfo generationInfo) { var classType = new CodeTypeDeclaration(); codeNamespace.Types.Add(classType); classType.Attributes = MemberAttributes.Private; classType.Name = generationInfo.ClassName; classType.IsClass = true; classType.TypeAttributes |= System.Reflection.TypeAttributes.Sealed; classType.BaseTypes.Add("CremaData"); CreateDataSetNameField(classType); CreateDataSetRevisionField(classType); CreateDataSetFields(classType, generationInfo.GetTables(true)); CreateDataSetMethodCreateFromFile(classType, generationInfo); //CreateDataSetMethodCreateFromDataSet(classType, generationInfo); CreateDataSetMethodReadFromFile(classType, generationInfo); }