public void GenerateUsings(StringBuilder sb, ClassGenerationContext context) { foreach (String ns in context.namespacesToUse) { sb.AppendLine("using " + ns + ";"); } }
public String GenerateClassCode <T>(List <settingsPropertyEntry> properties, ClassGenerationContext context) where T : BuilderForCode, new() { T builder = new T(); ClassGenerationExtensions.GetUsingForTypes(properties.Select(x => x.type), context.namespacesToUse); ClassGenerationExtensions.GetUsingForFlags(context.propertyAppendFlags, true, context.namespacesToUse); context.namespacesToUse.RemoveDuplicates(); builder.AppendUsing(context.namespacesToUse); builder.OpenNamespace(context.namespaceName); builder.OpenClass(context.className, "public", context.classDescription); builder.AppendLine(); builder.OpenMethod(new CodeMethodBlockInfo() { methodAccess = "public", methodName = context.className, returnType = "", parameters = new List <KeyValuePair <Type, string> >(), methodDescription = "Default constructor" }); builder.CloseMethod(); builder.AppendLine(); foreach (var spe in properties) { builder.AppendLine(); builder.AppendProperty(spe, context.propertyAppendType, context.propertyAppendFlags); } builder.CloseClass(); builder.CloseNamespace(); return(builder.GetContent()); }
public static String GenerateClassForTable(this DataTable input, ClassGenerationContext context) { List <settingsPropertyEntry> properties = new List <settingsPropertyEntry>(); ClassGenerator generator = new ClassGenerator(); DataTable schemaTable = input.GetClonedShema <DataTable>(); foreach (DataColumn dc in schemaTable.Columns) { properties.Add(dc.GetSPE()); } String code = generator.GenerateClassCode <BuilderForCode>(properties, context); return(code); //settingsEntriesForObject seo = new settingsEntriesForObject() }