public virtual string GetText(ColumnRole role, ColumnType type, Tolerance tolerance, Rounding rounding) { var roleText = GetRoleText(role); var typeText = GetTypeText(type); var toleranceText = GetToleranceText(tolerance); var roundingText = GetRoundingText(rounding); var value = string.Format("{0} ({1}){2}{3}{4}", roleText, typeText, (toleranceText + roundingText).Length > 0 ? " " : "", toleranceText, roundingText); return value; }
private string GetRoleText(ColumnRole role) { switch (role) { case ColumnRole.Key: return "KEY"; case ColumnRole.Value: return "VALUE"; default: return string.Empty; } }
/// <summary> /// Returns whether there are two or more columns of the given role. /// </summary> public bool HasMultiple(ColumnRole role) => _map.TryGetValue(role.Value, out var cols) && cols.Count > 1;
/// <summary> /// If there are columns of the given role, this returns the infos as a readonly list. Otherwise, /// it returns null. /// </summary> public IReadOnlyList <ColumnInfo> GetColumns(ColumnRole role) => _map.TryGetValue(role.Value, out var list) ? list : null;
/// <summary> /// Returns whether there are any columns with the given column role. /// </summary> public bool Has(ColumnRole role) => _map.ContainsKey(role.Value);
/// <summary> /// Returns whether there is exactly one column of the given role. /// </summary> public bool HasUnique(ColumnRole role) => _map.TryGetValue(role.Value, out var cols) && cols.Count == 1;
private static KeyValuePair <ColumnRole, T> Pair <T>(ColumnRole kind, T value) { return(new KeyValuePair <ColumnRole, T>(kind, value)); }
public static KeyValuePair <ColumnRole, string> CreatePair(ColumnRole role, string name) => new KeyValuePair <ColumnRole, string>(role, name);
/// <summary> /// Returns whether there are any columns with the given column role. /// </summary> public bool Has(ColumnRole role) { return(role.Value != null && _map.ContainsKey(role.Value)); }
/// <summary> /// Returns whether there are two or more columns of the given role. /// </summary> public bool HasMultiple(ColumnRole role) { IReadOnlyList <ColumnInfo> cols; return(role.Value != null && _map.TryGetValue(role.Value, out cols) && cols.Count > 1); }
public static KeyValuePair <ColumnRole, string> CreatePair(ColumnRole role, string name) { return(new KeyValuePair <ColumnRole, string>(role, name)); }
/// <summary> /// Determines whether the given value is valid as a <see cref="ColumnRole"/>. /// </summary> /// <param name="self"> /// The value to check. /// </param> /// <returns> /// <c>true</c> if the given <see cref="ColumnRole"/> is valid; /// <c>false</c> otherwise. /// </returns> public static bool IsValidColumnRole(this ColumnRole self) { return(Enum.IsDefined(typeof(ColumnRole), self) && self != ColumnRole.CountColumnMetadata); }
/// <summary> /// If there are columns of the given role, this returns the infos as a readonly list. Otherwise, /// it returns null. /// </summary> public IReadOnlyList <DataViewSchema.Column> GetColumns(ColumnRole role) => _map.TryGetValue(role.Value, out var list) ? list : null;
private static void Add(Dictionary <string, List <DataViewSchema.Column> > map, ColumnRole role, DataViewSchema.Column column) { Contracts.AssertValue(map); Contracts.AssertNonEmpty(role.Value); if (!map.TryGetValue(role.Value, out var list)) { list = new List <DataViewSchema.Column>(); map.Add(role.Value, list); } list.Add(column); }
protected virtual IEnumerable <IColumnDefinition> BuildMetadata(ColumnMappingCollection mappings, ColumnRole role, Func <ColumnMapping, IColumnIdentifier> identify) { foreach (var mapping in mappings ?? new ColumnMappingCollection()) { yield return new Column() { Identifier = identify.Invoke(mapping), Role = role, Type = mapping.Type, } } ; }