public static EnumerationFlags AddFlag <T>(this EnumerationFlags flags, T value) where T : Enumeration
        {
            if (flags.AllowMultipleSelections == false && flags.SelectedKeys.Count == 1)
            {
                throw new ArgumentException("Cannot add item, multiple selections are not allowed");
            }
            if (flags.SelectedKeys.Contains(value.Key))
            {
                throw new ArgumentException("State already flagged");
            }

            flags.SelectedKeys.Add(value.Key);

            return(flags);
        }
 public static void ReplaceFlag(this EnumerationFlags flags, Enumeration old, Enumeration @new)
 {
     flags.RemoveFlag(old);
     flags.AddFlag(@new);
 }
        public static EnumerationFlags RemoveFlag <T>(this EnumerationFlags flags, T value) where T : Enumeration
        {
            flags.SelectedKeys.Remove(value.Key);

            return(flags);
        }
 public static bool HasFlag(this EnumerationFlags flags, string key) => flags.SelectedKeys.Exists(x => x == key);
 public static bool HasFlag(this EnumerationFlags flags, Enumeration item) => flags.SelectedKeys.Contains(item.Key);
 public static int Count(this EnumerationFlags flags) => flags.SelectedKeys.Count;