private void ChangeColorPalette(ColorPalette colorPalette) { if (colorPalette == null) { throw new ArgumentNullException(nameof(colorPalette)); } if (!_colorPaletteStore.ColorPalettes.Contains(colorPalette)) { throw new Exception("Chosen ColorPalette is not known in the ColorPaletteStore."); } if (!colorPalette.IsValid) { throw new Exception("Cannot use an invalid ColorPalette."); } if (colorPalette.Equals(_colorPalette)) { return; } var @event = new ColorPaletteChangedEvent(colorPalette); _colorPalette = colorPalette; MessageBus.Publish(@event); }