diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index 36657110..63d3a82e 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -111,11 +111,11 @@
-
+
CampusMapPage.xaml
-
+
DepartmentPage.xaml
@@ -171,6 +171,7 @@
True
Constants.resx
+
@@ -179,6 +180,7 @@
+
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs
new file mode 100644
index 00000000..885c86fc
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs
@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 13.06.2013
+//----------------------------------------------------------------------
+namespace CampusAppWP8.Feed.Lecture
+{
+ using System;
+ using CampusAppWP8.Model.Lecture;
+ using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
+
+ ///
+ /// Class for the feed of the Lecture
+ ///
+ ///
+ /// need the XmlAPI
+ ///
+ public class LectureApi : XmlApi
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public LectureApi()
+ : base(new Uri(Constants.UrlLecture_ApiBaseAddr))
+ {
+ this.ValidRootName = Constants.LectureXmlValidRootName;
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs
deleted file mode 100644
index b635d51b..00000000
--- a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Company copyright tag.
-//
-// stubbfel
-// 13.06.2013
-//----------------------------------------------------------------------
-namespace CampusAppWP8.Feed.Lecture
-{
- using System;
- using CampusAppWP8.Model.Lecture;
- using CampusAppWP8.Utility;
-
- ///
- /// Class for the feed of the Lecture
- ///
- ///
- /// need the XmlAPI
- ///
- public class LectureFeed : XmlFeed
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// the RequestUrl
- public LectureFeed(Uri url)
- : base(url, "Lecture.xml")
- {
- this.validRootName = "lsf_auszug";
- }
-
- ///
- /// Method create the RequestUrl
- ///
- ///
- /// have to refactors
- ///
- /// value of the semester
- /// value of the degree
- /// value of the course
- /// value of the from
- /// value of the to
- /// return the requestUrl
- public static Uri CreateFeedUrl(string semester, string degree, string course, string from, string to)
- {
- return new Uri("http://www.zv.tu-cottbus.de/LSFveranst/LSF4?Semester=" + semester + "&Abschluss=" + degree + "&Studiengang=" + course + "&Von=" + from + "&Bis=" + to);
- }
-
- ///
- /// Method implement CheckIsModelUpToDate()-Method
- ///
- /// true, if model is up-to-date, otherwise false
- protected override bool CheckIsModelUpToDate()
- {
- return false;
- }
-
- ///
- /// Method implement CheckIsFileUpToDate()-Method
- ///
- /// true, if file is up-to-date, otherwise false
- protected override bool CheckIsFileUpToDate()
- {
- return false;
- }
- }
-}
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/Model/Utility/URLParamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs
index 7ea84ed4..c8d9c1a2 100644
--- a/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs
@@ -10,7 +10,7 @@ namespace CampusAppWP8.Model.Utility
///
/// This class is a Model for the URLParameter like GET-Parameter
///
- public class URLParamModel
+ public class UrlParamModel
{
#region Members
@@ -24,20 +24,20 @@ namespace CampusAppWP8.Model.Utility
#region Constructor
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// the key for the parameter
- public URLParamModel(string key)
+ public UrlParamModel(string key)
{
this.key = key;
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// the key for the parameter>
/// value of the parameter
- public URLParamModel(string key, string value)
+ public UrlParamModel(string key, string value)
{
this.key = key;
this.Value = value;
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml
index 9eeaf42a..d42a5df4 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml
@@ -22,12 +22,11 @@
-
+
-
-
+
@@ -160,7 +159,7 @@
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs
index f88b2de0..2ba1e36c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs
@@ -17,6 +17,8 @@ namespace CampusAppWP8.Pages.Lecture
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
+ using System.Windows.Media;
+ using System.Windows.Media.Imaging;
///
/// Class for the LecturePage
@@ -24,9 +26,9 @@ namespace CampusAppWP8.Pages.Lecture
public partial class LecturePage : PhoneApplicationPage
{
///
- /// actual LectureFeed
+ /// actual LectureAPI
///
- private LectureFeed feed;
+ private LectureApi api;
///
/// List for the courses of the BTU
@@ -118,6 +120,10 @@ namespace CampusAppWP8.Pages.Lecture
{
this.InitializeComponent();
this.SetupListPickers();
+ if ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible)
+ {
+ this.SearchButtonImg.Source = new BitmapImage(new Uri("/Assets/icons/search_159_dark.png",UriKind.Relative));
+ }
}
///
@@ -141,27 +147,43 @@ namespace CampusAppWP8.Pages.Lecture
/// sender of this event
/// events arguments
private void SendRequest(object sender, RoutedEventArgs e)
+ {
+ this.api = new LectureApi();
+ this.api.EventHandler.ApiIsReadyEvent += new ApiEventHandler.ApiReadyHandler(this.ApiIsReady);
+ this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
+ List parameterList = this.CreateUrlParameter();
+ 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;
ListPickerItemModel degree = (ListPickerItemModel)this.Degree.SelectedItem;
ListPickerItemModel course = (ListPickerItemModel)this.Course.SelectedItem;
ListPickerItemModel from = (ListPickerItemModel)this.From.SelectedItem;
ListPickerItemModel to = (ListPickerItemModel)this.To.SelectedItem;
- Uri request = LectureFeed.CreateFeedUrl(semester.Value, degree.Value, course.Value, from.Value, to.Value);
- this.feed = new LectureFeed(request);
- this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady);
- this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
- this.feed.LoadFeed();
+
+ List parameterList = new List();
+ 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 FeedIsReady()
+ private void ApiIsReady()
{
- App.SaveToIsolatedStorage(Constants.IsolatedStorageLectureModel, this.feed.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 89fc3666..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,45 +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 UrlLecture_ApiBaseAddr {
+ get {
+ 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 6ec52b15..3549c065 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -117,34 +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
new file mode 100644
index 00000000..ddb1baaa
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs
@@ -0,0 +1,47 @@
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 17.06.2013
+//----------------------------------------------------------------------
+namespace CampusAppWP8.Utility
+{
+ ///
+ /// This class handle the events of a API
+ ///
+ public class ApiEventHandler
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ApiEventHandler()
+ {
+ }
+
+ #region Delegate&Events
+ ///
+ /// Delegate for the ready event
+ ///
+ public delegate void ApiReadyHandler();
+
+ ///
+ /// The ready event
+ ///
+ public event ApiReadyHandler ApiIsReadyEvent;
+
+ #endregion
+
+ #region Method
+
+ ///
+ /// Method fire a ready event
+ ///
+ public void FireApiReadyevent()
+ {
+ this.ApiIsReadyEvent();
+ }
+
+ #endregion
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs
index f179c448..6c2283eb 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs
@@ -8,7 +8,9 @@
namespace CampusAppWP8.Utility
{
using System;
+ using System.Collections.Generic;
using System.Net;
+ using CampusAppWP8.Model.Utility;
///
/// Class realize the access of restful RestAPI
@@ -60,6 +62,23 @@ namespace CampusAppWP8.Utility
this.client.DownloadStringAsync(url);
}
+ ///
+ /// 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)
+ {
+ paramterStr += parameter.ToString();
+ }
+
+ string getUrlStr = this.client.BaseAddress + "?" + paramterStr;
+ return new Uri(getUrlStr, UriKind.Absolute);
+ }
+
///
/// Method realize the http-delete-method
///
@@ -74,7 +93,7 @@ namespace CampusAppWP8.Utility
}
///
- /// Method realize the http-delete-method
+ /// Method realize the http-head-method
///
///
/// is not supported by WebClient
@@ -87,7 +106,7 @@ namespace CampusAppWP8.Utility
}
///
- /// Method realize the http-delete-method
+ /// Method realize the http-options-method
///
///
/// is not supported by WebClient
@@ -100,7 +119,7 @@ namespace CampusAppWP8.Utility
}
///
- /// Method realize the http-delete-method
+ /// Method realize the http-connect-method
///
///
/// is not supported by WebClient
@@ -113,7 +132,7 @@ namespace CampusAppWP8.Utility
}
///
- /// Method realize the http-delete-method
+ /// Method realize the http-trace-method
///
///
/// is not supported by WebClient
@@ -137,7 +156,7 @@ namespace CampusAppWP8.Utility
}
///
- /// Method realize the http-get-method
+ /// Method realize the http-put-method
///
/// Url of the resource
/// callback method
@@ -148,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
new file mode 100644
index 00000000..df80424a
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs
@@ -0,0 +1,181 @@
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 13.06.2013
+//----------------------------------------------------------------------
+namespace CampusAppWP8.Utility
+{
+ 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
+ {
+ #region Members
+
+ ///
+ /// EventHandler of the API
+ ///
+ private readonly ApiEventHandler eventHandler;
+
+ ///
+ /// 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 API
+ ///
+ public T Model
+ {
+ get
+ {
+ return this.model;
+ }
+
+ set
+ {
+ if ((value == null && this.model != null) || !value.Equals(this.model))
+ {
+ this.model = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets for the event-handler of the API
+ ///
+ public ApiEventHandler EventHandler
+ {
+ get { return this.eventHandler; }
+ }
+
+ ///
+ /// 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
+ private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
+ {
+ Exception downloadError = e.Error;
+ if (downloadError != null)
+ {
+ return;
+ }
+
+ string downloadResult = e.Result;
+ if (downloadResult != null && !downloadResult.Equals(string.Empty))
+ {
+ this.CreateModel(downloadResult);
+ }
+ }
+ #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 5b49b20d..c94a9775 100644
--- a/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/utility/XMLFeed.cs
@@ -18,7 +18,10 @@ namespace CampusAppWP8.Utility
/// Type for model of the feed
public abstract class XmlFeed : Feed
{
- protected string validRootName = Constants.XMLRootElementName;
+ ///
+ /// Variable for the name of the root-tag
+ ///
+ private string validRootName = Constants.XMLRootElementName;
#region Constructor
@@ -40,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
///
@@ -50,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());