コード例 #1
0
        public ComponentFeatureStateNotSupportedException(IComponentFeatureState state)
            : base($"State '{state}' is not supported.")
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

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

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

            return(this);
        }
コード例 #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));
        }