76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="HttpRequest.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>10.06.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Utility
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using CampusAppWPortalLib8.Model.Utility;
|
|
|
|
/// <summary>
|
|
/// Class realize the access of restful HttpRequest
|
|
/// </summary>
|
|
public abstract class AbstractHttpRequest
|
|
{
|
|
#region Member
|
|
|
|
/// <summary>
|
|
/// BaseAddress of the webClient
|
|
/// </summary>
|
|
private string baseAddress;
|
|
|
|
#endregion
|
|
|
|
#region property
|
|
|
|
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>
|
|
/// <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
|
|
}
|
|
}
|