public DataFormatGroupCollection Get(string q)
{
// slightly weird projection - in order to filter out the formats (and groups)
// we don't want, we have to query and then reproject into the correct static type
if (q.IsNotBlank())
{
var query = from g in DataFormats.Known
from f in g.Formats
where g.Name.ToLowerInvariant().Contains(q)
|| f.Name.ToLowerInvariant().Contains(q)
|| f.Code.ToLowerInvariant().Contains(q)
group f by g into formats
select new DataFormatGroup
{
Name = formats.Key.Name,
Glyph = formats.Key.Glyph,
Formats = new DataFormatCollection(formats)
};
return new DataFormatGroupCollection(query);
}
else
{
return DataFormats.Known;
}
}