Merge branch 'release/#109' into develmaster
This commit is contained in:
@@ -8,11 +8,13 @@
|
||||
namespace CampusAppWP8
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using CampusAppWP8.Model.Utility;
|
||||
using CampusAppWP8.Utility;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Base model io handling class.
|
||||
/// </summary>
|
||||
@@ -49,6 +51,11 @@ namespace CampusAppWP8
|
||||
/// </summary>
|
||||
private Uri httpApiUri = null;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterized uri of the feed.
|
||||
/// </summary>
|
||||
private Uri paramizedUri = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MainModel{T}" /> class.
|
||||
/// </summary>
|
||||
@@ -57,25 +64,27 @@ namespace CampusAppWP8
|
||||
/// <param name="url">url of the feed</param>
|
||||
public MainModel(ModelType modelType, string fileName, string url)
|
||||
{
|
||||
this.modelType = modelType;
|
||||
this.Init(modelType, fileName, url);
|
||||
}
|
||||
|
||||
if ((url != null) && (url.Equals(string.Empty) == false))
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MainModel{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="modelType">Model IO type</param>
|
||||
/// <param name="sourceName">name of the file or the url of the feed</param>
|
||||
public MainModel(ModelType modelType, string sourceName)
|
||||
{
|
||||
if (modelType == ModelType.File)
|
||||
{
|
||||
this.httpApiUri = new Uri(url, UriKind.Absolute);
|
||||
this.Init(modelType, sourceName, string.Empty);
|
||||
}
|
||||
|
||||
this.fileName = fileName;
|
||||
|
||||
if ((this.IsFile() == true)
|
||||
&& (fileName.Equals(string.Empty) == false))
|
||||
else if (modelType == ModelType.Feed)
|
||||
{
|
||||
this.InitFile(CampusAppWP8.Utility.File.IOTypeRead.ReadSync, CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync);
|
||||
this.Init(modelType, string.Empty, sourceName);
|
||||
}
|
||||
|
||||
if ((this.IsHttpApi() == true)
|
||||
&& (url.Equals(string.Empty) == false))
|
||||
else
|
||||
{
|
||||
this.InitHttpApi();
|
||||
throw new NotSupportedException("Wrong constructor was called for Feed and File support.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +281,14 @@ namespace CampusAppWP8
|
||||
|
||||
if (loadFromFile == false)
|
||||
{
|
||||
this.api.HttpGet(this.httpApiUri, this.OnLoadDataComplete);
|
||||
if (this.paramizedUri != null)
|
||||
{
|
||||
this.api.HttpGet(this.paramizedUri, this.OnLoadDataComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.api.HttpGet(this.httpApiUri, this.OnLoadDataComplete);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -335,6 +351,26 @@ namespace CampusAppWP8
|
||||
return this.model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the parameterized uri.
|
||||
/// </summary>
|
||||
/// <param name="parameters">uri parameter list</param>
|
||||
public void SetUriParams(List<UrlParamModel> parameters)
|
||||
{
|
||||
if (this.api != null)
|
||||
{
|
||||
this.paramizedUri = this.api.CreateGetUrl(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the parameterized uri.
|
||||
/// </summary>
|
||||
public void ClearUriParams()
|
||||
{
|
||||
this.paramizedUri = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Abstract declaration of the model deserialize function.
|
||||
/// </summary>
|
||||
@@ -380,6 +416,36 @@ namespace CampusAppWP8
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the class. Is called by the constructors.
|
||||
/// </summary>
|
||||
/// <param name="modelType">model IO type</param>
|
||||
/// <param name="fileName">name of the data file</param>
|
||||
/// <param name="url">url of the feed data</param>
|
||||
private void Init(ModelType modelType, string fileName, string url)
|
||||
{
|
||||
this.modelType = modelType;
|
||||
|
||||
if ((url != null) && (url.Equals(string.Empty) == false))
|
||||
{
|
||||
this.httpApiUri = new Uri(url, UriKind.Absolute);
|
||||
}
|
||||
|
||||
this.fileName = fileName;
|
||||
|
||||
if ((this.IsFile() == true)
|
||||
&& (fileName.Equals(string.Empty) == false))
|
||||
{
|
||||
this.InitFile(CampusAppWP8.Utility.File.IOTypeRead.ReadSync, CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync);
|
||||
}
|
||||
|
||||
if ((this.IsHttpApi() == true)
|
||||
&& (url.Equals(string.Empty) == false))
|
||||
{
|
||||
this.InitHttpApi();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the file object.
|
||||
/// </summary>
|
||||
@@ -402,7 +468,7 @@ namespace CampusAppWP8
|
||||
if ((this.IsHttpApi() == true)
|
||||
&& (this.api == null))
|
||||
{
|
||||
this.api = new HttpRequest();
|
||||
this.api = new HttpRequest(this.httpApiUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,17 @@ namespace CampusAppWP8.Model
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="XmlModel{T}" /> class.
|
||||
/// Use only if the model io type is file or feed, not both.
|
||||
/// </summary>
|
||||
/// <param name="modelType">model io type</param>
|
||||
/// <param name="sourceName">name of the file or the url of the feed</param>
|
||||
public XmlModel(ModelType modelType, string sourceName)
|
||||
: base(modelType, sourceName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the model from a xml byte array.
|
||||
/// </summary>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<lui:NavigateButton Name="EventItem" QuerryStringValue="{Binding Index}" Url="{Binding Path=Constants.PathEvent_EventPage, Source={StaticResource Const}}" QuerryStringName="{Binding Path=Constants.ParamPivotIndex, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Title}" />
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Title}"/>
|
||||
</lui:NavigateButton>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
Reference in New Issue
Block a user