public string GetMethods() { string entitiesText = ""; string dbSetsText = ""; List<Ac4yClass> connectionClasses = new List<Ac4yClass>(); string editedConnectionsText = ""; foreach(PlanObjectReference planObject in Parameter.PlanObjectReferenceList) { Ac4yClass ac4yClass = new Ac4yClassHandler().GetAc4yClassFromType(planObject.classType); foreach(Ac4yProperty property in ac4yClass.PropertyList) { if(property.NavigationProperty == true) { connectionClasses.Add(ac4yClass); break; } } } foreach(Ac4yClass ac4yClass in connectionClasses) { string connectionsText = ReadIntoString("Connections") .Replace(EntityMask, ac4yClass.Name) .Replace(PropertyManyMask, ac4yClass.Name.Replace("Ac4y", "") + "List") ; foreach (Ac4yProperty property in ac4yClass.PropertyList) { if (property.NavigationProperty == true) { connectionsText = connectionsText.Replace(EntityOneMask, property.Name) .Replace(ReferencePropertyMask, property.Name + "Id"); } } editedConnectionsText = editedConnectionsText + connectionsText; } foreach(PlanObjectReference planObject in Parameter.PlanObjectReferenceList) { entitiesText = entitiesText + EntitiesText.Replace(ClassCodeMask, planObject.className) + "\n"; } foreach (PlanObjectReference planObject in Parameter.PlanObjectReferenceList) { dbSetsText = dbSetsText + DbSetsText.Replace(ClassCodeMask, planObject.className) + "\n"; } return ReadIntoString("Methods") .Replace(EntitiesMask, entitiesText) .Replace(DbSetsMask, dbSetsText) .Replace(ConnectionsMask, editedConnectionsText) ; }
} // Program public void Run() { Ac4yClass ac4yClass = new Ac4yClassHandler().GetAc4yClassFromType(typeof(CSEFTPC4Core3Objects.Ac4yObjects.Ac4yPersistentChild)); new JSObjectServiceGenerator() { TemplatePath = Config[APPSETTINGS_TEMPLATEPATH] , TemplateSubPath = Config[APPSETTINGS_JAVASCRIPTOBJECTSERVICETEMPLATESUBPATH] , OutputPath = Config[APPSETTINGS_JAVASCRIPTOUTPUTPATH] } .Generate(ac4yClass); } // run
public string GetConnectedPropertyNames(PlanObjectReference planObject) { string result = ""; Ac4yClass ac4yClass = new Ac4yClassHandler().GetAc4yClassFromType(planObject.classType); foreach (Ac4yProperty property in ac4yClass.PropertyList) { if (property.Cardinality.Equals("COLLECTION")) { result = result + property.Name + ", "; } } return(result); }
private string GetTableItem() { string returnText = ""; Ac4yClassHandler ac4yClassHandler = new Ac4yClassHandler(); for (int i = 0; i < Type.PropertyList.Count; i++) { string text = ReadIntoString("tableItem"); if (Type.PropertyList[i].Name.Equals("Id") || GetConvertedType(Type.PropertyList[i].TypeName, FormaKonverziok)) { } else { text = text.Replace(InputFieldMask, GetInputField(Type.PropertyList[i].WidgetType)) .Replace(PropertyNameMask, Type.PropertyList[i].Name) ; if (Type.PropertyList[i].WidgetType.Equals("COMBOBOX")) { text = text.Replace(ComboboxEntityMask, Type.PropertyList[i].ComboboxEntityName); if (Type.PropertyList[i].NavigationId == true) { text = text.Replace(KeyMask, "Id"); } else { text = text.Replace(KeyMask, "Name"); } } ; returnText += text; } } return(returnText); }
public Dictionary <string, OpenApiSchema> SchemaFromObject() { Dictionary <string, OpenApiSchema> Lista = new Dictionary <string, OpenApiSchema>(); foreach (PlanObjectReference planObject in Parameter.PlanObjectReferenceList) { Ac4yClass ac4yClass = new Ac4yClassHandler().GetAc4yClassFromType(planObject.classType); Dictionary <string, OpenApiSchema> PropertyLista = new Dictionary <string, OpenApiSchema>(); Dictionary <string, OpenApiSchema> PropertyListaWithoutID = new Dictionary <string, OpenApiSchema>(); foreach (Ac4yProperty property in ac4yClass.PropertyList) { if (property.Cardinality.Equals("COLLECTION")) { PropertyLista.Add(property.Name, new OpenApiSchema() { Type = "array", Items = new OpenApiSchema() { Type = "object", Title = property.TypeName }, Nullable = true, Description = Ac4yClassHandler.GetAc4yDescription(property.PropertyInfo) }); } else if (property.NavigationProperty == true) { PropertyLista.Add(property.Name, new OpenApiSchema() { Type = "object", Description = Ac4yClassHandler.GetAc4yDescription(property.PropertyInfo), Title = property.Name, Nullable = true }); } else { PropertyLista.Add(property.Name, new OpenApiSchema() { Type = GetConvertedType(property.TypeName, TipusKonverziok), Format = GetConvertedType(property.TypeName, FormaKonverziok), Description = Ac4yClassHandler.GetAc4yDescription(property.PropertyInfo) }); if (!property.Name.Equals("Id")) { PropertyListaWithoutID.Add(property.Name, new OpenApiSchema() { Type = GetConvertedType(property.TypeName, TipusKonverziok), Format = GetConvertedType(property.TypeName, FormaKonverziok), Description = Ac4yClassHandler.GetAc4yDescription(property.PropertyInfo) }); } } } ; OpenApiSchema Schema = new OpenApiSchema() { Properties = PropertyLista }; OpenApiSchema SchemaWithoutID = new OpenApiSchema() { Properties = PropertyListaWithoutID }; Lista.Add(ac4yClass.Name, Schema); Lista.Add(ac4yClass.Name + "WithoutID", SchemaWithoutID); } return(Lista); }