private void LogModuleDependencies(IPluginModule module, IEnumerable <PropertyInfo> moduleProps) { foreach (PropertyInfo moduleProp in moduleProps) { BootstrapLogger.Add(LogLevel.Trace, "Module: {moduleName} Property: {propName}: References Module: {refModuleName}", module.GetType().FullName, moduleProp.Name, moduleProp.PropertyType.FullName); } }
//-------------------------------------------------- //--Container Composition //-------------------------------------------------- // Core plugins are composed from all other plugin types since they implement // reusable cross-cutting concerns. private void ComposeCorePlugins(ITypeResolver typeResolver) { BootstrapLogger.Add(LogLevel.Debug, "Settings Plugin Module Properties Referencing Concrete Implementations."); var allPluginTypes = GetPluginTypes().ToArray(); foreach (var plugin in CorePlugins) { typeResolver.ComposePlugin(plugin, allPluginTypes); } }
private void LogPlugins(IEnumerable <IPlugin> plugins) { foreach (var plugin in plugins.OrderBy(p => p.PluginType)) { var details = new { plugin.Name, plugin.PluginId, plugin.AssemblyName, Configs = plugin.Configs.Select(c => c.GetType().FullName), Modules = plugin.Modules.Select(m => m.GetType().FullName) }; BootstrapLogger.Add(LogLevel.Debug, details.ToIndentedJson()); } }
//--------------------------------------------- //--Module Dependencies //--------------------------------------------- // A plugin module can reference another module by referencing any of its supported interfaces // deriving from IPluginModuleService. Finds all IPluginModuleService derived properties of the // referencing module and set them corresponding referenced module instance. private void ComposeModuleDependencies() { BootstrapLogger.Add(LogLevel.Debug, "Settings Plugin Module Properties Referencing other Plugin Modules."); foreach (IPluginModule module in AllModules) { var dependentServiceProps = GetDependentServiceProperties(module); foreach (PropertyInfo serviceProp in dependentServiceProps) { IPluginModuleService dependentService = GetModuleSupportingService(serviceProp.PropertyType); serviceProp.SetValue(module, dependentService); } LogModuleDependencies(module, dependentServiceProps); } }