Beispiel #1
0
    /// <summary>
    /// 处理 HTML 范围
    /// </summary>
    /// <param name="context">当前 HTML 请求上下文</param>
    public void ProcessScope( HtmlRequestContext context )
    {
      Context = context;

      PreProcess();

      DataBind();


      if ( Request.HttpMethod.Equals( "GET" ) )
        ProcessGet();

      if ( Request.HttpMethod.Equals( "POST" ) )
        ProcessPost();


      PostProcess();
    }
Beispiel #2
0
 /// <summary>引发 Processing 事件</summary>
 protected virtual void OnProcessing( HtmlRequestContext context, IHtmlFilter[] filters )
 {
   foreach ( var filter in filters )
   {
     try
     {
       filter.OnProcessing( context );
     }
     catch { }
   }
 }
Beispiel #3
0
 /// <summary>引发 Rendered 事件</summary>
 protected virtual void OnRendered( HtmlRequestContext context, IHtmlFilter[] filters )
 {
   foreach ( var filter in filters.Reverse() )
   {
     try
     {
       filter.OnRendered( context );
     }
     catch { }
   }
 }
Beispiel #4
0
    /// <summary>
    /// 派生类重写此方法接管 HTTP 请求处理流程
    /// </summary>
    /// <param name="context">当前 HTML 请求上下文</param>
    /// <param name="handler">用于处理 HTML 文档的处理程序</param>
    /// <returns>处理后的结果</returns>
    protected virtual ICachedResponse ProcessRequest( HtmlRequestContext context, IHtmlHandler handler )
    {

      var filters = GetFilters( context.VirtualPath );



      OnProcessing( context, filters );

      Trace( "Begin process document." );
      handler.ProcessScope( context );
      Trace( "End process document." );

      OnProcessed( context, filters );




      OnRendering( context, filters );

      Trace( "Begin render document." );
      string content;
      using ( StringWriter writer = new StringWriter() )
      {
        context.Scope.RenderChilds( writer, GetAdapters( handler ) );
        content = writer.ToString();
      }

      Trace( "End render document." );

      OnRendered( context, filters );

      return CreateResponse( content );
    }