Orchard的Recipe是如何解析的
SetupService类
安装的时候先去发现Recipe:
1 | _recipeHarvester.HarvestRecipes("Orchard.Setup"); |
RecipeHarvester类
1 | /// <summary> |
RecipeParser类
1 | public Recipe ParseRecipe(string recipeText) { |
安装的时候就会通过在界面中选择的model.Recipe去Execute对应的Recipe.
RecipeManager类
1 | if (recipe == null) |
先把RecipeStep加入recipeStepQueue中,其实内部就是写入一个个文件
RecipeStepQueue类
1 | public void Enqueue(string executionId, RecipeStep step) { |
然后RecipeStepExecutor就去去执行各个Step
RecipeStepExecutor类
1 | public bool ExecuteNextStep(string executionId) { |
有没有发现 其实到最后是通过recipeHandler来处理的
我们来看看有多少Handler
FeatureRecipeHandler
CommandRecipeHandler
DataRecipeHandler
MetadataRecipeHandler
MigrationRecipHandler
ModuleRecipeHandler
SettingsRecipeHandler
ThemeRecipeHandler
看看FeatureRecipeHandler内部是怎么ExecuteRecipeStep的
FeatureRecipeHandler类
1 | // <Feature enable="f1,f2,f3" disable="f4" /> |
一开始判断RecipeStep.Name是不是Feature,不是就直接Return.
1 | foreach (var featureName in featuresToEnable) { |
随后去availableFeatures中判断是不是存在featuresToEnable中的某个feature。
1 | 然后去EnableFeatures. |
FeatureManager类
1 | _shellDescriptorManager.UpdateShellDescriptor(shellDescriptor.SerialNumber, enabledFeatures, |
我们先来看这两段代码:1
2ShellDescriptor shellDescriptor = _shellDescriptorManager.GetShellDescriptor();
List<ShellFeature> enabledFeatures = shellDescriptor.Features.ToList();