public void ReciveTrainInfo(TrainInfo info) { if (TrainsDictionary.Keys.FirstOrDefault(a => a.Name == info.BaseTrain.Number) == null && tempProxy != null) { var train = new TrainUI { Name = info.BaseTrain.Number, Location = info.TrainPosition, PassangersCount = info.BaseTrain.CurrentPassengers, Speed = int.Parse(info.BaseTrain.Speed.ToString()) }; TrainsDictionary.Add(train, tempProxy); Trains.Add(train); tempProxy = null; } }
private void HandleProxy() { switch (tempProxy.State) { case CommunicationState.Closed: tempProxy = null; //Message("Dissconnected"); break; case CommunicationState.Faulted: tempProxy.Abort(); tempProxy = null; //Message("Dissconnected"); break; case CommunicationState.Opened: tempProxy.GetTrainInfoAsync(); break; default: break; } }