diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 1c76561c..30b3410b 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -206,8 +206,6 @@ Constants.resx - - @@ -221,7 +219,6 @@ Code - diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs index c8d9c1a2..186f6d61 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/URLParamModel.cs @@ -60,6 +60,17 @@ namespace CampusAppWP8.Model.Utility return this.key; } } + + /// + /// Gets or sets the token, which indicate that tha paramterlist started + /// + public string ParamToken + { + get + { + return "?"; + } + } #endregion #region Methods diff --git a/CampusAppWP8/CampusAppWP8/Utility/Api.cs b/CampusAppWP8/CampusAppWP8/Utility/Api.cs deleted file mode 100644 index a0178de8..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/Api.cs +++ /dev/null @@ -1,144 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 19.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System; - using System.Collections.Generic; - using System.Net; - using CampusAppWP8.Model.Utility; - - /// - /// This abstract Class is for API - /// - /// Type for model of the API - public abstract class Api : HttpRequest - { - #region Members - - /// - /// EventHandler of the API - /// - private readonly ApiEventHandler eventHandler; - - /// - /// The model of the API - /// - private T model; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// BaseUrl of the API - public Api(Uri apiBaseAddress) - : base(apiBaseAddress) - { - this.eventHandler = new ApiEventHandler(); - } - - #endregion - - #region Proberty - - /// - /// Gets or sets for the model of the API - /// - public T Model - { - get - { - return this.model; - } - - set - { - if ((value == null && this.model != null) || !value.Equals(this.model)) - { - this.model = value; - } - } - } - - /// - /// Gets for the event-handler of the API - /// - public ApiEventHandler EventHandler - { - get { return this.eventHandler; } - } - #endregion - - #region Methods - - #region public - - /// - /// Method send an HTTP-Get for an API - /// - /// list of GetParameter - public void ApiGet(List parameters) - { - Uri getUrl = this.CreateGetUrl(parameters); - this.HttpGet(getUrl, this.DownloadCompleted); - } - #endregion - - #region protected - - /// - /// Method implement the deserialization a Xml-API - /// - /// content of the API - protected abstract void Deserialization(string xmlString); - - #endregion - - #region private - - /// - /// Method create the model of the API - /// - /// content of the API - private void CreateModel(string resultString) - { - if (resultString == null || resultString == string.Empty) - { - return; - } - - this.Deserialization(resultString); - this.EventHandler.FireApiReadyevent(); - } - - /// - /// Method will be execute if the download of the API is completed and create the model - /// - /// Sender of the event - /// Arguments of the event - private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e) - { - Exception downloadError = e.Error; - if (downloadError != null) - { - return; - } - - string downloadResult = e.Result; - if (downloadResult != null && !downloadResult.Equals(string.Empty)) - { - this.CreateModel(downloadResult); - } - } - #endregion - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs b/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs deleted file mode 100644 index ddb1baaa..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/ApiEventHandler.cs +++ /dev/null @@ -1,47 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 17.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - /// - /// This class handle the events of a API - /// - public class ApiEventHandler - { - /// - /// Initializes a new instance of the class. - /// - public ApiEventHandler() - { - } - - #region Delegate&Events - /// - /// Delegate for the ready event - /// - public delegate void ApiReadyHandler(); - - /// - /// The ready event - /// - public event ApiReadyHandler ApiIsReadyEvent; - - #endregion - - #region Method - - /// - /// Method fire a ready event - /// - public void FireApiReadyevent() - { - this.ApiIsReadyEvent(); - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs index 665a004f..859a8982 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs @@ -68,12 +68,18 @@ namespace CampusAppWP8.Utility public Uri CreateGetUrl(List parameters) { string paramterStr = string.Empty; + string seperator = string.Empty; foreach (UrlParamModel parameter in parameters) { + if (string.Empty.Equals(seperator)) + { + seperator = parameter.ParamToken; + } + paramterStr += parameter.ToString(); } - string getUrlStr = baseAddress + "?" + paramterStr; + string getUrlStr = baseAddress + seperator + paramterStr; return new Uri(getUrlStr, UriKind.Absolute); } diff --git a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs deleted file mode 100644 index 2f1aa0e3..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs +++ /dev/null @@ -1,84 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 13.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System; - using System.Collections.Generic; - using System.Net; - using CampusAppWP8.Model.Utility; - using CampusAppWP8.Resources; - - /// - /// This abstract Class is for Xml-API - /// - /// Type for model of the API - public abstract class XmlApi : Api - { - #region Members - - /// - /// Variable for the name of the root-tag - /// - private string validRootName; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// BaseUrl of the API - public XmlApi(Uri apiBaseAddress) - : base(apiBaseAddress) - { - this.validRootName = Constants.XMLRootElementName; - } - - #endregion - - #region Proberty - - /// - /// Gets or sets the ValidRootName of the API - /// - protected string ValidRootName - { - get - { - return this.validRootName; - } - - set - { - if (value != this.validRootName) - { - this.validRootName = value; - } - } - } - - #endregion - - #region Methods - - /// - /// Method implement the deserialization a Xml-API - /// - /// content of the API - protected override void Deserialization(string xmlString) - { - T model = XmlManager.DeserializationToModel(xmlString, this.ValidRootName); - if (model != null) - { - this.Model = model; - } - } - #endregion - } -}