public static string[] GetHeaders <T>(this IChoCSVLiteWriter parser, T rec = default(T)) { if (typeof(IDictionary <string, object>).IsAssignableFrom(typeof(T)) && rec != null) { return(((IDictionary <string, object>)rec).Keys.ToArray()); } else { PropertyInfo[] props = GetPropertyInfos <T>(); return(props.Select(p => GetDisplayName(p, p.Name)).ToArray()); } }
public static void GetValues <T>(this IChoCSVLiteWriter parser, T rec, IList <string> cols) { if (rec is IDictionary <string, object> ) { foreach (var col in ((IDictionary <string, object>)rec).Values) { cols.Add(col.ToNString()); } } else { PropertyInfo[] props = GetPropertyInfos <T>(); foreach (var prop in props) { cols.Add(ChoType.GetPropertyValue(rec, prop).ToNString()); } } }