jellyfin/Emby.Dlna/Didl/Filter.cs

30 lines
682 B
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2016-10-29 15:22:20 -07:00
2016-10-29 15:34:54 -07:00
namespace Emby.Dlna.Didl
2016-10-29 15:22:20 -07:00
{
public class Filter
{
2017-08-24 12:52:19 -07:00
private readonly string[] _fields;
2016-10-29 15:22:20 -07:00
private readonly bool _all;
public Filter()
: this("*")
{
}
public Filter(string filter)
{
2020-01-09 09:07:13 -07:00
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
2016-10-29 15:22:20 -07:00
2017-08-24 12:52:19 -07:00
_fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
2016-10-29 15:22:20 -07:00
}
public bool Contains(string field)
{
2020-08-20 12:04:57 -07:00
return _all || Array.Exists(_fields, x => x.Equals(field, StringComparison.OrdinalIgnoreCase));
2016-10-29 15:22:20 -07:00
}
}
}