/// <summary> /// Given a schema and a bunch of column names, create the BoundSchema object. Any or all of the column /// names may be null or whitespace, in which case they are ignored. Any columns that are specified but not /// valid columns of the schema are also ignored. /// </summary> public static RoleMappedSchema CreateRoleMappedSchemaOpt(ISchema schema, string feature, string group, IEnumerable <KeyValuePair <ColumnRole, string> > custom = null) { Contracts.CheckValueOrNull(feature); Contracts.CheckValueOrNull(custom); var list = new List <KeyValuePair <ColumnRole, string> >(); if (!string.IsNullOrWhiteSpace(feature)) { list.Add(ColumnRole.Feature.Bind(feature)); } if (!string.IsNullOrWhiteSpace(group)) { list.Add(ColumnRole.Group.Bind(group)); } if (custom != null) { list.AddRange(custom); } return(RoleMappedSchema.CreateOpt(schema, list)); }
/// <summary> /// Creates a RoleMappedData from the given schema and role/column-name pairs. /// This skips null or empty column-names, or column-names that are not found in the schema. /// </summary> public static RoleMappedData CreateOpt(IDataView data, IEnumerable <KeyValuePair <RoleMappedSchema.ColumnRole, string> > roles) { Contracts.CheckValue(data, nameof(data)); Contracts.CheckValue(roles, nameof(roles)); return(new RoleMappedData(data, RoleMappedSchema.CreateOpt(data.Schema, roles))); }