From 347e45f561b7756ea6120837cef9126c3ddb5365 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 16 Jul 2013 11:59:38 +0200 Subject: [PATCH] change to XMLModel --- .../CampusAppWP8/Feed/Link/ClubLinkFeed.cs | 13 ++++---- .../CampusAppWP8/Feed/Link/CommonLinkFeed.cs | 19 +++++------ .../CampusAppWP8/Feed/Mensa/MensaFeed.cs | 22 ++++++------- .../Feed/StudentCouncil/StudentCouncilFeed.cs | 33 +++++++++++-------- .../StudentCouncil/StudentCouncilPage.xaml.cs | 4 +-- 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs index 2b40380a..76f9d279 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs @@ -34,11 +34,12 @@ namespace CampusAppWP8.Feed.Link #region Method - #region Protected + #region Private /// - /// Method implement CheckIsModelUpToDate()-Method . + /// Method check if the FeedModel is up-to-date /// + /// reference of the FeedModel /// true, if model is up-to-date, otherwise false private bool CheckIsModelUpToDate(LinkListModel model) { @@ -46,22 +47,22 @@ namespace CampusAppWP8.Feed.Link { return false; } + DateTime lastModified = model.CreateTime; return this.CheckIsUpToDate(lastModified); } /// - /// Method implement CheckIsFileUpToDate()-Method . + /// Method check if the FeedFile is up-to-date /// + /// reference of the FeedModel + /// info about the file /// true, if file is up-to-date, otherwise false private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo) { DateTime lastModified = fileInfo.LastWriteTime; return this.CheckIsUpToDate(lastModified); } - #endregion - - #region Private /// /// Check if the model or file is up-to-date. diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs index eb94131f..35c1db36 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs @@ -8,11 +8,10 @@ namespace CampusAppWP8.Feed.Link { using System; + using System.IO; + using CampusAppWP8.Model; using CampusAppWP8.Model.Link; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; - using CampusAppWP8.Model; - using System.IO; /// /// This Class is for CommonLinkFeeds @@ -35,11 +34,12 @@ namespace CampusAppWP8.Feed.Link #region Method - #region Protected + #region Private /// - /// Method implement CheckIsModelUpToDate()-Method . + /// Method check if the FeedModel is up-to-date /// + /// reference of the FeedModel /// true, if model is up-to-date, otherwise false private bool CheckIsModelUpToDate(LinkListModel model) { @@ -47,13 +47,16 @@ namespace CampusAppWP8.Feed.Link { return false; } + DateTime lastModified = model.CreateTime; return this.CheckIsUpToDate(lastModified); } /// - /// Method implement CheckIsFileUpToDate()-Method . + /// Method check if the FeedFile is up-to-date /// + /// reference of the FeedModel + /// info about the file /// true, if file is up-to-date, otherwise false private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo) { @@ -61,10 +64,6 @@ namespace CampusAppWP8.Feed.Link return this.CheckIsUpToDate(lastModified); } - #endregion - - #region Private - /// /// Check if the model or file is up-to-date. /// diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs index 2386beb0..f2c2509b 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs @@ -8,12 +8,10 @@ namespace CampusAppWP8.Api.Mensa { using System; - using System.Collections.ObjectModel; - using CampusAppWP8.Model.Mensa; - using CampusAppWP8.Utility; - using CampusAppWP8.Model; - using CampusAppWP8.Resources; using System.IO; + using CampusAppWP8.Model; + using CampusAppWP8.Model.Mensa; + using CampusAppWP8.Resources; /// /// This Class is for MensaFeeds @@ -36,11 +34,12 @@ namespace CampusAppWP8.Api.Mensa #region Method - #region Protected + #region Private /// - /// Method implement CheckIsModelUpToDate()-Method + /// Method check if the FeedModel is up-to-date /// + /// reference of the FeedModel /// true, if model is up-to-date, otherwise false private bool CheckIsModelUpToDate(MenuWeekModel model) { @@ -48,13 +47,16 @@ namespace CampusAppWP8.Api.Mensa { return false; } + DateTime lastModified = model.CreateTime; return this.CheckIsUpToDate(lastModified); } /// - /// Method implement CheckIsFileUpToDate()-Method + /// Method check if the FeedFile is up-to-date /// + /// reference of the FeedModel + /// info about the file /// true, if file is up-to-date, otherwise false private bool CheckIsFileUpToDate(MenuWeekModel model, FileInfo fileInfo) { @@ -62,10 +64,6 @@ namespace CampusAppWP8.Api.Mensa return this.CheckIsUpToDate(lastModified); } - #endregion - - #region Private - /// /// Method check if the last modification was later as the NewMenuWeekDay /// diff --git a/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs index 9925ac05..07c7d21d 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs @@ -8,14 +8,15 @@ namespace CampusAppWP8.Feed.StudentCouncil { using System; + using System.IO; + using CampusAppWP8.Model; using CampusAppWP8.Model.StudentCouncil; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; /// /// This Class is for StudentCouncilFeed /// - public class StudentCouncilFeed : XmlFeed + public class StudentCouncilFeed : XmlModel { #region Constructor @@ -23,40 +24,46 @@ namespace CampusAppWP8.Feed.StudentCouncil /// Initializes a new instance of the class. /// public StudentCouncilFeed() - : base(new Uri(Constants.UrlStudentCouncil_StudentCouncils, UriKind.Absolute), Constants.FileStudentCouncil_StudentCouncils) + : base(ModelType.FileAndFeed, Constants.FileStudentCouncil_StudentCouncils, Constants.UrlStudentCouncil_StudentCouncils) { + this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate); } #endregion #region Method - #region Protected + #region Private /// - /// Method implement CheckIsModelUpToDate()-Method . + /// Method check if the FeedModel is up-to-date /// + /// reference of the FeedModel /// true, if model is up-to-date, otherwise false - protected override bool CheckIsModelUpToDate() + private bool CheckIsModelUpToDate(StudentCouncilListModel model) { + if (model == null) + { + return false; + } + DateTime lastModified = this.Model.CreateTime; return this.CheckIsUpToDate(lastModified); } /// - /// Method implement CheckIsFileUpToDate()-Method . + /// Method check if the FeedFile is up-to-date /// + /// reference of the FeedModel + /// info about the file /// true, if file is up-to-date, otherwise false - protected override bool CheckIsFileUpToDate() + private bool CheckIsFileUpToDate(StudentCouncilListModel model, FileInfo fileInfo) { - DateTime lastModified = FileManager.GetFileInfo(FileName).LastWriteTime; + DateTime lastModified = fileInfo.LastWriteTime; return this.CheckIsUpToDate(lastModified); } - #endregion - - #region Private - /// /// Check if the model or file is up-to-date. /// diff --git a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs index f6b50393..ec22a66e 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs @@ -61,7 +61,7 @@ namespace CampusAppWP8.Pages.StudentCouncil } this.ProgressBar.Visibility = System.Windows.Visibility.Visible; - this.feed.LoadFeed(); + this.feed.LoadData(); } #endregion @@ -73,7 +73,7 @@ namespace CampusAppWP8.Pages.StudentCouncil private void InitializeFeed() { this.feed = new StudentCouncilFeed(); - this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady); + this.feed.onLoaded += new StudentCouncilFeed.OnLoaded(this.FeedIsReady); } ///