基本信息
源码名称:asp.net 博客系统源码下载,附数据库文件
源码大小:6.65M
文件格式:.zip
开发语言:C#
更新时间:2013-09-03
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
c# blog系统源码 包含数据库文件

using System;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.Web;
using System.Reflection;

namespace Dottext.Common.UrlManager
{

	public enum HandlerType
	{
		Direct,
		Factory,
		Page
	};

	/// <summary>
	/// Summary description for HttpHandler.
	/// </summary>
	public class HttpHandler
	{
		public HttpHandler()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		private readonly object HandlerLock = new object();

		private string _pattern;
		[XmlAttribute("pattern")]
		public string Pattern
		{
			get {return this._pattern;}
			set {this._pattern = value;}
		}

		private string _type;
		[XmlAttribute("type")]
		public string Type
		{
			get {return this._type;}
			set {this._type = value;}
		}

		private string _PageLocation;
		[XmlAttribute("pageLocation")]
		public string PageLocation
		{
			get {return this._PageLocation;}
			set {this._PageLocation = value;}
		}

		private string _fullPageLocation;
		public string FullPageLocation
		{
			get 
			{
				if(this._fullPageLocation == null && PageLocation != null)
				{
					this._fullPageLocation = HttpContext.Current.Server.MapPath("~/"   PageLocation);
				}
				return this._fullPageLocation;
			}
		}

		private string _controls;
		[XmlAttribute("controls")]
		public string Controls
		{
			get {return this._controls;}
			set {this._controls = value;}
		}

		public string[] BlogControls
		{
			get
			{
				if(this.Controls != null)
				{
					return this.Controls.Split(',');
				}
				return null;
			}
		}

		private Type _httpHanlderType;
		public Type HttpHanlderType
		{
			get 
			{
				if(this._httpHanlderType == null)
				{
					lock(HandlerLock)
					{
						if(this._httpHanlderType == null)
						{
							this._httpHanlderType = System.Type.GetType(Type);
						}
					}
				}
				return this._httpHanlderType;
			}		
		}

		private ConstructorInfo constructor = null;
		public object Instance()
		{
			if(constructor == null)
			{
				lock(HandlerLock)
				{
					if(constructor == null)
					{
						System.Type t = System.Type.GetType(this.Type);
						constructor = t.GetConstructor(new Type[0]);
					}
				}
			}
			return constructor.Invoke(null);
		}

		private Regex _urlRegex;
		//Will throw an exception without Ignore Attribute..err...
		//Cache the Regex so that it does not have to be constantly recreated. This will also allow us to use Compiled expressions as well.
		[XmlIgnoreAttribute]
		public Regex UrlRegex
		{
			//Should we add a check here for a null Pattern. We will throw an exception if the Pattern is null...but not much else we can
			//do about it either
			get
			{
				if(_urlRegex == null)
				{
					if(Dottext.Framework.Configuration.Config.Settings.UrlFormat.ToLower()!="aspx")
					{
						this.Pattern=Regex.Replace(this.Pattern,"aspx","(aspx|" Dottext.Framework.Configuration.Config.Settings.UrlFormat ")",RegexOptions.IgnoreCase);
					}
					_urlRegex = new Regex(this.Pattern,RegexOptions.IgnoreCase|RegexOptions.Compiled);
				}
				return _urlRegex;
			}
		}

		public bool IsMatch(string url)
		{
			return UrlRegex.IsMatch(url);
		}


		private HandlerType _handlerType = HandlerType.Page;
		[XmlAttribute("handlerType")]
		public HandlerType HandlerType
		{
			get {return this._handlerType;}
			set {this._handlerType = value;}
		}
	}
}