74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="AbstractHttpRequest.cs" company="BTU/IIT">
|
|
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
|
// </copyright>
|
|
// <author>Stubbfel</author>
|
|
// <date>15.10.2013</date>
|
|
// <summary>Implements the abstract HTTP request class</summary>
|
|
//-----------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Utility
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using CampusAppWPortalLib8.Model.Utility;
|
|
|
|
/// <summary> abstract Class provides some methods and member for HttpRequest. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
public abstract class AbstractHttpRequest
|
|
{
|
|
#region Member
|
|
|
|
/// <summary> BaseAddress of the webClient. </summary>
|
|
private string baseAddress;
|
|
|
|
#endregion
|
|
|
|
#region property
|
|
|
|
/// <summary> Gets or sets BaseAddress of the webClient. </summary>
|
|
/// <value> The base address. </value>
|
|
protected string BaseAddress
|
|
{
|
|
get
|
|
{
|
|
return this.baseAddress;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.baseAddress)
|
|
{
|
|
this.baseAddress = value;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary> Method create the Url for the http-get-method. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
/// <param name="parameters"> list of parameters. </param>
|
|
/// <returns> absolute API-Url include GetParameter. </returns>
|
|
public Uri CreateGetUrl(List<UrlParamModel> 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 = this.baseAddress + seperator + paramterStr;
|
|
return new Uri(getUrlStr, UriKind.Absolute);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|