Why do many WPF-classes store boolean values as enum-flags?
Let's have a look at the Control class:
public class Control : FrameworkElement
{
internal ControlBoolFlags _controlBoolField;
// [...]
internal bool ReadControlFlag(ControlBoolFlags reqFlag);
internal void WriteControlFlag(ControlBoolFlags reqFlag, bool set);
// I think it's clear what they do
// [...]
internal enum ControlBoolFlags : ushort
{
CommandDisabled = 8,
ContainsSelection = 128,
ContentIsItem = 16,
ContentIsNotLogical = 1,
HeaderIsItem = 32,
HeaderIsNotLogical = 4,
IsSpaceKeyDown = 2,
ScrollHostValid = 64,
VisualStateChangeSuspended = 256
}
}
So I just want to know why MS chose this way to store the boolean values
instead of using a bool field for every flag. Is it just their style of
coding oder did they just want to save space for every field?
No comments:
Post a Comment