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 eitherget{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;}}}}
评论