private void OnModuleTypeLoaded(ModuleInfo typeLoadedModuleInfo, Exception error) { if (error == null) { if (LoadedModules.FirstOrDefault(x => x.ModuleName == typeLoadedModuleInfo.ModuleName) == null) { LoadedModules.Add(typeLoadedModuleInfo); try { Type moduleType = Type.GetType(typeLoadedModuleInfo.ModuleType, true); INinjectModule moduleInstance = Activator.CreateInstance(moduleType) as INinjectModule; if (moduleInstance == null) error = new InvalidOperationException("Module instance null"); _kernel.Load(new List<INinjectModule> { moduleInstance }); } catch (Exception ex) { error = ex; } } } if (ModuleTypeLoaded != null) ModuleTypeLoaded(this, new ModuleTypeLoadedEventArgs(typeLoadedModuleInfo, error)); }
public static void SetModuleInfo(ContentControl control, ModuleInfo moduleInfo) { control.SetValue(ModuleInfoProperty, moduleInfo); }
public ModuleTypeLoadedEventArgs(ModuleInfo moduleInfo, Exception error) { if (moduleInfo == null) throw new ArgumentNullException("moduleInfo"); ModuleInfo = moduleInfo; Error = error; }
public void LoadModuleType(ModuleInfo moduleInfo) { _moduleTypeLoader.BeginLoadModuleType(moduleInfo, OnModuleTypeLoaded); }