//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 IEnumerable <RelationalModelChange> AddEnumeration(TableInfo table, EnumerationInfo item) { // check enum options to determine if this item should be considered if (_enumOption == EnumOptions.All || (_enumOption == EnumOptions.Hard && item.IsHard)) { return(CollectionUtils.Map <EnumerationMemberInfo, RelationalModelChange>( item.Members, member => new AddEnumValueChange(table, member))); } // nothing to do return(new RelationalModelChange[] { }); }
public override void SetRef(ApplicationInfo applicationInfo, ModelInfo databaseInfo, EntityInfo table) { EnumerationInfo = applicationInfo.Enumerations.GetByName(EnumerationName); }
private IEnumerable <RelationalModelChange> CompareEnumerations(TableInfo table, EnumerationInfo initial, EnumerationInfo desired) { // note: for soft enumerations, we don't do any updates, because they may have been customized already // hence only hard enums should ever be compared (need to ensure what is in the database matches the C# enum definition) if (_enumOption != EnumOptions.None && desired.IsHard) { return(CompareSets(initial.Members, desired.Members, item => AddEnumerationValue(table, item), item => DropEnumerationValue(table, item), (x, y) => CompareEnumerationValues(table, x, y))); } // nothing to do return(new RelationalModelChange[] { }); }
private static IEnumerable <RelationalModelChange> DropEnumeration(TableInfo table, EnumerationInfo item) { // nothing to do - the table will be dropped return(new RelationalModelChange[] { }); }