Welcome 微信登录

首页 / 网页编程 / ASP.NET / System.Web.Routing命名空间代码解析(四)

System.Web.Routing命名空间代码解析(四)2012-01-22 博客园 Andrew YinRoute解析中用到的实体类,一些以"Segment”为名的类

先看类图:

1.PathSegment和PathSubSegment两个类是基类,没有任何代码,分别代表Route规则中Url片段("/"分隔的结果)和Url片段中的子片段("{"和"}"分隔的结果)。

2.SeparatorPathSegment类代表Route规则的Url中的"/",也没有任何代码

3.ContentPathSegment类与SeparatorPathSegment类相对应

其有两个属性,Subsegments存储其所包含的PathSubsegment,IsCatchAll表示其是否包含通配的PathSubsegment

  internal sealed class ContentPathSegment : PathSegment  {    // Methods    public ContentPathSegment(IList<PathSubsegment> subsegments)    {      this.Subsegments = subsegments;    }      // Properties    public bool IsCatchAll    {      get      {        return          this.Subsegments.Any(seg => ((seg is ParameterSubsegment) && ((ParameterSubsegment) seg).IsCatchAll));      }    }      public IList<PathSubsegment> Subsegments { get; private set; }  }