private string get_entity(sytelinetableschema schema) { var cls = string.Format(@"public class {0} : Entity [ ",schema.name); schema.columns.ForEach(c => cls += " public virtual " + fix_type(c[1]) + " " + c[0] + "[ get;set; ] \r\n"); return cls + @" ] "; }
private string get_map(sytelinetableschema schema) { var cls = string.Format(@"public class {0}Map : ClassMap<{0}> [ public {0}Map() [ ", schema.name); cls += "Table(\"" + schema.name + "\");"; schema.columns.ForEach(c => cls += " Map(x => x." + c[0] + ");\r\n"); return cls + @" ] ] "; }
private string get_file_text(sytelinetableschema schema) { return get_header() + get_entity(schema) + get_map(schema) + get_footer(); }
private void save_file(sytelinetableschema schema) { var writer = File.CreateText(string.Format("{0}Map.cs", schema.name)); writer.Write(get_file_text(schema).Replace("[", "{").Replace("]", "}")); writer.Close(); }