예제 #1
0
        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;
        }
예제 #2
0
 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;
예제 #7
0
 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);
예제 #9
0
 /// <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));
 }
예제 #10
0
        /// <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);
        }
예제 #11
0
 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);
 }
예제 #13
0
 /// <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;
예제 #14
0
        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);
        }
예제 #15
0
 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,
                }
     }
     ;
 }