Wojilu source code analysis-how to track and debug wojilu

Source: Internet
Author: User

The following is a simple look at wojilu source code, wojilu source code is very large, has not been carefully studied, said the wrong place please correct, so as to avoid mistakes.

In simple terms, the wojilu framework server is [the url is entered, and the html is displayed].

Code here: [wojilu1.8 \ wojilu \ Web \ Mvc \ ProcessContext. cs]

Public static void Begin (MvcContext ctx ){

WebStopwatch. Start ();

MvcEventPublisher. Instance. BeginProcessMvc (ctx );

List <ProcessorBase> processorList = initProcessor ();
ProcessContext context = new ProcessContext (ctx );
Foreach (ProcessorBase p in processorList ){

If (context. isEnd () break; // showEnd skips all the following processors except RenderProcessor

If (context. ctx. utils. GetCancelMvcProcessor (). Contains (p. GetType () continue; // cancelProcessor skips the specified Processor

P. Process (context );
Context. ctx. utils. skipCurrentProcessor (false); // reset status // skipCurrentProcessor skips the remaining portion of the current Processor
}

// Display the page content
If (skinRender (ctx) = false) new RenderProcessor (). Process (context );

Ctx. web. CompleteRequest ();

}

Here, we use the responsibility chain model mentioned in the design model. That is, each processor processes user requests sequentially and puts the processing results into ProcessContext. The processor following the process depends on the processing results of the previous processor.

All processor is here:

Private static List <ProcessorBase> initProcessor (){
List <ProcessorBase> list = new List <ProcessorBase> ();
List. Add (new RouteProcessor ());
List. Add (new InitContextProcessor ());
List. Add (new ActionMethodChecker ());
List. Add (new ForbiddenActionChecker ());
List. Add (new LoginActionChecker ());
List. Add (new HttpMethodChecker ());
List. Add (new PermissionChecker ());
List. Add (new ActionProcessor ());
List. Add (new LayoutProcessor ());
List. Add (new NsLayoutProcessor ());
Return list;
}

Render RenderProcessor on the last page.

The wojilu code is huge, and there are hundreds of controllers. Sometimes we don't know which controller we will go to after a link is clicked, so it is difficult to track and debug it. Here I found a simple method: In the Process method in the above ActionProcessor, [wojilu1.8 \ wojilu \ Web \ Mvc \ Processors \ ActionProcessor. cs], with a line of code, setControllerView (controller, actionMethod );

When a breakpoint is set, the controller Parameter displays the name of the controller, and the actionMethod displays the name of the method.

Let's just talk about it.

I will share my record with you later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.