//----------------------------------------------------------------------- // // The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // // Stubbfel // 15.10.2013 // Implements the URL parameter model class //----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Utility { /// This class is a Model for the URLParameter like GET-Parameter. /// Stubbfel, 15.10.2013. public class UrlParamModel { #region Members /// Variable of the key. protected readonly string key; #endregion #region Constructor /// Initializes a new instance of the class. /// Stubbfel, 15.10.2013. /// the key for the parameter. public UrlParamModel(string key) { this.key = key; } /// Initializes a new instance of the class. /// Stubbfel, 15.10.2013. /// the key for the parameter. /// value of the parameter. public UrlParamModel(string key, string value) { this.key = key; this.Value = value; } #endregion #region Proberty /// Gets or sets the value of the Parameter. /// The value. public string Value { get; set; } /// Gets the key of the parameter. /// The key. public string Key { get { return this.key; } } /// Gets the token, which indicate that the parameterList started. /// The parameter token. public virtual string ParamToken { get { return "?"; } } #endregion #region Methods /// Method check if the parameter is valid. /// Stubbfel, 15.10.2013. /// true if is it valid, otherwise false. public virtual bool IsParamValid() { if (this.key == null || string.Empty.Equals(this.key) || string.Empty.Equals(this.Value)) { return false; } return true; } /// Method return a formatted string like Key=Value. /// Stubbfel, 15.10.2013. /// public override string ToString() { if (!this.IsParamValid()) { return string.Empty; } return "&" + this.key + "=" + this.Value; } #endregion } }