打印本文 打印本文 关闭窗口 关闭窗口
[ASP.NET]重构Session确实让代码简洁干净了不少
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3467  更新时间:2009/4/23 10:39:09  文章录入:mintao  责任编辑:mintao
    /**//// <summary>
    /// Returns the userID as a Int32 instead of an object.
    /// This way you will get the compiler protection and intelligence support you need.
    /// </summary>
    public static Int32 UserID
    {
      get 
      {
        return (Int32) GetValueOrDefault( eKeys.UserID, nUSERID_UNKOWN );
      }
      set
      {
        if ( nUSERID_MINIMUM >= value )
        {
          throw new ApplicationException ( String.Format(sUSERID_INVALID, value, nUSERID_MINIMUM ));
        }
        SetValue( eKeys.UserID, value );
      }
    }
    #endregion

    private: GetValueOrDefault( eKeys eKey, Object oDefaultValue )#region private: GetValueOrDefault( eKeys eKey, Object oDefaultValue )
    /**//// <summary>
    /// Gets the value from the session object.
    /// </summary>
    /// <param name="eKey"> The session key to get the value for.</param>
    /// <param name="oDefaultValue">The default value to use if no valid value stored.</param>
    /// <returns>When the value is null or the key does not exist, 
    /// the specified default value is returned. 
    /// Otherwise, the value is returned</returns>
    private static object GetValueOrDefault( eKeys eKey, Object oDefaultValue )

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

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