public TModel Parse <TModel>([NotNull] ITableParser tableParser, [NotNull] RenderingTemplate template, Action <string, string> addFieldMapping) where TModel : new() { var model = new TModel(); var enumerablesLengths = GetEnumerablesLengths <TModel>(tableParser, template); foreach (var row in template.Content.Cells) { foreach (var cell in row) { tableParser.PushState(cell.CellPosition); var expression = cell.StringValue; if (TemplateDescriptionHelper.IsCorrectValueDescription(expression)) { ParseCellularValue(tableParser, addFieldMapping, model, ExcelTemplatePath.FromRawExpression(expression), enumerablesLengths); continue; } if (TemplateDescriptionHelper.IsCorrectFormValueDescription(expression)) { ParseFormValue(tableParser, addFieldMapping, model, cell, ExcelTemplatePath.FromRawExpression(expression)); continue; } tableParser.PopState(); } } return(model); }
public void Render(ITableBuilder tableBuilder, object model, RenderingTemplate template) { var lastRow = template.Content.Cells.LastOrDefault(); foreach (var row in template.Content.Cells) { foreach (var cell in row) { tableBuilder.PushState(new Style(cell)); if (TemplateDescriptionHelper.IsCorrectFormValueDescription(cell.StringValue)) { RenderFormControl(tableBuilder, model, cell); } else { RenderCellularValue(tableBuilder, model, cell); } tableBuilder.PopState(); } if (!row.Equals(lastRow)) { tableBuilder.MoveToNextLayer(); } } MergeCells(tableBuilder, template); ResizeColumns(tableBuilder, template); }
public void TestIsCorrectFormValueDescriptionReturnsFalse(string description) { TemplateDescriptionHelper.IsCorrectFormValueDescription(description).Should().BeFalse(); }