/// <summary> /// Gets value from specified bridge without throwing anything /// </summary> /// <param name="b">bridge to query</param> /// <param name="id">identifier to query</param> /// <returns>value or default(T) on failure</returns> private T SafeGet(IDataBridge <T> b, uint id) { try { return(b.Get(id)); } catch (Exception) { return(default(T)); } }
/// <summary> /// Gets value from chain. /// </summary> /// <param name="id">identifier of queried value</param> /// <returns>the value</returns> public T Get(uint id) { T t = SafeGet(_first, id); if (EqualityComparer <T> .Default.Equals(t, default(T))) { //t = SafeGet(_second, id); t = _second.Get(id); if (!EqualityComparer <T> .Default.Equals(t, default(T))) { _first.Set(id, t); } } return(t); }
protected override object DoImpl() { //if (_mdl == null) { ReportProgress(0, "Getting general team information"); DateTime?startDate = _startDate; DateTime?endDate = _endDate; if (_tdb != null) { TeamDetails teamDetails = _tdb.GetTeamDetails((uint)_teamId); if (teamDetails == null || teamDetails.Owner == null || teamDetails.Owner.JoinDate == null) { throw new Exception("Cannot get join date of owner"); } startDate = teamDetails.Owner.JoinDate.Value; endDate = DateTime.Now.ToHtTime(); } if (startDate == null || endDate == null) { throw new Exception("missing start and/or end date"); } //ReportProgress(10, String.Format("Getting match archive from {0} to {1}", startDate.Value.ToShortDateString(), endDate.Value.ToShortDateString())); ReportProgress(10, "Getting match archive"); MatchArchive ar = _mab.GetMatches((uint)_teamId, startDate.Value, endDate.Value); int noMatches = ar.Count(); int noCurMatch = 0; _mdl = new List <MatchDetails>(); foreach (Match m in ar.SafeEnum()) { ReportProgress(20 + (80 * noCurMatch / noMatches), String.Format("Getting match {0}/{1}", noCurMatch + 1, noMatches)); _mdl.Add(_mdb.Get((uint)m.ID)); ++noCurMatch; } } ReportProgress(100, "Done."); return(_mdl); }