Пример #1
0
 /// <summary>
 /// The add to history.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="args">
 /// The args.
 /// </param>
 private void AddToHistory(object sender, HistoryPushEventArgs args)
 {
     this._history.AddLast(args.Change);
     this._historyViewModel.Insert(0, HistoryViewModel.FromHistoryLocation(args.Change, this._faviconCache));
     args.Change.PropertyChanged += this.UpdateTitle;
 }
Пример #2
0
        /// <summary>
        /// The load function.
        /// </summary>
        private void Load()
        {
            using (var db = new DataContext())
            {
                // do not track the query, and load either all or all in x hours based on config
                IQueryable <HistoryLocation> query = db.History.AsNoTracking()
                                                     .Where(history => this._config.OverrideAndLoadAllHistory || DateTime.Now < history.Date.Add(this._config.HistoryTimeSpan))
                                                     .Include(history => history.Url);

                // create history list
                this._history = new LinkedList <HistoryLocation>(query);

                // create view model
                this._historyViewModel = new BindingList <HistoryViewModel>(query
                                                                            .AsEnumerable()
                                                                            .Select(hist => HistoryViewModel.FromHistoryLocation(hist, this._faviconCache))
                                                                            .Reverse()
                                                                            .ToList());
            }
        }