public ComponentFeatureStateNotSupportedException(IComponentFeatureState state)
            : base($"State '{state}' is not supported.")
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            State = state;
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        public IComponentFeatureStateCollection With(IComponentFeatureState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (!_states.Add(state))
            {
                throw new InvalidOperationException();
            }

            return(this);
        }
Exemple #4
0
        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));
        }