Merge branch 'feature/#33' into develop

This commit is contained in:
stubbfel
2013-06-17 13:50:07 +02:00
19 changed files with 471 additions and 134 deletions

View File

@@ -111,11 +111,11 @@
<Compile Include="Model\Lecture\LectureModule.cs" />
<Compile Include="Model\Mensa\MenuModel.cs" />
<Compile Include="Model\Mensa\MenuWeekModel.cs" />
<Compile Include="Model\Utility\URLParamModel.cs" />
<Compile Include="Model\Utility\UrlParamModel.cs" />
<Compile Include="Pages\Campusmap\CampusMapPage.xaml.cs">
<DependentUpon>CampusMapPage.xaml</DependentUpon>
</Compile>
<Compile Include="Feed\Lecture\LectureFeed.cs" />
<Compile Include="Feed\Lecture\LectureApi.cs" />
<Compile Include="Feed\Departments\DepartmentFeed.cs" />
<Compile Include="Pages\Departments\DepartmentPage.xaml.cs">
<DependentUpon>DepartmentPage.xaml</DependentUpon>
@@ -171,6 +171,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Constants.resx</DependentUpon>
</Compile>
<Compile Include="Utility\ApiEventHandler.cs" />
<Compile Include="Utility\Feed.cs" />
<Compile Include="Utility\FeedEventHandler.cs" />
<Compile Include="Utility\FileList.cs" />
@@ -179,6 +180,7 @@
<Compile Include="Utility\RestApi.cs" />
<Compile Include="Utility\StringManager.cs" />
<Compile Include="Utility\URLList.cs" />
<Compile Include="Utility\XmlApi.cs" />
<Compile Include="Utility\XmlFeed.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------
// <copyright file="LectureApi.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>13.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Feed.Lecture
{
using System;
using CampusAppWP8.Model.Lecture;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
/// <summary>
/// Class for the feed of the Lecture
/// </summary>
/// <remarks>
/// need the XmlAPI
/// </remarks>
public class LectureApi : XmlApi<LectureList>
{
/// <summary>
/// Initializes a new instance of the <see cref="LectureApi" /> class.
/// </summary>
public LectureApi()
: base(new Uri(Constants.UrlLecture_ApiBaseAddr))
{
this.ValidRootName = Constants.LectureXmlValidRootName;
}
}
}

View File

@@ -1,67 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="LectureFeed.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>13.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Feed.Lecture
{
using System;
using CampusAppWP8.Model.Lecture;
using CampusAppWP8.Utility;
/// <summary>
/// Class for the feed of the Lecture
/// </summary>
/// <remarks>
/// need the XmlAPI
/// </remarks>
public class LectureFeed : XmlFeed<LectureList>
{
/// <summary>
/// Initializes a new instance of the <see cref="LectureFeed" /> class.
/// </summary>
/// <param name="url">the RequestUrl</param>
public LectureFeed(Uri url)
: base(url, "Lecture.xml")
{
this.validRootName = "lsf_auszug";
}
/// <summary>
/// Method create the RequestUrl
/// </summary>
/// <remarks>
/// have to refactors
/// </remarks>
/// <param name="semester">value of the semester</param>
/// <param name="degree">value of the degree</param>
/// <param name="course">value of the course</param>
/// <param name="from">value of the from</param>
/// <param name="to">value of the to</param>
/// <returns>return the requestUrl</returns>
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);
}
/// <summary>
/// Method implement CheckIsModelUpToDate()-Method <see cref="Pages"/>
/// </summary>
/// <returns>true, if model is up-to-date, otherwise false</returns>
protected override bool CheckIsModelUpToDate()
{
return false;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>
/// </summary>
/// <returns>true, if file is up-to-date, otherwise false</returns>
protected override bool CheckIsFileUpToDate()
{
return false;
}
}
}

View File

@@ -90,7 +90,7 @@ namespace CampusAppWP8.Model.Lecture
/// </summary>
private void CreateUrl()
{
this.url = new Uri(Constants.UrlLectureModulBaseAddr + this.number.ToString());
this.url = new Uri(Constants.UrlLecture_ModulBaseAddr + this.number.ToString());
}
#endregion

View File

@@ -10,7 +10,7 @@ namespace CampusAppWP8.Model.Utility
/// <summary>
/// This class is a Model for the URLParameter like GET-Parameter
/// </summary>
public class URLParamModel
public class UrlParamModel
{
#region Members
@@ -24,20 +24,20 @@ namespace CampusAppWP8.Model.Utility
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="URLParamModel" /> class.
/// Initializes a new instance of the <see cref="UrlParamModel" /> class.
/// </summary>
/// <param name="key">the key for the parameter</param>
public URLParamModel(string key)
public UrlParamModel(string key)
{
this.key = key;
}
/// <summary>
/// Initializes a new instance of the <see cref="URLParamModel" /> class.
/// Initializes a new instance of the <see cref="UrlParamModel" /> class.
/// </summary>
/// <param name="key">the key for the parameter</param>>
/// <param name="value">value of the parameter</param>
public URLParamModel(string key, string value)
public UrlParamModel(string key, string value)
{
this.key = key;
this.Value = value;

View File

@@ -22,12 +22,11 @@
</Grid.RowDefinitions>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<ProgressBar Name="ProgressBar" Visibility="Collapsed" IsIndeterminate="True"/>
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<Border BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="0,0,0,2" >
<TextBlock Text="{Binding Path=LocalizedResources.LectureApp_Title, Source={StaticResource LocalizedStrings}}"/>
</Border>
<ProgressBar Name="ProgressBar" Visibility="Collapsed" IsIndeterminate="True"/>
</Border>
</StackPanel>

View File

@@ -24,9 +24,9 @@ namespace CampusAppWP8.Pages.Lecture
public partial class LecturePage : PhoneApplicationPage
{
/// <summary>
/// actual LectureFeed
/// actual LectureAPI
/// </summary>
private LectureFeed feed;
private LectureApi api;
/// <summary>
/// List for the courses of the BTU
@@ -141,27 +141,43 @@ namespace CampusAppWP8.Pages.Lecture
/// <param name="sender">sender of this event</param>
/// <param name="e"> events arguments</param>
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<UrlParamModel> parameterList = this.CreateUrlParameter();
this.api.XMLHttpGet(parameterList);
}
/// <summary>
/// Method read the values from the inputs and put them in a list of parameters
/// </summary>
/// <returns>a list of parameters</returns>
private List<UrlParamModel> 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<UrlParamModel> parameterList = new List<UrlParamModel>();
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;
}
/// <summary>
/// Method will be execute if the feed is ready
/// </summary>
private void FeedIsReady()
private void ApiIsReady()
{
App.SaveToIsolatedStorage<LectureList>(Constants.IsolatedStorageLectureModel, this.feed.Model);
App.SaveToIsolatedStorage<LectureList>(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);
}
}

View File

@@ -13,7 +13,7 @@ namespace CampusAppWP8.Pages.Lecture
using Microsoft.Phone.Controls;
/// <summary>
/// Class for the page which shows Webpages from the BaseAddress <see cref="Constants.UrlLectureModulBaseAddr" />
/// Class for the page which shows Webpages from the BaseAddress <see cref="Constants.UrlLecture_ModulBaseAddr" />
/// </summary>
public partial class ModulWebPage : PhoneApplicationPage
{
@@ -31,10 +31,10 @@ namespace CampusAppWP8.Pages.Lecture
/// <param name="e">Arguments of navigation</param>
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);

View File

@@ -31,9 +31,9 @@ namespace CampusAppWP8.Pages.Lecture
/// <param name="e">Arguments of navigation</param>
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
/// <param name="activityId">id of the activity</param>
private void LoadActivity(int activityId)
{
LectureList list = App.LoadFromIsolatedStorage<LectureList>(Constants.IsolatedStorageLectureModel);
LectureList list = App.LoadFromIsolatedStorage<LectureList>(Constants.IsolatedStorage_LectureModel);
if (list != null)
{
LectureActivity activity = list.GetActivity(activityId);

View File

@@ -39,7 +39,7 @@ namespace CampusAppWP8.Pages.Lecture
/// <param name="e">Arguments of navigation</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
LectureList list = App.LoadFromIsolatedStorage<LectureList>(Constants.IsolatedStorageLectureModel);
LectureList list = App.LoadFromIsolatedStorage<LectureList>(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);
}
}

View File

@@ -30,7 +30,7 @@ namespace CampusAppWP8.Pages.Webmail
/// </summary>
private void LoadWebmailPage()
{
this.WebmailBrowser.Navigate(new Uri(Constants.UrlWebMailAddr, UriKind.Absolute));
this.WebmailBrowser.Navigate(new Uri(Constants.UrlWebMail_Addr, UriKind.Absolute));
}
}
}

View File

@@ -13,7 +13,7 @@
<Capability Name="ID_CAP_ISV_CAMERA" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="pages/StartPage.xaml" />
<DefaultTask Name="_default" NavigationPage="pages/Lecture/LecturePage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">

View File

@@ -63,27 +63,81 @@ namespace CampusAppWP8.Resources {
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die LectureModel ähnelt.
/// </summary>
internal static string IsolatedStorageLectureModel {
internal static string IsolatedStorage_LectureModel {
get {
return ResourceManager.GetString("IsolatedStorageLectureModel", resourceCulture);
return ResourceManager.GetString("IsolatedStorage_LectureModel", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die lsf_auszug ähnelt.
/// </summary>
internal static string LectureXmlValidRootName {
get {
return ResourceManager.GetString("LectureXmlValidRootName", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt.
/// </summary>
internal static string ParamGetLecture_Course {
get {
return ResourceManager.GetString("ParamGetLecture_Course", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Abschluss ähnelt.
/// </summary>
internal static string ParamGetLecture_Degree {
get {
return ResourceManager.GetString("ParamGetLecture_Degree", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Von ähnelt.
/// </summary>
internal static string ParamGetLecture_From {
get {
return ResourceManager.GetString("ParamGetLecture_From", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Semester ähnelt.
/// </summary>
internal static string ParamGetLecture_Semester {
get {
return ResourceManager.GetString("ParamGetLecture_Semester", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bis ähnelt.
/// </summary>
internal static string ParamGetLecture_To {
get {
return ResourceManager.GetString("ParamGetLecture_To", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die ActivityId ähnelt.
/// </summary>
internal static string ParamLectureActivityId {
internal static string ParamModelLecture_ActivityId {
get {
return ResourceManager.GetString("ParamLectureActivityId", resourceCulture);
return ResourceManager.GetString("ParamModelLecture_ActivityId", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die ModulNumber ähnelt.
/// </summary>
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 {
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ModulWebPage.xaml ähnelt.
/// </summary>
internal static string PathLectureModulWebPage {
internal static string PathLecture_ModulWebPage {
get {
return ResourceManager.GetString("PathLectureModulWebPage", resourceCulture);
return ResourceManager.GetString("PathLecture_ModulWebPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ResultDetailPage.xaml ähnelt.
/// </summary>
internal static string PathResultDetailPage {
internal static string PathLecture_ResultDetailPage {
get {
return ResourceManager.GetString("PathResultDetailPage", resourceCulture);
return ResourceManager.GetString("PathLecture_ResultDetailPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ResultPage.xaml ähnelt.
/// </summary>
internal static string PathResultPage {
internal static string PathLecture_ResultPage {
get {
return ResourceManager.GetString("PathResultPage", resourceCulture);
return ResourceManager.GetString("PathLecture_ResultPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt.
/// </summary>
internal static string UrlLecture_ApiBaseAddr {
get {
return ResourceManager.GetString("UrlLecture_ApiBaseAddr", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die https://www.tu-cottbus.de/modul/ ähnelt.
/// </summary>
internal static string UrlLectureModulBaseAddr {
internal static string UrlLecture_ModulBaseAddr {
get {
return ResourceManager.GetString("UrlLectureModulBaseAddr", resourceCulture);
return ResourceManager.GetString("UrlLecture_ModulBaseAddr", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die https://webmail.tu-cottbus.de ähnelt.
/// </summary>
internal static string UrlWebMailAddr {
internal static string UrlWebMail_Addr {
get {
return ResourceManager.GetString("UrlWebMailAddr", resourceCulture);
return ResourceManager.GetString("UrlWebMail_Addr", resourceCulture);
}
}

View File

@@ -117,34 +117,55 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="IsolatedStorageLectureModel" xml:space="preserve">
<data name="IsolatedStorage_LectureModel" xml:space="preserve">
<value>LectureModel</value>
</data>
<data name="ParamLectureActivityId" xml:space="preserve">
<data name="ParamModelLecture_ActivityId" xml:space="preserve">
<value>ActivityId</value>
</data>
<data name="ParamLectureModulNumber" xml:space="preserve">
<data name="ParamModelLecture_ModulNumber" xml:space="preserve">
<value>ModulNumber</value>
</data>
<data name="ParamUrl" xml:space="preserve">
<value>Url</value>
</data>
<data name="PathLectureModulWebPage" xml:space="preserve">
<data name="PathLecture_ModulWebPage" xml:space="preserve">
<value>/Pages/Lecture/ModulWebPage.xaml</value>
</data>
<data name="PathResultDetailPage" xml:space="preserve">
<data name="PathLecture_ResultDetailPage" xml:space="preserve">
<value>/Pages/Lecture/ResultDetailPage.xaml</value>
</data>
<data name="UrlLectureModulBaseAddr" xml:space="preserve">
<data name="UrlLecture_ModulBaseAddr" xml:space="preserve">
<value>https://www.tu-cottbus.de/modul/</value>
</data>
<data name="XMLRootElementName" xml:space="preserve">
<value>root</value>
</data>
<data name="UrlWebMailAddr" xml:space="preserve">
<data name="UrlWebMail_Addr" xml:space="preserve">
<value>https://webmail.tu-cottbus.de</value>
</data>
<data name="PathResultPage" xml:space="preserve">
<data name="PathLecture_ResultPage" xml:space="preserve">
<value>/Pages/Lecture/ResultPage.xaml</value>
</data>
<data name="LectureXmlValidRootName" xml:space="preserve">
<value>lsf_auszug</value>
</data>
<data name="ParamGetLecture_Course" xml:space="preserve">
<value>Studiengang</value>
</data>
<data name="ParamGetLecture_Degree" xml:space="preserve">
<value>Abschluss</value>
</data>
<data name="ParamGetLecture_From" xml:space="preserve">
<value>Von</value>
</data>
<data name="ParamGetLecture_Semester" xml:space="preserve">
<value>Semester</value>
</data>
<data name="ParamGetLecture_To" xml:space="preserve">
<value>Bis</value>
</data>
<data name="UrlLecture_ApiBaseAddr" xml:space="preserve">
<value>http://www.zv.tu-cottbus.de/LSFveranst/LSF4</value>
</data>
</root>

View File

@@ -0,0 +1,47 @@
//-----------------------------------------------------------------------
// <copyright file="ApiEventHandler.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>17.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Utility
{
/// <summary>
/// This class handle the events of a API <see cref="RestApi{T}"/>
/// </summary>
public class ApiEventHandler
{
/// <summary>
/// Initializes a new instance of the <see cref="ApiEventHandler" /> class.
/// </summary>
public ApiEventHandler()
{
}
#region Delegate&Events
/// <summary>
/// Delegate for the ready event
/// </summary>
public delegate void ApiReadyHandler();
/// <summary>
/// The ready event
/// </summary>
public event ApiReadyHandler ApiIsReadyEvent;
#endregion
#region Method
/// <summary>
/// Method fire a ready event
/// </summary>
public void FireApiReadyevent()
{
this.ApiIsReadyEvent();
}
#endregion
}
}

View File

@@ -8,7 +8,9 @@
namespace CampusAppWP8.Utility
{
using System;
using System.Collections.Generic;
using System.Net;
using CampusAppWP8.Model.Utility;
/// <summary>
/// Class realize the access of restful RestAPI
@@ -60,6 +62,23 @@ namespace CampusAppWP8.Utility
this.client.DownloadStringAsync(url);
}
/// <summary>
/// Method create the Url for the http-get-method
/// </summary>
/// <param name="parameters"> list of parameters</param>
/// <returns>absolute API-Url include GetParameter</returns>
public Uri CreateGetUrl(List<UrlParamModel> 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);
}
/// <summary>
/// Method realize the http-delete-method
/// </summary>
@@ -74,7 +93,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-delete-method
/// Method realize the http-head-method
/// </summary>
/// <remarks>
/// is not supported by WebClient
@@ -87,7 +106,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-delete-method
/// Method realize the http-options-method
/// </summary>
/// <remarks>
/// is not supported by WebClient
@@ -100,7 +119,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-delete-method
/// Method realize the http-connect-method
/// </summary>
/// <remarks>
/// is not supported by WebClient
@@ -113,7 +132,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-delete-method
/// Method realize the http-trace-method
/// </summary>
/// <remarks>
/// is not supported by WebClient
@@ -137,7 +156,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-get-method
/// Method realize the http-put-method
/// </summary>
/// <param name="url">Url of the resource</param>
/// <param name="action">callback method</param>
@@ -148,7 +167,7 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// Method realize the http-get-method
/// Method realize the http-patch-method
/// </summary>
/// <param name="url">Url of the resource</param>
/// <param name="action">callback method</param>

View File

@@ -0,0 +1,181 @@
//-----------------------------------------------------------------------
// <copyright file="XmlApi.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>13.06.2013</sience>
//----------------------------------------------------------------------
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;
/// <summary>
/// This abstract Class is for Xml-API
/// </summary>
/// <typeparam name="T">Type for model of the API</typeparam>
public abstract class XmlApi<T> : RestApi
{
#region Members
/// <summary>
/// EventHandler of the API
/// </summary>
private readonly ApiEventHandler eventHandler;
/// <summary>
/// The model of the API
/// </summary>
private T model;
/// <summary>
/// Variable for the name of the root-tag
/// </summary>
private string validRootName = Constants.XMLRootElementName;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="XmlApi{T}" /> class.
/// </summary>
/// <param name="apiBaseAddress">BaseUrl of the API</param>
public XmlApi(Uri apiBaseAddress)
: base(apiBaseAddress)
{
this.eventHandler = new ApiEventHandler();
}
#endregion
#region Proberty
/// <summary>
/// Gets or sets for the model of the API
/// </summary>
public T Model
{
get
{
return this.model;
}
set
{
if ((value == null && this.model != null) || !value.Equals(this.model))
{
this.model = value;
}
}
}
/// <summary>
/// Gets for the event-handler of the API
/// </summary>
public ApiEventHandler EventHandler
{
get { return this.eventHandler; }
}
/// <summary>
/// Gets or sets the ValidRootName of the API
/// </summary>
protected string ValidRootName
{
get
{
return this.validRootName;
}
set
{
if (value != this.validRootName)
{
this.validRootName = value;
}
}
}
#endregion
#region Methods
#region public
/// <summary>
/// Method send an HTTP-Get for an Xml-API
/// </summary>
/// <param name="parameters">list of GetParameter</param>
public void XMLHttpGet(List<UrlParamModel> parameters)
{
Uri getUrl = this.CreateGetUrl(parameters);
this.HttpGet(getUrl, this.DownloadCompleted);
}
/// <summary>
/// Method create the model of the API
/// </summary>
/// <param name="xmlString">content of the API</param>
private void CreateModel(string xmlString)
{
if (xmlString == null || xmlString == string.Empty)
{
return;
}
this.Deserialization(xmlString);
this.EventHandler.FireApiReadyevent();
}
#endregion
#region private
/// <summary>
/// Method implement the deserialization a Xml-API
/// </summary>
/// <param name="xmlString">content of the API</param>
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;
}
}
/// <summary>
/// Method will be execute if the download of the API is completed and create the model
/// </summary>
/// <param name="sender">Sender of the event</param>
/// <param name="e">Arguments of the event</param>
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
}
}

View File

@@ -14,7 +14,7 @@ namespace CampusAppWP8.Utility
/// This a abstract Class for reading, store and deserialization Feeds from the Web.
/// </summary>
/// <typeparam name="T">Type for model of the feed</typeparam>
public abstract class Feed<T>:RestApi
public abstract class Feed<T> : RestApi
{
#region Member

View File

@@ -18,7 +18,10 @@ namespace CampusAppWP8.Utility
/// <typeparam name="T">Type for model of the feed</typeparam>
public abstract class XmlFeed<T> : Feed<T>
{
protected string validRootName = Constants.XMLRootElementName;
/// <summary>
/// Variable for the name of the root-tag
/// </summary>
private string validRootName = Constants.XMLRootElementName;
#region Constructor
@@ -40,6 +43,27 @@ namespace CampusAppWP8.Utility
}
#endregion
#region Proberty
/// <summary>
/// Gets or sets the ValidRootName of the feed
/// </summary>
protected string ValidRootName
{
get
{
return this.validRootName;
}
set
{
if (value != this.validRootName)
{
this.validRootName = value;
}
}
}
#endregion
#region Methods
/// <summary>
@@ -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());