下面的代码使得传入一组HtmlParserOptions变得容易,并且可以检查单个选项以查看它是否被选中。
[Flags]
public enum HtmlParserOptions
{
NotifyOpeningTags = 1,
NotifyClosingTags = 2,
NotifyText = 4,
NotifyEmptyText = 8
}
private bool IsOptionSet(HtmlParserOptions options, HtmlParserOptions singleOption)
{
return (options & singleOption) == singleOption;
}
我的问题是,是否可以通过在方法属性上实现接口的方式创建一个通用版本,以便与任何带有 Flags 属性的枚举一起使用?