示例#1
0
        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));
        }
示例#2
0
 public static void SetModuleInfo(ContentControl control, ModuleInfo moduleInfo)
 {
     control.SetValue(ModuleInfoProperty, moduleInfo);
 }
示例#3
0
        public ModuleTypeLoadedEventArgs(ModuleInfo moduleInfo, Exception error)
        {
            if (moduleInfo == null)
                throw new ArgumentNullException("moduleInfo");

            ModuleInfo = moduleInfo;
            Error = error;
        }
示例#4
0
 public void LoadModuleType(ModuleInfo moduleInfo)
 {
     _moduleTypeLoader.BeginLoadModuleType(moduleInfo, OnModuleTypeLoaded);
 }