diff --git a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs
index ca175cbc..b36d20e2 100644
--- a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs
@@ -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;
-
+
///
/// Base model io handling class.
///
@@ -49,6 +51,11 @@ namespace CampusAppWP8
///
private Uri httpApiUri = null;
+ ///
+ /// Parameterized uri of the feed.
+ ///
+ private Uri paramizedUri = null;
+
///
/// Initializes a new instance of the class.
///
@@ -57,25 +64,27 @@ namespace CampusAppWP8
/// url of the feed
public MainModel(ModelType modelType, string fileName, string url)
{
- this.modelType = modelType;
+ this.Init(modelType, fileName, url);
+ }
- if ((url != null) && (url.Equals(string.Empty) == false))
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Model IO type
+ /// name of the file or the url of the feed
+ 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;
}
+ ///
+ /// Create the parameterized uri.
+ ///
+ /// uri parameter list
+ public void SetUriParams(List parameters)
+ {
+ if (this.api != null)
+ {
+ this.paramizedUri = this.api.CreateGetUrl(parameters);
+ }
+ }
+
+ ///
+ /// Clear the parameterized uri.
+ ///
+ public void ClearUriParams()
+ {
+ this.paramizedUri = null;
+ }
+
///
/// Abstract declaration of the model deserialize function.
///
@@ -380,6 +416,36 @@ namespace CampusAppWP8
return retValue;
}
+ ///
+ /// Initialize the class. Is called by the constructors.
+ ///
+ /// model IO type
+ /// name of the data file
+ /// url of the feed data
+ 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();
+ }
+ }
+
///
/// Initializes the file object.
///
@@ -402,7 +468,7 @@ namespace CampusAppWP8
if ((this.IsHttpApi() == true)
&& (this.api == null))
{
- this.api = new HttpRequest();
+ this.api = new HttpRequest(this.httpApiUri);
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs
index 4baedf31..7803e0e8 100644
--- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs
@@ -28,6 +28,17 @@ namespace CampusAppWP8.Model
{
}
+ ///
+ /// Initializes a new instance of the class.
+ /// Use only if the model io type is file or feed, not both.
+ ///
+ /// model io type
+ /// name of the file or the url of the feed
+ public XmlModel(ModelType modelType, string sourceName)
+ : base(modelType, sourceName)
+ {
+ }
+
///
/// Create the model from a xml byte array.
///
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml
index 692f5dec..b545f2dc 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml
@@ -37,7 +37,7 @@
-
+