public void Enum_ContainsAny() { BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic; Assert.True(flags.ContainsAny(BindingFlags.Public)); Assert.True(flags.ContainsAny(BindingFlags.NonPublic)); Assert.True(flags.ContainsAny(BindingFlags.Public | BindingFlags.NonPublic)); Assert.True(flags.ContainsAny(BindingFlags.Public | BindingFlags.Instance)); Assert.False(flags.ContainsAny(BindingFlags.Instance)); }
public static T AssertReflectedField <T, TField>(this T value, string name, BindingFlags flags, Action <T, TField> verify) { // TODO: TBD: perhaps an exception is justified somewhere in here... TField GetFieldValue(FieldInfo fieldInfo) { if (flags.ContainsAny(Instance)) { return((TField)fieldInfo.GetValue(value)); } if (flags.ContainsAny(Static)) { return((TField)fieldInfo.GetValue(null)); } return(default);