/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { _feedLocator = new LocalFeedLocationService(); CacheDictionary = new Dictionary<Uri, KeyValuePair<DateTime, IList<FeedItemSummary>>>(); FeedTitles = new ObservableCollection<string>(); FeedItems = new SmartObservableCollection<FeedItemSummary>(); Feeds = _feedLocator.GetFeeds(); //Initialize the feeds collection CurrentFeedUri = Feeds[0]; //Initialize the CurrentFeedUri PopulateFeedTitles(); //Initialize the feed titles collection if (IsInDesignMode) { // Code runs in Blend --> create design time data. var designFeed = FeedSummarizer.SummarizeFeed(DesignTimeData.Feeds.First()); PopulateFeedItems(designFeed); } else { // Code runs "for real" _remoteQueryService = new FeedQueryService(new HttpFeedFactory()); LocateFeedUri = new RelayCommand<SelectionChangedEventArgs>(ResolveFeedUri); LoadLastOrDefaultFeed = new RelayCommand(() => ExecuteQuery(CurrentFeedUri, true)); NavigateToUri = new RelayCommand<string>(uri => Messenger.Default.Send<string>(uri, "NavigationRequest")); BeginLoading = new RelayCommand(() => DispatcherHelper.CheckBeginInvokeOnUI(() => { IsLoading = true; })); PopulateItemsList = new RelayCommand(() => { if (FeedIsInCache(CurrentFeedUri.FeedUri)) { UpdateBindings(CacheDictionary[CurrentFeedUri.FeedUri].Value); } else { ExecuteQuery(CurrentFeedUri, bind: true); } }); EndLoading = new RelayCommand(() => DispatcherHelper.CheckBeginInvokeOnUI(() => { if(FeedIsInCache(CurrentFeedUri.FeedUri)) IsLoading = false; })); BuildAllItems = new RelayCommand(() => { foreach(var feed in Feeds) { ExecuteQuery(feed); } }); } }
public HomeController(IFeedLocationService feedlocator) { _feedlocator = feedlocator; }