public void WriteJSON(ITextRender output, MetaEntityNamespaceCollection namespaces) { var instructions = ConvertToInstructions(namespaces); MetaPropertyInstruction rootInstruction = new MetaPropertyInstruction("", instructions); rootInstruction.WriteToOutput(output, true); }
public void CreateDataTableRow(DataTable output, MetaEntity entity, MetaEntityClassPropertyType typesToInclude = MetaEntityClassPropertyType.value | MetaEntityClassPropertyType.valueCollection) { var types = typesToInclude.getEnumListFromFlags <MetaEntityClassPropertyType>(); var dr = output.NewRow(); if (output.Columns.Contains(nameof(MetaEntity.name))) { dr[nameof(MetaEntity.name)] = entity.name; } if (output.Columns.Contains(nameof(MetaEntity.EntityClassName))) { dr[nameof(MetaEntity.EntityClassName)] = entity.EntityClassName; } foreach (var property in Properties) { if (types.Contains(property.type)) { String column_name = property.GetSelectExpression(); if (output.Columns.Contains(column_name)) { var setter = entity.Setters.FirstOrDefault(x => x.name.Equals(property.name)); if (setter != null) { if (property.type.HasFlag(MetaEntityClassPropertyType.collection)) { MetaPropertyInstruction instruction = new MetaPropertyInstruction(setter, property); dr[column_name] = instruction.value; } else { if (setter.Value != null) { dr[column_name] = setter.Value; } } } } } } output.Rows.Add(dr); }