sp; /// By using an approach like this you improve the protection and encapsulation of existing code.
/// It offers a simple, low-risk, easy manageable way to improve existing WebApplication.
/// Therfore, I call it webRefactoring.
/// </summary>
public class CurrentSession
{
Constants#region Constants
private const String sMANDATORY_SESSION_KEY_NOT_FOUND_MSG = "Session variable excepted but does not exist. Key={0}";
private const String sMANDATORY_SESSION_VALUE_INVALID_NULL = "None null session value excepted. Key={0}";
private const Int32 nUSERID_UNKOWN = -1;
private const Int32 nUSERID_MINIMUM = 1;
private const String sUSERID_INVALID = "Invalid UserID:{0}. UserID should be larger than:{1}";
#endregion
UserID#region UserID
/**//// <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, va
/// It offers a simple, low-risk, easy manageable way to improve existing WebApplication.
/// Therfore, I call it webRefactoring.
/// </summary>
public class CurrentSession
{
Constants#region Constants
private const String sMANDATORY_SESSION_KEY_NOT_FOUND_MSG = "Session variable excepted but does not exist. Key={0}";
private const String sMANDATORY_SESSION_VALUE_INVALID_NULL = "None null session value excepted. Key={0}";
private const Int32 nUSERID_UNKOWN = -1;
private const Int32 nUSERID_MINIMUM = 1;
private const String sUSERID_INVALID = "Invalid UserID:{0}. UserID should be larger than:{1}";
#endregion
UserID#region UserID
/**//// <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, va
| 对此文章发表了评论 |

