private static Dictionary <string, List <ColumnInfo> > MapFromNames(Schema schema, IEnumerable <KeyValuePair <ColumnRole, string> > roles, bool opt = false) { Contracts.AssertValue(schema); Contracts.AssertValue(roles); var map = new Dictionary <string, List <ColumnInfo> >(); foreach (var kvp in roles) { Contracts.AssertNonEmpty(kvp.Key.Value); if (string.IsNullOrEmpty(kvp.Value)) { continue; } ColumnInfo info; if (!opt) { info = ColumnInfo.CreateFromName(schema, kvp.Value, kvp.Key.Value); } else if (!ColumnInfo.TryCreateFromName(schema, kvp.Value, out info)) { continue; } Add(map, kvp.Key.Value, info); } return(map); }
private static Dictionary <string, List <ColumnInfo> > MapFromNamesOpt(ISchema schema, IEnumerable <KeyValuePair <ColumnRole, string> > roles) { Contracts.AssertValue(schema, "schema"); Contracts.AssertValue(roles, "roles"); var map = new Dictionary <string, List <ColumnInfo> >(); foreach (var kvp in roles) { Contracts.CheckNonEmpty(kvp.Key.Value, nameof(roles), "Bad column role"); if (string.IsNullOrEmpty(kvp.Value)) { continue; } ColumnInfo info; if (!ColumnInfo.TryCreateFromName(schema, kvp.Value, out info)) { continue; } Add(map, kvp.Key.Value, info); } return(map); }