public ComponentFeatureStateNotSupportedException(IComponentFeatureState state) : base($"State '{state}' is not supported.") { if (state == null) { throw new ArgumentNullException(nameof(state)); } State = state; }
public ComponentHasStateCondition(IComponent component, IComponentFeatureState state) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (state == null) { throw new ArgumentNullException(nameof(state)); } WithExpression(() => component.GetState().Has(state)); }
public IComponentFeatureStateCollection With(IComponentFeatureState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } if (!_states.Add(state)) { throw new InvalidOperationException(); } return(this); }
public bool Has(IComponentFeatureState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } var foundState = _states.FirstOrDefault(s => s.GetType() == state.GetType()); if (foundState == null) { throw new ComponentFeatureNotSupportedException(state.GetType()); } return(ReferenceEquals(state, foundState) || foundState.Equals(state)); }