Change your internal &to |:
if ((operation & (Operations.add | Operations.eval)) == (Operations.add | Operations.eval))
This is equivalent to:
if( ((operation & Operations.add)==Operations.add) &&
((operation & Operations.eval)==Operations.eval))
which may be more readable. You can also consider the extension as follows:
public static bool HasFlag(this Operations op, Operations checkflag)
{
return (op & checkflag)==checkflag;
}
You can do it:
if(operation.HasFlag(Operations.add) && Operations.HasFlag(Operations.eval))
which may be even more readable. Finally, you can create this extension for even more fun:
public static bool HasAllFlags(this Operations op, params Operations[] checkflags)
{
foreach(Operations checkflag in checkflags)
{
if((op & checkflag)!=checkflag)
return false;
}
return true;
}
Then your expression may turn into:
if(operation.HasAllFlags(Operations.add, Operations.eval))