diff --git a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs index 3f80c5e2..885c86fc 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel @@ -9,8 +9,8 @@ namespace CampusAppWP8.Feed.Lecture { using System; using CampusAppWP8.Model.Lecture; - using CampusAppWP8.Utility; using CampusAppWP8.Resources; + using CampusAppWP8.Utility; /// /// Class for the feed of the Lecture @@ -23,11 +23,10 @@ namespace CampusAppWP8.Feed.Lecture /// /// Initializes a new instance of the class. /// - /// the RequestUrl public LectureApi() - : base(new Uri(Constants.UrlLectureApiBaseAddr)) + : base(new Uri(Constants.UrlLecture_ApiBaseAddr)) { - this.validRootName = "lsf_auszug"; + this.ValidRootName = Constants.LectureXmlValidRootName; } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModule.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModule.cs index 076407b5..1a190438 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModule.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModule.cs @@ -90,7 +90,7 @@ namespace CampusAppWP8.Model.Lecture /// private void CreateUrl() { - this.url = new Uri(Constants.UrlLectureModulBaseAddr + this.number.ToString()); + this.url = new Uri(Constants.UrlLecture_ModulBaseAddr + this.number.ToString()); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml index 9eeaf42a..db091258 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml @@ -22,12 +22,11 @@ - + - - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index 9602344f..44274e0e 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -24,7 +24,7 @@ namespace CampusAppWP8.Pages.Lecture public partial class LecturePage : PhoneApplicationPage { /// - /// actual LectureFeed + /// actual LectureAPI /// private LectureApi api; @@ -149,6 +149,10 @@ namespace CampusAppWP8.Pages.Lecture this.api.XMLHttpGet(parameterList); } + /// + /// Method read the values from the inputs and put them in a list of parameters + /// + /// a list of parameters private List CreateUrlParameter() { ListPickerItemModel semester = (ListPickerItemModel)this.Semester.SelectedItem; @@ -158,22 +162,22 @@ namespace CampusAppWP8.Pages.Lecture ListPickerItemModel to = (ListPickerItemModel)this.To.SelectedItem; List parameterList = new List(); - parameterList.Add(new UrlParamModel("Semester",semester.Value)); - parameterList.Add(new UrlParamModel("Abschluss", degree.Value)); - parameterList.Add(new UrlParamModel("Studiengang", course.Value)); - parameterList.Add(new UrlParamModel("Von", from.Value)); - parameterList.Add(new UrlParamModel("Bis", to.Value)); + parameterList.Add(new UrlParamModel(Constants.ParamGetLecture_Semester, semester.Value)); + parameterList.Add(new UrlParamModel(Constants.ParamGetLecture_Degree, degree.Value)); + parameterList.Add(new UrlParamModel(Constants.ParamGetLecture_Course, course.Value)); + parameterList.Add(new UrlParamModel(Constants.ParamGetLecture_From, from.Value)); + parameterList.Add(new UrlParamModel(Constants.ParamGetLecture_To, to.Value)); return parameterList; - } + /// /// Method will be execute if the feed is ready /// private void ApiIsReady() { - App.SaveToIsolatedStorage(Constants.IsolatedStorageLectureModel, this.api.Model); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_LectureModel, this.api.Model); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; - Uri url = new Uri(Constants.PathResultPage, UriKind.Relative); + Uri url = new Uri(Constants.PathLecture_ResultPage, UriKind.Relative); NavigationService.Navigate(url); } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs index 989f0b51..cf6d4332 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs @@ -13,7 +13,7 @@ namespace CampusAppWP8.Pages.Lecture using Microsoft.Phone.Controls; /// - /// Class for the page which shows Webpages from the BaseAddress + /// Class for the page which shows Webpages from the BaseAddress /// public partial class ModulWebPage : PhoneApplicationPage { @@ -31,10 +31,10 @@ namespace CampusAppWP8.Pages.Lecture /// Arguments of navigation protected override void OnNavigatedTo(NavigationEventArgs e) { - if (NavigationContext.QueryString.ContainsKey(Constants.ParamLectureModulNumber)) + if (NavigationContext.QueryString.ContainsKey(Constants.ParamModelLecture_ModulNumber)) { - string number = NavigationContext.QueryString[Constants.ParamLectureModulNumber]; - this.WebmailBrowser.Navigate(new Uri(Constants.UrlLectureModulBaseAddr + number, UriKind.Absolute)); + string number = NavigationContext.QueryString[Constants.ParamModelLecture_ModulNumber]; + this.WebmailBrowser.Navigate(new Uri(Constants.UrlLecture_ModulBaseAddr + number, UriKind.Absolute)); } base.OnNavigatedTo(e); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs index ad54ee75..e09763e3 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs @@ -31,9 +31,9 @@ namespace CampusAppWP8.Pages.Lecture /// Arguments of navigation protected override void OnNavigatedTo(NavigationEventArgs e) { - if (NavigationContext.QueryString.ContainsKey(Constants.ParamLectureActivityId)) + if (NavigationContext.QueryString.ContainsKey(Constants.ParamModelLecture_ActivityId)) { - string activityId = NavigationContext.QueryString[Constants.ParamLectureActivityId]; + string activityId = NavigationContext.QueryString[Constants.ParamModelLecture_ActivityId]; this.LoadActivity(int.Parse(activityId)); } @@ -46,7 +46,7 @@ namespace CampusAppWP8.Pages.Lecture /// id of the activity private void LoadActivity(int activityId) { - LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorageLectureModel); + LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LectureModel); if (list != null) { LectureActivity activity = list.GetActivity(activityId); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs index 454b67ea..6486db91 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs @@ -39,7 +39,7 @@ namespace CampusAppWP8.Pages.Lecture /// Arguments of navigation protected override void OnNavigatedTo(NavigationEventArgs e) { - LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorageLectureModel); + LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LectureModel); this.ResultList.ItemsSource = list.Activities; base.OnNavigatedTo(e); } @@ -132,7 +132,7 @@ namespace CampusAppWP8.Pages.Lecture private void ShowModulWebPage(object sender, RoutedEventArgs e) { Button btn = (Button)sender; - Uri url = new Uri(Constants.PathLectureModulWebPage + "?" + Constants.ParamLectureModulNumber + "=" + btn.Tag, UriKind.Relative); + Uri url = new Uri(Constants.PathLecture_ModulWebPage + "?" + Constants.ParamModelLecture_ModulNumber + "=" + btn.Tag, UriKind.Relative); NavigationService.Navigate(url); } @@ -144,7 +144,7 @@ namespace CampusAppWP8.Pages.Lecture private void ShowDetailPage(object sender, RoutedEventArgs e) { Button btn = (Button)sender; - Uri url = new Uri(Constants.PathResultDetailPage + "?" + Constants.ParamLectureActivityId + "=" + btn.Tag, UriKind.Relative); + Uri url = new Uri(Constants.PathLecture_ResultDetailPage + "?" + Constants.ParamModelLecture_ActivityId + "=" + btn.Tag, UriKind.Relative); NavigationService.Navigate(url); } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/Webmail/WebmailPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Webmail/WebmailPage.xaml.cs index 22e81f25..50afc636 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Webmail/WebmailPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Webmail/WebmailPage.xaml.cs @@ -30,7 +30,7 @@ namespace CampusAppWP8.Pages.Webmail /// private void LoadWebmailPage() { - this.WebmailBrowser.Navigate(new Uri(Constants.UrlWebMailAddr, UriKind.Absolute)); + this.WebmailBrowser.Navigate(new Uri(Constants.UrlWebMail_Addr, UriKind.Absolute)); } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 9171dccc..f6d9df87 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -63,27 +63,81 @@ namespace CampusAppWP8.Resources { /// /// Sucht eine lokalisierte Zeichenfolge, die LectureModel ähnelt. /// - internal static string IsolatedStorageLectureModel { + internal static string IsolatedStorage_LectureModel { get { - return ResourceManager.GetString("IsolatedStorageLectureModel", resourceCulture); + return ResourceManager.GetString("IsolatedStorage_LectureModel", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die lsf_auszug ähnelt. + /// + internal static string LectureXmlValidRootName { + get { + return ResourceManager.GetString("LectureXmlValidRootName", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt. + /// + internal static string ParamGetLecture_Course { + get { + return ResourceManager.GetString("ParamGetLecture_Course", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Abschluss ähnelt. + /// + internal static string ParamGetLecture_Degree { + get { + return ResourceManager.GetString("ParamGetLecture_Degree", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Von ähnelt. + /// + internal static string ParamGetLecture_From { + get { + return ResourceManager.GetString("ParamGetLecture_From", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Semester ähnelt. + /// + internal static string ParamGetLecture_Semester { + get { + return ResourceManager.GetString("ParamGetLecture_Semester", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Bis ähnelt. + /// + internal static string ParamGetLecture_To { + get { + return ResourceManager.GetString("ParamGetLecture_To", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die ActivityId ähnelt. /// - internal static string ParamLectureActivityId { + internal static string ParamModelLecture_ActivityId { get { - return ResourceManager.GetString("ParamLectureActivityId", resourceCulture); + return ResourceManager.GetString("ParamModelLecture_ActivityId", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die ModulNumber ähnelt. /// - internal static string ParamLectureModulNumber { + internal static string ParamModelLecture_ModulNumber { get { - return ResourceManager.GetString("ParamLectureModulNumber", resourceCulture); + return ResourceManager.GetString("ParamModelLecture_ModulNumber", resourceCulture); } } @@ -99,54 +153,54 @@ namespace CampusAppWP8.Resources { /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ModulWebPage.xaml ähnelt. /// - internal static string PathLectureModulWebPage { + internal static string PathLecture_ModulWebPage { get { - return ResourceManager.GetString("PathLectureModulWebPage", resourceCulture); + return ResourceManager.GetString("PathLecture_ModulWebPage", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ResultDetailPage.xaml ähnelt. /// - internal static string PathResultDetailPage { + internal static string PathLecture_ResultDetailPage { get { - return ResourceManager.GetString("PathResultDetailPage", resourceCulture); + return ResourceManager.GetString("PathLecture_ResultDetailPage", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ResultPage.xaml ähnelt. /// - internal static string PathResultPage { + internal static string PathLecture_ResultPage { get { - return ResourceManager.GetString("PathResultPage", resourceCulture); + return ResourceManager.GetString("PathLecture_ResultPage", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt. /// - internal static string UrlLectureApiBaseAddr { + internal static string UrlLecture_ApiBaseAddr { get { - return ResourceManager.GetString("UrlLectureApiBaseAddr", resourceCulture); + return ResourceManager.GetString("UrlLecture_ApiBaseAddr", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die https://www.tu-cottbus.de/modul/ ähnelt. /// - internal static string UrlLectureModulBaseAddr { + internal static string UrlLecture_ModulBaseAddr { get { - return ResourceManager.GetString("UrlLectureModulBaseAddr", resourceCulture); + return ResourceManager.GetString("UrlLecture_ModulBaseAddr", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die https://webmail.tu-cottbus.de ähnelt. /// - internal static string UrlWebMailAddr { + internal static string UrlWebMail_Addr { get { - return ResourceManager.GetString("UrlWebMailAddr", resourceCulture); + return ResourceManager.GetString("UrlWebMail_Addr", resourceCulture); } } diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index cbf64ad2..3549c065 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -117,37 +117,55 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + LectureModel - + ActivityId - + ModulNumber Url - + /Pages/Lecture/ModulWebPage.xaml - + /Pages/Lecture/ResultDetailPage.xaml - + https://www.tu-cottbus.de/modul/ root - + https://webmail.tu-cottbus.de - + /Pages/Lecture/ResultPage.xaml - + + lsf_auszug + + + Studiengang + + + Abschluss + + + Von + + + Semester + + + Bis + + http://www.zv.tu-cottbus.de/LSFveranst/LSF4 \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs b/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs index f90b2ec4..ddb1baaa 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs @@ -1,13 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 17.06.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility { /// - /// This class handle the events of a api + /// This class handle the events of a API /// public class ApiEventHandler { diff --git a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs index 1b61a137..6c2283eb 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs @@ -7,10 +7,10 @@ //----------------------------------------------------------------------using System; namespace CampusAppWP8.Utility { - using CampusAppWP8.Model.Utility; using System; using System.Collections.Generic; using System.Net; + using CampusAppWP8.Model.Utility; /// /// Class realize the access of restful RestAPI @@ -66,14 +66,16 @@ namespace CampusAppWP8.Utility /// Method create the Url for the http-get-method /// /// list of parameters - /// + /// absolute API-Url include GetParameter public Uri CreateGetUrl(List parameters) { string paramterStr = string.Empty; - foreach(UrlParamModel parameter in parameters){ + foreach (UrlParamModel parameter in parameters) + { paramterStr += parameter.ToString(); } - string getUrlStr = client.BaseAddress + "?" + paramterStr; + + string getUrlStr = this.client.BaseAddress + "?" + paramterStr; return new Uri(getUrlStr, UriKind.Absolute); } @@ -91,7 +93,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-delete-method + /// Method realize the http-head-method /// /// /// is not supported by WebClient @@ -104,7 +106,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-delete-method + /// Method realize the http-options-method /// /// /// is not supported by WebClient @@ -117,7 +119,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-delete-method + /// Method realize the http-connect-method /// /// /// is not supported by WebClient @@ -130,7 +132,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-delete-method + /// Method realize the http-trace-method /// /// /// is not supported by WebClient @@ -154,7 +156,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-get-method + /// Method realize the http-put-method /// /// Url of the resource /// callback method @@ -165,7 +167,7 @@ namespace CampusAppWP8.Utility } /// - /// Method realize the http-get-method + /// Method realize the http-patch-method /// /// Url of the resource /// callback method diff --git a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs index 64218571..df80424a 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs @@ -1,37 +1,63 @@ -using CampusAppWP8.Model.Utility; -using CampusAppWP8.Resources; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; -using System.Xml.Serialization; - +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 13.06.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility { - public class XmlApi : RestApi + using System; + using System.Collections.Generic; + using System.Net; + using System.Xml.Linq; + using System.Xml.Serialization; + using CampusAppWP8.Model.Utility; + using CampusAppWP8.Resources; + + /// + /// This abstract Class is for Xml-API + /// + /// Type for model of the API + public abstract class XmlApi : RestApi { - /// - /// The model of the feed - /// - private T model; - - protected string validRootName = Constants.XMLRootElementName; + #region Members /// - /// EventHandler of the api + /// EventHandler of the API /// private readonly ApiEventHandler eventHandler; - public XmlApi(Uri apiBaseAddress): base(apiBaseAddress) + /// + /// The model of the API + /// + private T model; + + /// + /// Variable for the name of the root-tag + /// + private string validRootName = Constants.XMLRootElementName; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// BaseUrl of the API + public XmlApi(Uri apiBaseAddress) + : base(apiBaseAddress) { this.eventHandler = new ApiEventHandler(); } + #endregion + + #region Proberty + /// - /// Gets or sets for the model of the feed + /// Gets or sets for the model of the API /// public T Model { @@ -50,7 +76,7 @@ namespace CampusAppWP8.Utility } /// - /// Gets for the event-handler of the feed + /// Gets for the event-handler of the API /// public ApiEventHandler EventHandler { @@ -58,11 +84,84 @@ namespace CampusAppWP8.Utility } /// - /// Method will be execute if the download of the feed is completed and create the model + /// Gets or sets the ValidRootName of the API + /// + protected string ValidRootName + { + get + { + return this.validRootName; + } + + set + { + if (value != this.validRootName) + { + this.validRootName = value; + } + } + } + + #endregion + + #region Methods + #region public + + /// + /// Method send an HTTP-Get for an Xml-API + /// + /// list of GetParameter + public void XMLHttpGet(List parameters) + { + Uri getUrl = this.CreateGetUrl(parameters); + this.HttpGet(getUrl, this.DownloadCompleted); + } + + /// + /// Method create the model of the API + /// + /// content of the API + private void CreateModel(string xmlString) + { + if (xmlString == null || xmlString == string.Empty) + { + return; + } + + this.Deserialization(xmlString); + this.EventHandler.FireApiReadyevent(); + } + #endregion + + #region private + /// + /// Method implement the deserialization a Xml-API + /// + /// content of the API + private void Deserialization(string xmlString) + { + XmlSerializer serializer = new XmlSerializer(typeof(T)); + XDocument document = XDocument.Parse(xmlString); + if (!document.Root.Name.ToString().Equals(this.ValidRootName)) + { + XElement content = document.Root; + document = new XDocument(); + document.Add(new XElement(this.ValidRootName, content)); + } + + T model = (T)serializer.Deserialize(document.CreateReader()); + if (model != null) + { + this.Model = model; + } + } + + /// + /// Method will be execute if the download of the API is completed and create the model /// /// Sender of the event /// Arguments of the event - public void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e) + private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e) { Exception downloadError = e.Error; if (downloadError != null) @@ -76,53 +175,7 @@ namespace CampusAppWP8.Utility this.CreateModel(downloadResult); } } - - - /// - /// Method realize the http-get-method resource - /// - /// Url of the resource - /// callback method - public void XMLHttpGet(List parameters) - { - Uri getUrl = this.CreateGetUrl(parameters); - this.HttpGet(getUrl, this.DownloadCompleted); - } - /// - /// Method create the model of the feed - /// - /// content of the feed - private void CreateModel(string xmlString) - { - if (xmlString == null || xmlString == string.Empty) - { - return; - } - - this.Deserialization(xmlString); - this.EventHandler.FireApiReadyevent(); - } - - /// - /// Method implement the deserialization a Xml-feed - /// - /// content of the feed - protected void Deserialization(string feedString) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Parse(feedString); - if (!document.Root.Name.ToString().Equals(validRootName)) - { - XElement content = document.Root; - document = new XDocument(); - document.Add(new XElement(validRootName, content)); - } - - T model = (T)serializer.Deserialize(document.CreateReader()); - if (model != null) - { - this.Model = model; - } - } + #endregion + #endregion } } diff --git a/CampusAppWP8/CampusAppWP8/utility/Feed.cs b/CampusAppWP8/CampusAppWP8/utility/Feed.cs index 456ad521..a085617b 100644 --- a/CampusAppWP8/CampusAppWP8/utility/Feed.cs +++ b/CampusAppWP8/CampusAppWP8/utility/Feed.cs @@ -14,7 +14,7 @@ namespace CampusAppWP8.Utility /// This a abstract Class for reading, store and deserialization Feeds from the Web. /// /// Type for model of the feed - public abstract class Feed:RestApi + public abstract class Feed : RestApi { #region Member diff --git a/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs b/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs index 6efa3610..c94a9775 100644 --- a/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs +++ b/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs @@ -19,9 +19,9 @@ namespace CampusAppWP8.Utility public abstract class XmlFeed : Feed { /// - /// Variablo for the name of the roottag + /// Variable for the name of the root-tag /// - protected string validRootName = Constants.XMLRootElementName; + private string validRootName = Constants.XMLRootElementName; #region Constructor @@ -43,6 +43,27 @@ namespace CampusAppWP8.Utility } #endregion + #region Proberty + /// + /// Gets or sets the ValidRootName of the feed + /// + protected string ValidRootName + { + get + { + return this.validRootName; + } + + set + { + if (value != this.validRootName) + { + this.validRootName = value; + } + } + } + #endregion + #region Methods /// @@ -53,11 +74,11 @@ namespace CampusAppWP8.Utility { XmlSerializer serializer = new XmlSerializer(typeof(T)); XDocument document = XDocument.Parse(feedString); - if (!document.Root.Name.ToString().Equals(validRootName)) + if (!document.Root.Name.ToString().Equals(this.ValidRootName)) { XElement content = document.Root; document = new XDocument(); - document.Add(new XElement(validRootName, content)); + document.Add(new XElement(this.ValidRootName, content)); } T model = (T)serializer.Deserialize(document.CreateReader());