public void CreateDataclass(ModelInfo database, EntityInfo table, TsmDossier dossier, Pallet pallet) { CodeWriter cw = new CodeWriter(); CreateDataclass(cw, table, dossier); pallet.AddProduct($"{table.Name}", "Model", $@"{table.Name}.cs", cw); }
//private void CreateEnumerationPerEntity(ModelInfo enumeration, TsmDossier dossier, Pallet pallet) //{ // TsmEntityMold tableMold = new TsmEntityMold(); // foreach (EntityInfo table in enumeration.Entities) // { // tableMold.CreateDataclass(enumeration, table, dossier, pallet); // } //} private void CreateEnumerations(EnumerationInfo enumeration, TsmDossier dossier, Pallet pallet) { CodeWriter cw = new CodeWriter(); cw.WriteLine($"export enum {enumeration.Name}"); cw.Open(); bool first = true; foreach (ValueInfo info in enumeration.Values) { if (first) { first = false; } else { cw.WriteLine(","); } cw.LineStart(); cw.Write(info.Name); } cw.WriteLine(); cw.Close(); pallet.AddProduct("TsmEnumerations", "Models", @"Enumerations.ts", cw); }
private void CreateDataclassPerEntity(ModelInfo database, TsmDossier dossier, Pallet pallet) { TsmEntityMold tableMold = new TsmEntityMold(); foreach (EntityInfo table in database.Entities) { tableMold.CreateDataclass(database, table, dossier, pallet); } }
public void Manufacture(TsmDossier dossier) { foreach (EnumerationInfo enumeration in dossier.Info.Enumerations) { Pallet pallet = new Pallet(); CreateEnumerations(enumeration, dossier, pallet); // create dataclass per table //CreateDataclassPerEntity(enumeration, dossier, pallet); dossier.Pallets.Add(pallet); } }
public void Manufacture(TsmDossier dossier) { foreach (ModelInfo database in dossier.Info.Models) { Pallet pallet = new Pallet(); // create databasecontext CreateModels(database, dossier, pallet); // create dataclass per table //CreateDataclassPerEntity(database, dossier, pallet); dossier.Pallets.Add(pallet); } }
private void CreateModels(ModelInfo database, TsmDossier dossier, Pallet pallet) { CodeWriter cw = new CodeWriter(); cw.WriteLine($@"import {{ JsonObject, JsonProperty }} from ""json2typescript"";"); cw.WriteLine($@"import * as enumerations from ""./Enumerations"";"); TsmEntityMold tableMold = new TsmEntityMold(); foreach (EntityInfo table in database.Entities.OrderByDescending(e => e.Order).ThenBy(e => e.Name)) { tableMold.CreateDataclass(cw, database, table, dossier, pallet); } pallet.AddProduct("TsmModel", "Models", $@"Models.ts", cw); }
private void CreateDataclass(CodeWriter cw, EntityInfo table, TsmDossier dossier) { cw.Empty(); if (table.ParentEntityInfo != null) { cw.WriteLine($"export class {table.Name} extends {table.ParentEntityInfo.Name}"); } else { cw.WriteLine($"export class {table.Name}"); } cw.Open(); bool first = true; foreach (IAttributeInfo fieldInfo in table.Attributes) { if (first) { first = false; } else { cw.Empty(); } ITsmAttributeMold fieldMold = AttributeMolds.Create(fieldInfo); if (fieldMold == null) { dossier.AddError("Mold not found.", fieldInfo); } else { fieldMold.CreateDataclass(fieldInfo, cw); } } cw.Close(); }
public void CreateDataclass(CodeWriter cw, ModelInfo database, EntityInfo table, TsmDossier dossier, Pallet pallet) { CreateDataclass(cw, table, dossier); }