打印本文 打印本文 关闭窗口 关闭窗口
[ASP.NET]重构Session确实让代码简洁干净了不少
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3467  更新时间:2009/4/23 10:39:09  文章录入:mintao  责任编辑:mintao
    {
      //get the value
      object oValue = GetValue( eKey );

      //value not found or null?
      if (null == oValue)
      {
        //return default value
        return oDefaultValue;
      }

      //everything oke: return session value
      return oValue;
    }
    #endregion
    private: GetMandatoryValue( eKeys eKey )#region private: GetMandatoryValue( eKeys eKey )
    /**//// <summary>
    /// Returns the session value for a session-key that must exist.
    /// If the key does not exist an applicationException is thrown.
    /// </summary>
    /// <param name="eKey"> The session-key to return the session-value for. </param>
    /// <returns> A none-null value.</returns>
    private static object GetMandatoryValue( eKeys eKey )
    {
      //get the value
      object oValue = GetValue( eKey );

      //key not found or value null?
      if ( null == oValue )
      {
        //throw applicationException because its application logic error (none CLR)
        throw new ApplicationException ( String.Format( sMANDATORY_SESSION_KEY_NOT_FOUND_MSG, eKey.ToString() ));
      }

      //everything oke: return value
      return oValue;

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口