private IColumnHandler[] GetHandlersByColumnIndex(IReadOnlyList <string> columnNames, out List <string> columnNamesToOutput) { columnNamesToOutput = new List <string>(); IColumnHandler[] handlers = new IColumnHandler[columnNames.Count]; for (int i = 0; i < columnNames.Count; ++i) { string columnName = columnNames[i]; IColumnHandler handler; if (this.DropColumns.Contains(columnName)) { handler = null; } else { columnNamesToOutput.Add(columnName); if (!this.HandlersByColumn.TryGetValue(columnName, out handler)) { handler = new KeepColumnHandler(); } } handlers[i] = handler; } return(handlers); }
/// <summary> /// Translate a single literal value to the sanitized form, given the value /// and which column it is from. Uses the mapper configured for the column in /// the spec file. /// </summary> /// <param name="value">Value to convert</param> /// <param name="columnName">ColumnName value is from</param> /// <returns>Sanitized version of value</returns> public string Translate(string value, string columnName) { IColumnHandler handler; // If there's no handler, there's no re-mapping if (!this.HandlersByColumn.TryGetValue(columnName, out handler)) { handler = new KeepColumnHandler(); } // Convert and return the value String8 value8 = String8.Convert(value, new byte[String8.GetLength(value)]); String8 replacement = this.HandlersByColumn[columnName].Sanitize(value8); return(replacement.ToString()); }