快速业务通道

System.Web.Routing凋兆腎寂旗鷹盾裂?眉? RouteCollection窃

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-05-19

RouteCollection窃写覚噐Collection<RouteBase>旺拝淫廾阻匯倖Dictionary<string, RouteBase>?噐頁万戻工阻屈宀議孔嬬。

宥狛賀心旗鷹厘断辛參岑祇?Collection嶄才Dictionary嶄議方象旺音頼畠?揖。

1.嗤Name議Route屡贋噐D嶄嗽贋噐C嶄?旺拝辛參宥狛沫哈奉來宥狛Name殊沫?歌心Add圭隈?

2.短嗤Name議Route峪贋噐C嶄

3.評茅Route議扮昨?泌惚D嶄匆贋壓万?夸貫D嶄匆評茅?歌心RemoveItem圭隈?

4.譜崔Route議扮昨?泌惚D嶄匆贋壓万?夸貫D嶄匆評茅(歌心SetItem圭隈?宸泣俶勣蒙艶廣吭)

宸倖窃嶄婢?阻匯嶽載挫議迄字崙?萩歌心旗鷹嶄議仔弼互疏何蛍?

云窃嶄議凪麿圭隈參朔氏壓 Route窃?和?嶄讐。

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Security.Permissions;
using System.Threading;
using System.Web;
using System.Web.Hosting;
  
namespace System.Web.Routing
{
  [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal),
   AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  public class RouteCollection : Collection<RouteBase>
  {
    // Fields
    private Dictionary<string, RouteBase> _namedMap;
    private ReaderWriterLock _rwLock;
    private VirtualPathProvider _vpp;
  
    // Methods
    public RouteCollection()
      : this(HostingEnvironment.VirtualPathProvider) {}
  
    public RouteCollection(VirtualPathProvider virtualPathProvider)
    {
      this._namedMap = new Dictionary<string, RouteBase>(StringComparer.OrdinalIgnoreCase);
      this._rwLock = new ReaderWriterLock();
      this._vpp = virtualPathProvider;
    }
  
    public void Add(string name, RouteBase item)
    {
      if (item == null)
        throw new ArgumentNullException("item");
      if (!string.IsNullOrEmpty(name) && this._namedMap.ContainsKey(name))
        throw new ArgumentException(
          string.Format(CultureInfo.CurrentUICulture, RoutingResources.RouteCollection_DuplicateName,
                 new object[] {name}), "name");
      base.Add(item);
      if (!string.IsNullOrEmpty(name))
        this._namedMap[name] = item;
    }
  
    protected override void ClearItems()
    {
      this._namedMap.Clear();
      base.ClearItems();
    }
  
    private RequestContext GetRequestContext(RequestContext requestContext)
    {
      if (requestContext != null)
        return requestContext;
      HttpContext current = HttpContext.Current;
      if (current == null)
        throw new InvalidOperationException(RoutingResources.RouteCollection_RequiresContext);
      return new RequestContext(new HttpContextWrapper(current), new RouteData());
    }
  
    public RouteData GetRouteData(HttpContextBase httpContext)
    {
      if (httpContext == n

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号