/// <summary> /// Fill properties from the current match /// </summary> /// <param name="_CurrentMatch"></param> public void Fill(vmMatchState _CurrentMatch) { CurrentPointDescription = _CurrentMatch.CurrentPointDescription; NamePlayer1 = _CurrentMatch.NamePlayer1; NamePlayer2 = _CurrentMatch.NamePlayer2; ScorePlayer1 = _CurrentMatch.ScorePlayer1; ScorePlayer2 = _CurrentMatch.ScorePlayer2; PrintableScore = _CurrentMatch.PrintableScore; Status = _CurrentMatch.Status; MatchType = _CurrentMatch.MatchType; Surface = _CurrentMatch.Surface; Duration = _CurrentMatch.Duration; Server = _CurrentMatch.Server; Winner = _CurrentMatch.Winner; InProgress = _CurrentMatch.InProgress; Completed = _CurrentMatch.Completed; Paused = _CurrentMatch.Paused; IsExtendPossible = _CurrentMatch.IsExtendPossible; Undo = _CurrentMatch.Undo; Switch = _CurrentMatch.Switch; TotalSets = new vmSetScore(_CurrentMatch.TotalSets); CurrentSetScore = new vmSetScore(_CurrentMatch.CurrentSetScore); if (StatisticsCollection == null) { StatisticsCollection = _CurrentMatch.StatisticsCollection; } else { StatisticsCollection.Update(_CurrentMatch.StatisticsCollection); } Notify(); }
/// <summary> /// Deserialize JSON string to vmMatchState /// </summary> /// <param name="JSON"></param> /// <returns></returns> public static vmMatchState Deserialize(String JSON) { try { MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(JSON)); //DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(vmMatchState)); //vmMatchState _State = (vmMatchState)js.ReadObject(stream); DataContractSerializer xml = new DataContractSerializer(typeof(vmMatchState)); vmMatchState _State = (vmMatchState)xml.ReadObject(stream); System.Diagnostics.Debug.WriteLine(_State); return(_State); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(String.Format("vmMatchState:Deserialize: {0}", e.Message)); } return(new vmMatchState()); }