Is the responsibility chain used in the .NET Framework?

I am trying to learn more about the responsibility chain design template. Each individual example that I see on the Internet gives the simplest example, for example, Logger, which writes another message to the Console, depending on which handler processes the request.

Are there any real life examples in the .NET Framework? I looked at the following links:

+4
source share
2 answers

ASP.NET Core -. - ( middleware), - , . :

Middleware - , . :

  • , .
  • .

, , , .

, .NET . .NET event ( ) . (, WPF, ) Handled . true , ( ) false, , - . .

0

. , , asp.net:

ASP.net:

- , , . , , . ASP.NET - , . ASP.NET API WebForms, - ASMX, WCF, ASP.NET Web API ASP.NET MVC HTTP . (, IHttpModule) (, IHttpHandler). , , . , . , , , . ASP.net :

public class SimpleHttpModule : IHttpModule 
{ 
  public SimpleHttpModule(){} 
  public String ModuleName 
  { 
    get { return "SimpleHttpModule"; } 
  } 
  public void Init(HttpApplication application) 
  { 
    application.BeginRequest +=  
    (new EventHandler(this.Application_BeginRequest)); 
    application.EndRequest +=  
    (new EventHandler(this.Application_EndRequest)); 
  } 
  private void Application_BeginRequest(Object source,  
  EventArgs e) 
  { 
    HttpApplication application = (HttpApplication)source; 
    HttpContext context = application.Context; 
    context.Response.Write(SomeHtmlString); 
  } 
  private void Application_EndRequest(Object source, EventArgs e) 
  { 
    HttpApplication application =      (HttpApplication)source; 
    HttpContext context = application.Context; 
    context.Response.Write(SomeHtmlString); 
  } 
  public void Dispose(){} 
} 

<configuration> 
  <system.web> 
    <httpModules> 
      <add name=" SimpleHttpModule " type=" SimpleHttpModule "/> 
    </httpModules> 
  </system.web> 
</configuration> 

ASP.NET HTTP , . HTTP- :

public class SimpleHttpHandler: IHttpHandler 
{ 
  public void ProcessRequest(System.Web.HttpContext context){ 
    context.Response.Write("The page request ->" +          
    context.Request.RawUrl.ToString()); 
  } 
  public bool IsReusable 
  { 
    get{ return true; } 
  } 
} 

. , ASP.NET .smp, ​​ SimpleHttpHandler:

<system.web> 
      <httpHandlers> 
        <add verb="*" path="*.smp" type="SimpleHttpHandler"/> 
      </httpHandlers> 
    </system.web> 

-, Java Servlets ( ), IIS ISAPI.

0

Source: https://habr.com/ru/post/1693791/


All Articles