void LoadModulesFromConfig(CommandEvaluationContext context) { var mods = ModuleUtil.LoadModuleInitConfiguration(context); if (mods == null) { // rebuild the module-init file - it is crashed mods = new ModuleInit() { ReadMe = $"new file generated on {System.DateTime.Now}", List = Array.Empty <ModuleInitItem>() }; ModuleUtil.SaveModuleInitConfiguration(context, mods); context.Errorln("a crashed version of module-init has been restored to initial state"); } var enabledMods = mods.List.Where(x => x.IsEnabled); if (!enabledMods.Any()) { return; } var o = context.Out; o.Echoln(); foreach (var mod in enabledMods) { try { context.Logger.Info(_clp.CommandEvaluationContext.ShellEnv.Colors.Log + $"loading module: '{mod.Path}' ... ", true, false); var a = Assembly.LoadFile(mod.Path); context.Logger.Info(_clp.CommandEvaluationContext.ShellEnv.Colors.Log + $"module assembly loaded: '{a}'. registering module ... ", true, false); var modSpec = _clp.ModuleManager.RegisterModule(_clp.CommandEvaluationContext, a); context.Logger.Done(modSpec.Info.GetDescriptor(context)); } catch (Exception loadModException) { _clp.CommandEvaluationContext.Logger.Fail(loadModException); } } }