add RestApi httpget
This commit is contained in:
@@ -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" />
|
||||
|
||||
42
CampusAppWP8/CampusAppWP8/Utility/RestApi.cs
Normal file
42
CampusAppWP8/CampusAppWP8/Utility/RestApi.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user