public void Commit() { if (CommandDevice == null) { throw new NullReferenceException("Device cannot be null"); } if (Filter == null || Filter()) { CommandDevice.WriteTrue(); } else { if (AlternativeAction != null) { AlternativeAction(); } } }