public void RenderSearchFile(List <SearchModel> models) { if (!Directory.Exists(_outputPath + "Entity\\" + NormalizeTableName + "\\")) { Directory.CreateDirectory(_outputPath + "Entity\\" + NormalizeTableName + "\\"); } var searchTemplate = new ConditionTemplate(models, NormalizeTableName, _projectName); var output = searchTemplate.TransformText(); var outputPath = _outputPath + "Entity\\" + NormalizeTableName + "\\" + NormalizeTableName + "SearchConditon.cs"; File.WriteAllText(outputPath, output); }
public ConditionModel(string content) { if (string.IsNullOrEmpty(content)) { return; } Dictionary <ConditionType, string> conditionTypes = ConditionTemplate.GetConditionTypes(content); foreach (var condition in conditionTypes) { ConditionType type = condition.Key; string value = condition.Value; switch (type) { case ConditionType.ParkingFloor: { ParkingFloor = value; QueryType = TableType.ParkingLots; break; } case ConditionType.DiningBuilding: { DiningBuilding = value; QueryType = TableType.DiningHalls; break; } case ConditionType.DiningCapability: { DiningCapability = 60; QueryType = TableType.DiningHalls; break; } default: { break; } } } }
private (Paragraph, int) ProcessTemplate( ConditionTemplate template, ICollection <Paragraph> bodyParagraphs, Model context) { if (!(context.Find(template.Start.ModelDescription.Expression) is ConditionModel conditionModel)) { return(bodyParagraphs.ElementAt(template.End.Position.RowIndex), template.End.Position.TextIndex); } var startParagraph = bodyParagraphs.ElementAt(template.Start.Position.ParagraphIndex); startParagraph.ReplaceToken(template.Start, Model.Empty, _imageProcessor); var endParagraph = bodyParagraphs.ElementAt(template.End.Position.ParagraphIndex); var textEnd = endParagraph.ReplaceToken(template.End, Model.Empty, _imageProcessor); if (!conditionModel.IsFullfilled(template.Start.ModelDescription.Parameters)) { bodyParagraphs.RemoveTextBetween(template.Start.Position, template.End.Position); } return(endParagraph, textEnd); }