Orchard Source exploration: Module,theme,core Extended Load Overview

Source: Internet
Author: User
Tags foreach readfile

1. Host. Initialize ();

private static Iorchardhost Hostinitialization (HttpApplication application) {
     var host = Orchardstarter.createhost (mvcsingletons);
     Host. Initialize ();
     Initialize shells to speed up the the "the
    " the "the" BeginRequest ();
    Host. EndRequest ();
    return host;
}

Orchard as an extensible CMS system, you need to load modules (Modules) or themes (Themes) at initialization or runtime, which are collectively called Extensions (Extensions).

Host. Initialize ();
Called Once on startup to configure app domain, and load/apply existing shell configuration
setupextensions ();//In Initial The extension is set monitorextensions () when a new extension is added, the extension is removed, and the expansion
source is modified, the extension loader (Extension Loader) needs to be notified to reload or perform some cleanup work, so monitoring is required:
createandactivateshells ();//orchard is a multi-tenant (tenant) system, which is what we typically call a subweb, which allows a orchard application to contain multiple subwebs of different domain names. Each subweb corresponds to a shell that needs to be created and activated.

1.SetupExtensions

Loads all extensions and determines whether the application domain needs to be restarted. Involves the CacheManager class: Todo

Iparallelcachecontext Class: Parallel Cache Class

Orchard includes three kinds of extensions: Core,theme,module.

Folder. Availableextensions ()
harvestextensions (...)
Looking for extensions
private list<extensiondescriptor> availableextensionsinfolder (string path, string ExtensionType, String manifestname, bool manifestisoptional)
var descriptor = getextensiondescriptor (path, Extensionid, ExtensionType, Manifestpath, manifestisoptional);
_websitefolder.readfile (Manifestpath);

Traced to the File.Open. There are many classes and functions that are ignored in this process, and only the main thread is noticed, and that is the process of loading the extensions. If you are stuck with too much detail halfway, you will find that time is a bottomless pit. Later on in this process some of the typical problems to comb, to achieve the French 烣 烣.

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/

2.MonitorExtensions

When extension changes or additions are made, a new or changed extension needs to be reloaded by setting the _current value to NULL to cause the extended load coordination class to notify the orchard.

 public void Monitorextensionswork (Action<ivolatiletoken> monitor) {logger.information ("Start Monitor
         ing extension files ... ");
         Monitor Add/remove of any module/theme logger.debug ("Monitoring virtual path \" {0}\ "", "~/modules");
         Monitor (_virtualpathmonitor.whenpathchanges ("~/modules"));
         Logger.debug ("Monitoring virtual path \" {0}\ "", "~/themes");
         Monitor (_virtualpathmonitor.whenpathchanges ("~/themes")); Give loaders a chance to monitor any additional changes var extensions = _extensionmanager.availableextensions (). Where (d => defaultextensiontypes.ismodule (d.extensiontype) | | Defaultextensiontypes.istheme (D.extensiontype)).
         ToList (); foreach (var extension in extensions) {foreach (var loader in _loaders) {loader.
             Monitor (extension, monitor);
     } logger.information ("Done monitoring extension files ..."); }

3.CreateAndActivateShells

Load all subwebs and activate their shell.

Ienumerable<shellsettings> ishellsettingsmanager.loadsettings ();
 Private Const string _settingsfilename = "Settings.txt";
 Private Ienumerable<shellsettings> loadsettingsinternal () {
         var filepaths = _appdatafolder
             . Listdirectories ("Sites")
             . SelectMany (Path => _appdatafolder.listfiles (path))
             . Where (Path => string.equals (path.getfilename (path), _settingsfilename, StringComparison.OrdinalIgnoreCase));
         foreach (Var filePath in filepaths) {
             yield return shellsettingsserializer.parsesettings _appdatafolder.readfile ( FilePath));
         }
     

is clearly divided into two steps, one step is through the App_Data folder Setting.txt load all subwebs of the configuration is also deserialization, the second step of Activateshell (context);

Orchard.Environment.DefaultOrchardHost:IOrchardHost, Ishellsettingsmanagereventhandler, Ishelldescriptormanagereventhandler

The Orchard.Environment.IOrchardHost (Defaultorchardhost) object is used to initialize the configuration of the program domain and shell (corresponding to one shell per subweb), loading or reloading existing modules or extensions.

The world is yours and ours, but it is theirs in the final analysis.

Author: cnblogs, political and political sugar

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.