1

我们试图通过阅读 Bertrand Le Roy的这篇博文来了解 Orchard 请求的生命周期。我们能够单步执行代码并创建第一段的图表,该图表描述了为特定路线创建形状。好的。

第一段时序图

在此处输入图像描述

第一段的相关代码

public ActionResult Display(int id) {
    var contentItem = 
        _contentManager.Get(id, VersionOptions.Published);

    if (contentItem == null)
        return HttpNotFound();

    if (!Services.Authorizer.Authorize(Permissions.ViewContent, 
            contentItem, 
            T("Cannot view content"))) {
        return new HttpUnauthorizedResult();
    }

    dynamic model = _contentManager.BuildDisplay(contentItem);
    return new ShapeResult(this, model);
}

在第三段中我们被卡住了

在博文的第三段中,Bertrand 谈到了布局形状。

此时工作上下文中已经存在一个非常重要的形状,那就是布局形状。

好的。所以它已经存在了。它是什么时候创建的,创建它的代码在哪里?

4

1 回答 1

0

Betrand Le Roy 在codeplex 讨论中回答。

[布局形状] 由工作上下文在第一次需要时创建(查看那里的 Layout 属性访问器)。

他的回答是指这段代码:

public dynamic Layout {
    get { return GetState<object>("Layout"); }
    set { SetState("Layout", value); }
}
于 2013-04-30T18:02:21.820 回答