温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:UrlReWrite(Url重写或伪静态)完美示例源码
当前文件:
UrlReWriter/UrlRewriter/URLRewriter.Config.cs[2K,2009-6-12 11:57:50],打开代码结构图
UrlReWriter/UrlRewriter/URLRewriter.Config.cs[2K,2009-6-12 11:57:50],打开代码结构图1using System; 2
using System.Configuration; 3
using System.Collections; 4
5
namespace URLRewriter.Config 6
{ 7
// Define a custom section containing a simple element and a collection of the same element. 8
// It uses two custom types: UrlsCollection and UrlsConfigElement. 9
public class UrlsConfig 10
{ 11
public static UrlsSection GetConfig() 12
{ 13
return (UrlsSection)System.Configuration.ConfigurationManager.GetSection("CustomConfiguration"); 14
} 15
16
} 17
18
19
public class UrlsSection : ConfigurationSection 20
{ 21
[ConfigurationProperty("urls",IsDefaultCollection = false)] 22
public UrlsCollection Urls 23
{ 24
get 25
{ 26
return (UrlsCollection)this["urls"]; 27
} 28
} 29
} 30
31
// Define the UrlsCollection that contains UrlsConfigElement elements. 32
public class UrlsCollection : ConfigurationElementCollection 33
{ 34
protected override ConfigurationElement CreateNewElement() 35
{ 36
return new UrlConfigElement(); 37
} 38
protected override Object GetElementKey(ConfigurationElement element) 39
{ 40
return ((UrlConfigElement)element).VirtualUrl; 41
} 42
43
public UrlConfigElement this[int index] 44
{ 45
get 46
{ 47
return (UrlConfigElement)BaseGet(index); 48
} 49
} 50
51
} 52
53
// Define the UrlConfigElement. 54
public class UrlConfigElement : ConfigurationElement 55
{ 56
57
58
[ConfigurationProperty("virtualUrl", IsRequired = true)] 59
public string VirtualUrl 60
{ 61
get 62
{ 63
return (string)this["virtualUrl"]; 64
} 65
set 66
{ 67
this["virtualUrl"] = value; 68
} 69
} 70
71
[ConfigurationProperty("destinationUrl", IsRequired = true)] 72
public string DestinationUrl 73
{ 74
get 75
{ 76
return (string)this["destinationUrl"]; 77
} 78
set 79
{ 80
this["destinationUrl"] = value; 81
} 82
} 83
} 84
}






}
}