apppagecounter.cs

来自「投票系统模块设计」· CS 代码 · 共 49 行

CS
49
字号
using System;
using System.Web;

namespace Common
{
	/// <summary>
	/// AppPageCounter 的摘要说明。
	/// </summary>
	public class AppPageCounter : IPageCounter
	{
		public AppPageCounter()
		{
			if (HttpContext.Current.Application["PageCount"] == null)
			{
				HttpContext.Current.Application.Add("PageCount", 0);
			}
		}
		#region IPageCounter 成员

		public int GetPageCount()
		{
			return (int)HttpContext.Current.Application["PageCount"];
		}

		public void SetPageCount(int iCount)
		{
			HttpContext.Current.Application.Lock();
			if (HttpContext.Current.Application["PageCount"] == null)
			{
				HttpContext.Current.Application.Add("PageCount", 0);
			}
			else
			{
				HttpContext.Current.Application["PageCount"] = iCount;
			}
			HttpContext.Current.Application.UnLock();
		}

		public void IncreasePageCount()
		{
			HttpContext.Current.Application.Lock();
			HttpContext.Current.Application["PageCount"] = GetPageCount() + 1;
			HttpContext.Current.Application.UnLock();
		}

		#endregion
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?