Lets look at an example of grid filling.
We have Column class. It has a delegate FormatCell, which take some Data and convert it to a string. FormatCell delegate is unknown at design time - it might be set by a plugin.
public class ColumnFormatter
{
public Func<Data, string> FormatCell {get; set;}
//...
}
Here is an example of how such Columns are used.
public class Table
{
public List<Column> Columns;
public List<List<string>> BuildTable(List<Data> dataRows)
{
var table = new List<List<string>>();
foreach (var data in dataRows)
{
var line = new List<string>();
foreach (var column in Columns)
{
line.Add(column.FormatCell(data));
}
table.Add(line);
}
return table;
}
}
Now each column should save its state. And the question is how to serialize this FormatCell delegate?
P.S. I'm aware of this question but my question is much more case specific. And maybe one has a specific reliable run-in solution for the such case?
No comments:
Post a Comment