private static void OnPluginProgress(object sender, PluginLoadedEventArgs e) { Platform.CheckForNullReference(e, "e"); #if !MONO SplashScreenManager.SetStatus(e.Message); if (e.PluginAssembly != null) SplashScreenManager.AddAssemblyIcon(e.PluginAssembly); #endif }
private LoadPluginResult LoadPlugin(string path, bool processMetadata) { try { // load assembly var asm = Assembly.LoadFrom(path); // is it a plugin?? var pluginAttr = (PluginAttribute)asm.GetCustomAttributes(typeof(PluginAttribute), false).FirstOrDefault(); if (pluginAttr == null) { return(new LoadPluginResult(false, asm, null)); } var fileName = Path.GetFileName(path); Platform.Log(LogLevel.Debug, "Loaded plugin {0}", fileName); var e = new PluginLoadedEventArgs(string.Format(SR.FormatLoadedPlugin, fileName), asm); EventsHelper.Fire(PluginLoaded, this, e); // do not create a PluginInfo unless explicitly asked for, because it is expensive var pluginInfo = processMetadata ? new PluginInfo(asm, pluginAttr.Name, pluginAttr.Description, pluginAttr.Icon) : null; return(new LoadPluginResult(true, asm, pluginInfo)); } catch (BadImageFormatException e) { // unmanaged DLL in the plugin directory Platform.Log(LogLevel.Debug, SR.LogFoundUnmanagedDLL, e.FileName); } catch (ReflectionTypeLoadException e) { // this exception usually means one of the dependencies is missing Platform.Log(LogLevel.Error, SR.LogFailedToProcessPluginAssembly, Path.GetFileName(path)); // log a detail message for each missing dependency foreach (var loaderException in e.LoaderExceptions) { // just log the message, don't need the full stack trace Platform.Log(LogLevel.Error, loaderException.Message); } } catch (FileNotFoundException e) { Platform.Log(LogLevel.Error, e, "File not found while loading plugin: {0}", path); } catch (Exception e) { // there was a problem processing this assembly Platform.Log(LogLevel.Error, e, SR.LogFailedToProcessPluginAssembly, path); } return(new LoadPluginResult(false, null, null)); }
private LoadPluginResult LoadPlugin(string path, bool processMetadata) { try { // load assembly var asm = Assembly.LoadFrom(path); // is it a plugin?? var pluginAttr = (PluginAttribute) asm.GetCustomAttributes(typeof (PluginAttribute), false).FirstOrDefault(); if (pluginAttr == null) return new LoadPluginResult(false, asm, null); var fileName = Path.GetFileName(path); Platform.Log(LogLevel.Debug, "Loaded plugin {0}", fileName); var e = new PluginLoadedEventArgs(string.Format(SR.FormatLoadedPlugin, fileName), asm); EventsHelper.Fire(PluginLoaded, this, e); // do not create a PluginInfo unless explicitly asked for, because it is expensive var pluginInfo = processMetadata ? new PluginInfo(asm, pluginAttr.Name, pluginAttr.Description, pluginAttr.Icon) : null; return new LoadPluginResult(true, asm, pluginInfo); } catch (BadImageFormatException e) { // unmanaged DLL in the plugin directory Platform.Log(LogLevel.Debug, SR.LogFoundUnmanagedDLL, e.FileName); } catch (ReflectionTypeLoadException e) { // this exception usually means one of the dependencies is missing Platform.Log(LogLevel.Error, SR.LogFailedToProcessPluginAssembly, Path.GetFileName(path)); // log a detail message for each missing dependency foreach (var loaderException in e.LoaderExceptions) { // just log the message, don't need the full stack trace Platform.Log(LogLevel.Error, loaderException.Message); } } catch (FileNotFoundException e) { Platform.Log(LogLevel.Error, e, "File not found while loading plugin: {0}", path); } catch (Exception e) { // there was a problem processing this assembly Platform.Log(LogLevel.Error, e, SR.LogFailedToProcessPluginAssembly, path); } return new LoadPluginResult(false, null, null); }
void PluginManager_PluginLoaded(object sender, PluginLoadedEventArgs e) { Platform.Log(LogLevel.Info, e.Message); }