/// <inheritdoc /> /// <summary> /// Pushes a new item to history and to the database. /// </summary> /// <param name="historyLocation"> /// The historyLocation. /// </param> public void Push(HistoryLocation historyLocation) { using (var db = new DataContext()) { try { // try to find the matching url by id or by hash code var foundurl = historyLocation.Url.Id != 0 ? db.Urls.Single(url => url.Id == historyLocation.Url.Id) : db.Urls.FirstOrDefault(url => url.HashCode == historyLocation.Url.HashCode); historyLocation.Url = foundurl ?? historyLocation.Url; } catch { // wait } db.History.Add(historyLocation); db.SaveChanges(); } // update memory history and report update in view model this.HistoryUpdated?.Invoke(this, new HistoryPushEventArgs(historyLocation)); }
/// <summary> /// The from history Location. /// </summary> /// <param name="location"> /// The Location. /// </param> /// <param name="faviconLookup"> /// The favicon Lookup. /// </param> /// <returns> /// The <see cref="HistoryViewModel"/>. /// </returns> public static HistoryViewModel FromHistoryLocation(HistoryLocation location, IFavicon faviconLookup) { HistoryViewModel hvm = new HistoryViewModel() { Name = string.IsNullOrEmpty(location.Title) ? location.Url.Host : location.Title, Date = location.Date, _historyLocation = location, _faviconLookup = faviconLookup }; location.PropertyChanged += hvm.UpdateViewModel; return(hvm); }
/// <summary> /// Initializes a new instance of the <see cref="CurrentLocationChangeArgs"/> class. /// </summary> /// <param name="type"> /// The type. /// </param> /// <param name="location"> /// The location. /// </param> public CurrentLocationChangeArgs(ChangeType type, HistoryLocation location) { this.ChangeType = type; this.HistoryLocation = location; }
/// <inheritdoc /> /// <summary> /// Initializes a new instance of the <see cref="T:Browser.History.HistoryPushEventArgs" /> class. /// </summary> /// <param name="history"> /// The entire history. /// </param> public HistoryPushEventArgs(HistoryLocation history) { this.Change = history; }