100 lines
3.1 KiB
C#
100 lines
3.1 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="URLParamModel.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 URL parameter model class</summary>
|
|
//-----------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Model.Utility
|
|
{
|
|
/// <summary> This class is a Model for the URLParameter like GET-Parameter. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
public class UrlParamModel
|
|
{
|
|
#region Members
|
|
|
|
/// <summary> Variable of the key. </summary>
|
|
protected readonly string key;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="UrlParamModel" /> class. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
/// <param name="key"> the key for the parameter. </param>
|
|
public UrlParamModel(string key)
|
|
{
|
|
this.key = key;
|
|
}
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="UrlParamModel" /> class. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
/// <param name="key"> the key for the parameter. </param>
|
|
/// <param name="value"> value of the parameter. </param>
|
|
public UrlParamModel(string key, string value)
|
|
{
|
|
this.key = key;
|
|
this.Value = value;
|
|
}
|
|
#endregion
|
|
|
|
#region Proberty
|
|
|
|
/// <summary> Gets or sets the value of the Parameter. </summary>
|
|
/// <value> The value. </value>
|
|
public string Value { get; set; }
|
|
|
|
/// <summary> Gets the key of the parameter. </summary>
|
|
/// <value> The key. </value>
|
|
public string Key
|
|
{
|
|
get
|
|
{
|
|
return this.key;
|
|
}
|
|
}
|
|
|
|
/// <summary> Gets the token, which indicate that the parameterList started. </summary>
|
|
/// <value> The parameter token. </value>
|
|
public virtual string ParamToken
|
|
{
|
|
get
|
|
{
|
|
return "?";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary> Method check if the parameter is valid. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
/// <returns> true if is it valid, otherwise false. </returns>
|
|
public virtual bool IsParamValid()
|
|
{
|
|
if (this.key == null || string.Empty.Equals(this.key) || string.Empty.Equals(this.Value))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary> Method return a formatted string like Key=Value. </summary>
|
|
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
|
/// <seealso cref="M:System.Object.ToString()"/>
|
|
public override string ToString()
|
|
{
|
|
if (!this.IsParamValid())
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return "&" + this.key + "=" + this.Value;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|