change to XMLModel

This commit is contained in:
stubbfel
2013-07-23 11:40:59 +02:00
parent 125587f99c
commit 932842aebb
3 changed files with 13 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ namespace CampusAppWP8.Feed.Lecture
using CampusAppWP8.Model.Lecture;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Model;
/// <summary>
/// Class for the feed of the Lecture
@@ -18,13 +19,13 @@ namespace CampusAppWP8.Feed.Lecture
/// <remarks>
/// need the XmlAPI
/// </remarks>
public class LectureApi : XmlApi<LectureList>
public class LectureApi : XmlModel<LectureList>
{
/// <summary>
/// Initializes a new instance of the <see cref="LectureApi" /> class.
/// </summary>
public LectureApi()
: base(new Uri(Constants.UrlLecture_ApiBaseAddr))
: base(ModelType.Feed, Constants.UrlLecture_ApiBaseAddr)
{
this.ValidRootName = Constants.LectureXmlValidRootName;
}

View File

@@ -26,6 +26,7 @@ namespace CampusAppWP8.Model
public XmlModel(ModelType modelType, string fileName, string url)
: base(modelType, fileName, url)
{
this.ValidRootName = Constants.XMLRootElementName;
}
/// <summary>
@@ -39,6 +40,11 @@ namespace CampusAppWP8.Model
{
}
/// <summary>
/// Gets or sets for the name of the root-tag
/// </summary>
protected string ValidRootName { get; set; }
/// <summary>
/// Create the model from a xml byte array.
/// </summary>
@@ -50,7 +56,7 @@ namespace CampusAppWP8.Model
string data = Encoding.UTF8.GetString(modelData, 0, modelData.Length);
T tempModel = XmlManager.DeserializationToModel<T>(data, Constants.XMLRootElementName);
T tempModel = XmlManager.DeserializationToModel<T>(data, this.ValidRootName);
if (tempModel != null)
{
this.Model = tempModel;

View File

@@ -167,10 +167,11 @@ namespace CampusAppWP8.Pages.Lecture
private void SendRequest(object sender, RoutedEventArgs e)
{
this.api = new LectureApi();
this.api.EventHandler.ApiIsReadyEvent += new ApiEventHandler.ApiReadyHandler(this.ApiIsReady);
this.api.onLoaded += new LectureApi.OnLoaded(this.ApiIsReady);
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
List<UrlParamModel> parameterList = this.CreateUrlParameter();
this.api.ApiGet(parameterList);
this.api.SetUriParams(parameterList);
this.api.LoadData();
}
/// <summary>