private static void ProcessScorers(Match match, HattrickDataMatch htMatch) { foreach (var matchScorer in htMatch.MatchScorers) { int scorerTeamId = int.Parse(matchScorer.ScorerTeamID); bool isHomeScorer = match.MatchHomeTeam.Team.TeamId == scorerTeamId; var scorer = new MatchScorer { OppositionGoals = isHomeScorer ? short.Parse(matchScorer.ScorerAwayGoals) : short.Parse(matchScorer.ScorerHomeGoals), TeamGoals = isHomeScorer ? short.Parse(matchScorer.ScorerHomeGoals) : short.Parse(matchScorer.ScorerAwayGoals), PlayerId = int.Parse(matchScorer.ScorerPlayerID), PlayerName = matchScorer.ScorerPlayerName, ScorerMinute = short.Parse(matchScorer.ScorerMinute) }; if (isHomeScorer) match.AddHomeMatchScorer(scorer); else match.AddAwayMatchScorer(scorer); } }
private static void ProcessEvents(Match match, HattrickDataMatch htMatch) { foreach (var htMatchEvent in htMatch.EventList) { MatchEvent matchEvent = new MatchEvent(); matchEvent.EventIndex = short.Parse(htMatchEvent.Index); matchEvent.EventText = htMatchEvent.EventText; matchEvent.EventTypeID = short.Parse(htMatchEvent.EventTypeID); matchEvent.EventVariation = short.Parse(htMatchEvent.EventVariation); matchEvent.Minute = short.Parse(htMatchEvent.Minute); matchEvent.ObjectPlayerID = string.IsNullOrEmpty(htMatchEvent.ObjectPlayerID) ? (int?)null : int.Parse(htMatchEvent.ObjectPlayerID); matchEvent.SubjectPlayerID = string.IsNullOrEmpty(htMatchEvent.SubjectPlayerID) ? (int?)null : int.Parse(htMatchEvent.SubjectPlayerID); matchEvent.SubjectTeamID = string.IsNullOrEmpty(htMatchEvent.SubjectTeamID) ? (int?)null : int.Parse(htMatchEvent.SubjectTeamID); match.AddMatchEvent(matchEvent); } }
private static void ProcessInjuries(Match match, HattrickDataMatch htMatch) { foreach (var htInjury in htMatch.MatchInjuries) { int injuryTeamId = int.Parse(htInjury.InjuryTeamID); var injury = new MatchInjury { PlayerId = int.Parse(htInjury.InjuryPlayerID), PlayerName = htInjury.InjuryPlayerName, InjuryMinute = short.Parse(htInjury.InjuryMinute), InjuryType = short.Parse(htInjury.InjuryType), }; if (match.MatchHomeTeam.Team.TeamId == injuryTeamId) match.AddHomeTeamMatchInjury(injury); else if (match.MatchAwayTeam.Team.TeamId == injuryTeamId) match.AddAwayTeamMatchInjury(injury); } }
private static void ProcessBookings(Match match, HattrickDataMatch htMatch) { foreach (var htBooking in htMatch.Bookings) { int bookingTeamId = int.Parse(htBooking.BookingTeamID); var booking = new MatchBooking { PlayerId = int.Parse(htBooking.BookingPlayerID), PlayerName = htBooking.BookingPlayerName, BookingMinute = short.Parse(htBooking.BookingMinute), BookingType = short.Parse(htBooking.BookingType) }; if (match.MatchHomeTeam.Team.TeamId == bookingTeamId) match.AddHomeTeamMatchBooking(booking); else if (match.MatchAwayTeam.Team.TeamId == bookingTeamId) match.AddAwayTeamMatchBooking(booking); } }
public static bool LoadFromFile(string fileName, out HattrickDataMatch obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an HattrickDataMatch object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output HattrickDataMatch object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out HattrickDataMatch obj, out System.Exception exception) { exception = null; obj = default(HattrickDataMatch); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string xml, out HattrickDataMatch obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an HattrickDataMatch object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output HattrickDataMatch object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out HattrickDataMatch obj, out System.Exception exception) { exception = null; obj = default(HattrickDataMatch); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }