/// <summary> /// 当模块类型上标有 <see cref="AppModulePrepareArguments"/> 时,调用 <see cref="AppModulePrepairAttribute.Prepair(AppModulePrepareArguments)"/> /// </summary> /// <param name="type"></param> /// <param name="arguments"></param> private void InvokePrepairWhenTypeHasAppModulePrepairAttribute(Type type, AppModulePrepareArguments arguments) { IEnumerable <AppModulePrepairAttribute> attrs = type.GetCustomAttributes <AppModulePrepairAttribute>(); if (!attrs.Any()) { return; } attrs.ForEach(attr => attr.Prepair(arguments)); }
/// <summary> /// 收集所有模块的类型并触发所有的插件 /// </summary> /// <param name="rootModules"></param> private void CollectAllAppModuleType(IEnumerable <IAppModule> rootModules) { IEnumerable <Type> allAppModuleTypes = this.allAppModuleTypeCollector.Collect(rootModules); CreateTools(allAppModuleTypes); AppModulePrepareArguments appModulePrepareArguments = new AppModulePrepareArguments(this); allAppModuleTypes.ForEach(type => InvokePrepairWhenTypeHasAppModulePrepairAttribute(type, appModulePrepareArguments)); PluginInvoker <OnAllAppModuleTypeCollectedArguments> .SetArgument(new OnAllAppModuleTypeCollectedArguments(allAppModuleTypes)) .SetPlugins(this.Plugins) .Invoke((p, args) => p.OnAllAppModuleTypeCollected(this, args)); }