public InPortCargo(CargoState previousState, UnLocode portLocation, DateTime arrivalDate) : base(previousState) { _lastKnownLocation = portLocation; _date = arrivalDate; _customCleared = false; }
protected Cargo(CargoState state) { if (null == state) { throw new ArgumentNullException("state"); } CurrentState = state; }
public override bool Equals(CargoState other) { InPortCargo cargo = other as InPortCargo; if (null != cargo && !_customCleared.Equals(cargo._customCleared)) { return(false); } return(base.Equals(other)); }
public OnboardCarrierCargo(CargoState previousState, IVoyage voyage, DateTime loadDate) : base(previousState) { if (null == voyage) { throw new ArgumentNullException("voyage"); } _voyage = voyage.Number; _date = loadDate; _lastKnownLocation = voyage.LastKnownLocation; }
public ClaimedCargo(CargoState previousState, DateTime claimDate) : base(previousState) { if (previousState.RoutingStatus == RoutingStatus.Misrouted) { throw new ArgumentException(string.Format("Can not claim the misrouted cargo {0}.", Identifier)); } if (previousState.RoutingStatus == RoutingStatus.NotRouted) { throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not routed.", Identifier)); } if (previousState.TransportStatus != TransportStatus.InPort) { throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not yet in port.", Identifier)); } if (!previousState.IsUnloadedAtDestination) { throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not yet been unloaded at destination.", Identifier)); } _claimDate = claimDate; }
public void AssignToRoute(IItinerary itinerary) { // Thread safe, lock free sincronization CargoState stateBeforeTransition; CargoState previousState = CurrentState; do { stateBeforeTransition = previousState; CargoState newValue = stateBeforeTransition.AssignToRoute(itinerary); previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition); }while (previousState != stateBeforeTransition); if (!previousState.Equals(this.CurrentState)) { ChangeEventArgs <IItinerary> args = new ChangeEventArgs <IItinerary>(previousState.Itinerary, CurrentState.Itinerary); EventHandler <ChangeEventArgs <IItinerary> > handler = ItineraryChanged; if (null != handler) { handler(this, args); } } }
public void SpecifyNewRoute(IRouteSpecification routeSpecification) { // Thread safe, lock free sincronization CargoState stateBeforeTransition; CargoState previousState = CurrentState; do { stateBeforeTransition = previousState; CargoState newValue = stateBeforeTransition.SpecifyNewRoute(routeSpecification); previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition); }while (previousState != stateBeforeTransition); if (!previousState.Equals(this.CurrentState)) { ChangeEventArgs <IRouteSpecification> args = new ChangeEventArgs <IRouteSpecification>(previousState.RouteSpecification, CurrentState.RouteSpecification); EventHandler <ChangeEventArgs <IRouteSpecification> > handler = NewRouteSpecified; if (null != handler) { handler(this, args); } } }
public void Unload(Voyage.IVoyage voyage, DateTime date) { // Thread safe, lock free sincronization CargoState stateBeforeTransition; CargoState previousState = CurrentState; do { stateBeforeTransition = previousState; CargoState newValue = stateBeforeTransition.Unload(voyage, date); previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition); }while (previousState != stateBeforeTransition); if (!previousState.Equals(this.CurrentState)) { HandlingEventArgs args = new HandlingEventArgs(CurrentState, CurrentState.CalculationDate); EventHandler <HandlingEventArgs> handler = Unloaded; if (null != handler) { handler(this, args); } } }
protected NewCargo(CargoState previousState, IItinerary newItinerary) : base(previousState, newItinerary) { }
protected NewCargo(CargoState previousState, IRouteSpecification newRoute) : base(previousState, newRoute) { }