add RestApi httpget

This commit is contained in:
stubbfel
2013-06-10 11:27:02 +02:00
parent ffa0d8a009
commit c3a9109a7e
3 changed files with 47 additions and 4 deletions

View File

@@ -147,6 +147,7 @@
<Compile Include="Utility\FileList.cs" />
<Compile Include="Utility\FileManager.cs" />
<Compile Include="Utility\Logger.cs" />
<Compile Include="Utility\RestApi.cs" />
<Compile Include="Utility\StringManager.cs" />
<Compile Include="Utility\URLList.cs" />
<Compile Include="Utility\XmlFeed.cs" />

View File

@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------
// <copyright file="Feed.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>03.05.2013</sience>
//----------------------------------------------------------------------using System;
namespace CampusAppWP8.Utility
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
public class RestApi
{
#region Members
WebClient client;
#endregion
#region Constructor
public RestApi()
{
client = new WebClient();
}
#endregion
#region Methods
#region public
public void HttpGet(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
{
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action);
client.DownloadStringAsync(url);
}
#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>
public abstract class Feed<T>:RestApi
{
#region Member
@@ -119,6 +119,8 @@ namespace CampusAppWP8.Utility
/// </summary>
public void LoadFeed()
{
this.DownloadFeed();
return;
if (this.IsModelUpToDate())
{
return;
@@ -174,9 +176,7 @@ namespace CampusAppWP8.Utility
/// </summary>
private void DownloadFeed()
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.DownloadCompleted);
client.DownloadStringAsync(this.FeedURL);
this.HttpGet(this.FeedURL, this.DownloadCompleted);
}
/// <summary>