コード例 #1
0
        private static Dictionary <string, List <Schema.Column> > MapFromNames(Schema schema, IEnumerable <KeyValuePair <ColumnRole, string> > roles, bool opt = false)
        {
            Contracts.AssertValue(schema);
            Contracts.AssertValue(roles);

            var map = new Dictionary <string, List <Schema.Column> >();

            foreach (var kvp in roles)
            {
                Contracts.AssertNonEmpty(kvp.Key.Value);
                if (string.IsNullOrEmpty(kvp.Value))
                {
                    continue;
                }
                var info = schema.GetColumnOrNull(kvp.Value);
                if (info.HasValue)
                {
                    Add(map, kvp.Key.Value, info.Value);
                }
                else if (!opt)
                {
                    throw Contracts.ExceptParam(nameof(schema), $"{kvp.Value} column '{kvp.Key.Value}' not found");
                }
            }
            return(map);
        }