Ods: Fix small issues
This commit is contained in:
@ -10,18 +10,14 @@ namespace Elwig.Models.Dtos {
|
||||
public string FullName { get; set; }
|
||||
public IEnumerable<T> Rows { get; private set; }
|
||||
public int RowNum => Rows.Count();
|
||||
public int ColNum => ColumnNames.Count();
|
||||
|
||||
public IEnumerable<(string, Type?)> ColumnDefs => _map.Select(m => (m.Item1, m.Item2?.PropertyType ?? m.Item3?.FieldType));
|
||||
public IEnumerable<string> ColumnNames => ColumnDefs.Select(m => m.Item1);
|
||||
public IEnumerable<Type?> ColumnTypes => ColumnDefs.Select(m => m.Item2);
|
||||
public IEnumerable<(string, int)> ColumnSpans => ColumnDefs.Select(c => {
|
||||
var type = c.Item2;
|
||||
var elType = type?.GetElementType();
|
||||
return (c.Item1,
|
||||
type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Length :
|
||||
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Length : 1
|
||||
);
|
||||
}).ToList();
|
||||
public int ColNum => ColumnNames.Count();
|
||||
public IEnumerable<Type?> ColumnFlatTypes { get; private set; }
|
||||
public IEnumerable<int> ColumnSpans { get; private set; }
|
||||
|
||||
private readonly PropertyInfo[] _properties;
|
||||
private readonly FieldInfo[] _fields;
|
||||
private readonly (string, PropertyInfo?, FieldInfo?)[] _map;
|
||||
@ -34,6 +30,17 @@ namespace Elwig.Models.Dtos {
|
||||
Name = name;
|
||||
FullName = fullName;
|
||||
Rows = rows;
|
||||
ColumnFlatTypes = ColumnTypes.SelectMany(type => {
|
||||
var elType = type?.GetElementType();
|
||||
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Select(f => f.FieldType) :
|
||||
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Select(f => f.FieldType) :
|
||||
new Type?[] { type };
|
||||
}).ToList();
|
||||
ColumnSpans = ColumnTypes.Select(type => {
|
||||
var elType = type?.GetElementType();
|
||||
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Length :
|
||||
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Length : 1;
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string, string)>? colNames = null) :
|
||||
|
Reference in New Issue
Block a user