/// <summary> /// Gets the information for display /// </summary> /// <param name="addLocationInfoToWarning">Add line number information if set true</param> /// <param name="addColumnInfoToWarning">Add column information if set true</param> /// <value>A nicely formatted representation of the information</value> public string Display(bool addLocationInfoToWarning, bool addColumnInfoToWarning) { var sb = new StringBuilder(); if (addLocationInfoToWarning) { if (LineNumberEnd > 0 || LineNumberStart > 0) { sb.Append("Line "); if (LineNumberStart > 0) { sb.Append(LineNumberStart); if (LineNumberStart < LineNumberEnd) { sb.Append(" - "); } } if (LineNumberStart < LineNumberEnd) { sb.Append(LineNumberEnd); } } } if (addColumnInfoToWarning && !string.IsNullOrEmpty(ColumnName)) { if (sb.Length > 0) { sb.Append(" "); } sb.Append("Column ["); if (ColumnName.Length > 40) { sb.Append(ColumnName.Substring(0, 39)); sb.Append("…"); } else { sb.Append(ColumnName); } sb.Append("]"); } if (sb.Length > 0) { sb.Append(": "); } sb.Append(Message); return(sb.ToString()); }
public string MappedName(bool camelCase = false) { var result = (OrdinalPosition == 1 && ColumnName.EndsWith("_ID") ? "Id" : (ColumnName.EndsWith("ID") ? string.Concat(ColumnName.Substring(0, ColumnName.Length - 2), "Id") : ColumnName)).Replace("_", string.Empty); if (camelCase) { return($"{result.Substring(0, 1).ToLower()}{result.Substring(1)}"); } return(result); }
public void BuildColumn() { ColumnName = ColumnNamePrefix; Header = ""; HideIfValueEquals = ConcatenatedColumns.Select(r => r.HideIfValueEquals).FirstOrDefault(); foreach (var column in ConcatenatedColumns) { ColumnName += column.ColumnName + СolumnNameSplitter; Header += column.Header + СolumnHeaderSplitter; if (string.IsNullOrEmpty(column.HideIfValueEquals) || HideIfValueEquals != column.HideIfValueEquals) { HideIfValueEquals = null; } } if (ColumnName.Length > 0) { ColumnName = ColumnName.Substring(0, ColumnName.Length - СolumnNameSplitter.Length); } if (Header.Length > 0) { Header = Header.Substring(0, Header.Length - СolumnHeaderSplitter.Length); } // TODO: Copy needed properties }