public bool Matches(object stateIdentifier)
        {
            if (stateIdentifier == null)
            {
                return(false);
            }

            if (stateIdentifier is IStateMachineState)
            {
                return(StateName.Equals(((IStateMachineState)stateIdentifier).StateName));
            }

            if (stateIdentifier is string)
            {
                return(((string)stateIdentifier).Equals(StateIdentifier.ToString(),
                                                        StringComparison.CurrentCultureIgnoreCase));
            }

            if (StateIdentifier is string)
            {
                return(((string)StateIdentifier).Equals(stateIdentifier.ToString(),
                                                        StringComparison.CurrentCultureIgnoreCase));
            }

            if (StateIdentifier is IComparable)
            {
                return(((IComparable)StateIdentifier).CompareTo(stateIdentifier) == 0);
            }


            return(StateIdentifier.Equals(stateIdentifier));
        }
 public bool Equals(ICityStateZipData other)
 {
     return(City.Equals(other.City, StringComparison.CurrentCultureIgnoreCase) &&
            StateName.Equals(other.StateName, StringComparison.CurrentCultureIgnoreCase) &&
            StateAbbreviation.Equals(other.StateAbbreviation, StringComparison.CurrentCultureIgnoreCase) &&
            ZipCode.Equals(other.ZipCode, StringComparison.CurrentCultureIgnoreCase));
 }
Ejemplo n.º 3
0
        protected override void ApplyState(State upcomingState)
        {
            var eventsToPersist = new List <object>();

            if (upcomingState.DomainEvents != null)
            {
                foreach (var domainEvent in upcomingState.DomainEvents)
                {
                    eventsToPersist.Add(domainEvent);
                }
            }
            if (!StateName.Equals(upcomingState.StateName) || upcomingState.Timeout.HasValue)
            {
                eventsToPersist.Add(new StateChangeEvent(upcomingState.StateName, upcomingState.Timeout));
            }
            if (eventsToPersist.Count == 0)
            {
                base.ApplyState(upcomingState);
            }
            else
            {
                var nextData = StateData; // upcomingState.StateData;
                var handlersExecutedCounter = 0;


                PersistAll(eventsToPersist, @event =>
                {
                    handlersExecutedCounter++;
                    if (@event is TEvent)
                    {
                        nextData = ApplyEvent((TEvent)@event, nextData);
                    }
                    if (handlersExecutedCounter == eventsToPersist.Count)
                    {
                        base.ApplyState(upcomingState.Using(nextData));

                        if (upcomingState.AfterTransitionHandler != null)
                        {
                            upcomingState.AfterTransitionHandler(upcomingState.StateData);
                        }
                    }
                });
            }
        }
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is BlockingState))
            {
                return(false);
            }

            BlockingState that = (BlockingState)o;

            if (BlockedId != null ? !BlockedId.Equals(that.BlockedId) : that.BlockedId != null)
            {
                return(false);
            }
            if (StateName != null ? !StateName.Equals(that.StateName) : that.StateName != null)
            {
                return(false);
            }
            if (Service != null ? !Service.Equals(that.Service) : that.Service != null)
            {
                return(false);
            }
            if (!BlockChange.Equals(that.BlockChange))
            {
                return(false);
            }
            if (!BlockEntitlement.Equals(that.BlockEntitlement))
            {
                return(false);
            }
            if (!BlockBilling.Equals(that.BlockBilling))
            {
                return(false);
            }
            if (EffectiveDate != null ? EffectiveDate.CompareTo(that.EffectiveDate) != 0 : that.EffectiveDate != null)
            {
                return(false);
            }
            return(Type == that.Type);
        }
Ejemplo n.º 5
0
    public bool ChangeState(StateName name)
    {
        if (m_currentState.Equals(name))
        {
            return(false);
        }
        IState curr       = CurrentState();
        IState next_state = StateAt(name);

        if (next_state != null)
        {
            m_currentState = name;
            curr.Exit();
            next_state.Enter();
        }
        else
        {
            next_state     = StateAt(StateName.IDLE);
            m_currentState = StateName.IDLE;
            curr.Exit();
            next_state.Enter();
        }
        return(true);
    }
Ejemplo n.º 6
0
 public bool Equals(StateNode pOtherNode)
 {
     return(StateName.Equals(pOtherNode?.StateName));
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns true if ProcessInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of ProcessInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ProcessInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     StateName == other.StateName ||
                     StateName != null &&
                     StateName.Equals(other.StateName)
                 ) &&
                 (
                     ActivityName == other.ActivityName ||
                     ActivityName != null &&
                     ActivityName.Equals(other.ActivityName)
                 ) &&
                 (
                     SchemeId == other.SchemeId ||
                     SchemeId != null &&
                     SchemeId.Equals(other.SchemeId)
                 ) &&
                 (
                     SchemeCode == other.SchemeCode ||
                     SchemeCode != null &&
                     SchemeCode.Equals(other.SchemeCode)
                 ) &&
                 (
                     PreviousState == other.PreviousState ||
                     PreviousState != null &&
                     PreviousState.Equals(other.PreviousState)
                 ) &&
                 (
                     PreviousStateForDirect == other.PreviousStateForDirect ||
                     PreviousStateForDirect != null &&
                     PreviousStateForDirect.Equals(other.PreviousStateForDirect)
                 ) &&
                 (
                     PreviousStateForReverse == other.PreviousStateForReverse ||
                     PreviousStateForReverse != null &&
                     PreviousStateForReverse.Equals(other.PreviousStateForReverse)
                 ) &&
                 (
                     PreviousActivity == other.PreviousActivity ||
                     PreviousActivity != null &&
                     PreviousActivity.Equals(other.PreviousActivity)
                 ) &&
                 (
                     PreviousActivityForDirect == other.PreviousActivityForDirect ||
                     PreviousActivityForDirect != null &&
                     PreviousActivityForDirect.Equals(other.PreviousActivityForDirect)
                 ) &&
                 (
                     PreviousActivityForReverse == other.PreviousActivityForReverse ||
                     PreviousActivityForReverse != null &&
                     PreviousActivityForReverse.Equals(other.PreviousActivityForReverse)
                 ) &&
                 (
                     ParentProcessId == other.ParentProcessId ||
                     ParentProcessId != null &&
                     ParentProcessId.Equals(other.ParentProcessId)
                 ) &&
                 (
                     RootProcessId == other.RootProcessId ||
                     RootProcessId != null &&
                     RootProcessId.Equals(other.RootProcessId)
                 ) &&
                 (
                     InstanceStatus == other.InstanceStatus ||
                     InstanceStatus != null &&
                     InstanceStatus.Equals(other.InstanceStatus)
                 ) &&
                 (
                     Transitions == other.Transitions ||
                     Transitions != null &&
                     Transitions.SequenceEqual(other.Transitions)
                 ) &&
                 (
                     History == other.History ||
                     History != null &&
                     History.SequenceEqual(other.History)
                 ) &&
                 (
                     ProcessParameters == other.ProcessParameters ||
                     ProcessParameters != null &&
                     ProcessParameters.Equals(other.ProcessParameters)
                 ));
        }