Better way to notify failed modules?

May 11, 2010 at 3:29 PM
Edited May 11, 2010 at 3:30 PM

Looking for more of a 'best practice' here. I know this works, but is it in the right spot?

(Within Application_Startup(...) in App.xaml.cs, I've placed this just after starter.Start(); ):

List<string> failedModules = new List<string>(ModuleManagerSingleton.Instance.FailedModules);
List<string> disabledModules = new List<string>(ModuleManagerSingleton.Instance.NonStartupModules);
if (failedModules.Count > 0)
{
    foreach(string failedModule in failedModules)
    {
        if (!disabledModules.Contains(failedModule))
        {
            ServiceLocatorSingleton.Instance.GetInstance<IEventAggregator>().GetEvent<OutputPostedEvent>().Publish(
            new OutputMessage() {
                Category = "My Category",
                Message = string.Format("{0} failed to load.", failedModule)
            });
        }
    }
}