This commit is contained in:
stubbfel
2013-06-17 11:20:51 +02:00
parent f8f90ab247
commit 1c890fd43d

View File

@@ -1,12 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//-----------------------------------------------------------------------
// <copyright file="URLParamModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>17.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Utility
{
class URLParamModel
/// <summary>
/// This class is a Model for the URLParameter like GET-Parameter
/// </summary>
public class URLParamModel
{
#region Members
/// <summary>
/// Variable of the key
/// </summary>
private readonly string key;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="URLParamModel" /> class.
/// </summary>
/// <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>
/// <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>
public string Value { get; set; }
/// <summary>
/// Gets the key of the parameter
/// </summary>
public string Key
{
get
{
return this.key;
}
}
#endregion
#region Methods
/// <summary>
/// Method check if the parameter is valid
/// </summary>
/// <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>
/// <returns> return formatted string</returns>
public override string ToString()
{
if (!this.IsParamValid())
{
return string.Empty;
}
return "&" + this.key + "=" + this.Value;
}
#endregion
}
}