public Form1() { InitializeComponent(); this.Closing += new CancelEventHandler(Form1_Closing); // create the control and set Forms properties. this.globeControl = new GlobeControl(); this.SuspendLayout(); this.globeControl.Location = new System.Drawing.Point(0, 0); this.globeControl.Name = "globeControl"; // this.globeControl.Size = this.ClientSize; // this.globeControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; this.globeControl.Dock = DockStyle.Fill; this.globeControl.TabIndex = 0; // this.globeControl.SendToBack(); // we want the button to be on top this.toolStripContainer1.ContentPanel.Controls.Add(this.globeControl); this.ResumeLayout(false); this.loader = PlugInLoader.CreateLoader(this.globeControl.Host); // at this stage, it is safe to attach events to the control, but otherwise wait until Initialized. this.globeControl.Host.RenderEngine.Initialized += new EventHandler(Initialized); }
static void Main(string[] args) { ConsoleGUI gui = new ConsoleGUI(); PlugInLoader plugIn = new PlugInLoader(); var exercises = plugIn.LoadAvailableExercises().OrderBy(x => x.VersionNumber); foreach (var exercise in exercises) { gui.WriteMessage($"##### {exercise.VersionNumber} - {exercise.Description} #####", Color.Yellow); exercise.Run(gui); Console.ReadKey(); } //VatExerciseMain vat = new VatExerciseMain(); //vat.Run(null); //VatExercise.VatExerciseClasses vatClasses = new VatExercise.VatExerciseClasses(); //vatClasses.Run(gui); //StarWars.StarWarsMain starWars = new StarWars.StarWarsMain(); //starWars.Run(gui); //StarWars2_Delegates.StarWarsMain starWarsDelegates = new StarWars2_Delegates.StarWarsMain(); //starWarsDelegates.Run(gui); //StarWars3_Events.StarWarsMain starWarsDelegates = new StarWars3_Events.StarWarsMain(); //starWarsDelegates.Run(gui); Filters.FiltersMain filters = new Filters.FiltersMain(); filters.Run(gui); //Console.ReadKey(); }
static void EnsurePlugInLoader(string appPath) { if (_plugInLoader == null) { PlugInLoadHelper plugInLoadHelper = new PlugInLoadHelper(appPath); DrectSoftConfigurationSectionHandler.SetConfigurationDelegate(plugInLoadHelper.ReadPlugInLoadConfiguration); PlugInLoadConfiguration plugInLoadConfig = (PlugInLoadConfiguration)ConfigurationManager.GetSection(PlugInLoadConfigSectionName); _plugInLoader = new PlugInLoader(appPath, plugInLoadConfig); } }
private static void LoadPlugins() { try { PlugInLoader.LoadExternalProcessors(Logger); } catch (System.Exception ex) { Logger.Warning("Failed to load external job processors {0}", ex); } }
/// <summary> /// Ctor2 ,指定Loader /// </summary> /// <param name="configFileName"></param> /// <param name="plugInLoader"></param> /// <param name="assemblyInterfaceType"></param> public PlugInConfigurationReader(string configFileName, PlugInLoader plugInLoader, string assemblyInterfaceType) { if (plugInLoader == null) { throw new ArgumentNullException("plugInLoader", "指定的加载域为空"); } _plugInLoader = plugInLoader; _configFileName = configFileName; _assemblyInterfaceType = assemblyInterfaceType; _assemblySetPath = plugInLoader.PlugInsPath; _plugInConfiguration = new Collection <PlugInConfiguration>(); }
private static void LoadPlugins(ILogger logger) { Guard.Against.Null(logger, nameof(logger)); try { PlugInLoader.LoadExternalProcessors(logger); } catch (System.Exception ex) { logger.Log(Microsoft.Extensions.Logging.LogLevel.Error, ex, "Error loading plugins."); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { log.Info("Loading plugins"); PlugInLoader<IPlugin> loader = new PlugInLoader<IPlugin>(e.Argument.ToString()); _Plugins = new Dictionary<string, IPlugin>(); IEnumerable<IPlugin> plugins = loader.Plugins; foreach (var plugin in plugins) { _Plugins.Add(plugin.Name, plugin); log.Info("Loaded plugin: " + plugin.Name); } }
/// <summary> /// 创建并读取插件的配置信息,指定加载类实例 /// </summary> /// <param name="configFileName"></param> /// <param name="plugInLoader">加载类</param> /// <param name="assemblyInterfaceType"></param> /// <param name="needSearchPlugIn">是否需要遍历PlugIn以生成菜单文件</param> /// <returns></returns> public static Collection <PlugInConfiguration> CreateAndReadPlugInConfiguration( string configFileName, PlugInLoader plugInLoader, string assemblyInterfaceType, bool needSearchPlugIn) { PlugInConfigurationReader instance = new PlugInConfigurationReader(configFileName, plugInLoader, assemblyInterfaceType); if (needSearchPlugIn) { if (!instance.CreatePlugInConfiguration()) { _log.Error("生成配置文件失败,请确定有访问文件的权限"); return(new Collection <PlugInConfiguration>()); } } if (!instance.ReadPlugInConfiguration()) { _log.Error("读取配置文件失败,请确定有访问文件的权限"); return(new Collection <PlugInConfiguration>()); } return(instance._plugInConfiguration); }
public GlobeViewControl() { InitializeComponent(); requirements = new Requirements(); //Check if VE3D is installed Type veCheckType = Type.GetTypeFromProgID("Microsoft.SentinelVirtualEarth3DProxy.SentinelVE3DProxy"); if (veCheckType != null) { object veCheckObject = Activator.CreateInstance(veCheckType); object veVersion = veCheckType.InvokeMember("CurrentVersion", BindingFlags.GetProperty, null, veCheckObject, null); if (veVersion != null) { if (double.Parse(veVersion.ToString(), CultureInfo.InvariantCulture) > 4.0) { // create the control and set Forms properties. this.viewBase = new VirtualEarthViewBase(); this.viewBase.Name = "globeControl"; this.viewBase.TabIndex = 0; this.viewBase.SendToBack(); mainHost.Child = viewBase; this.loader = PlugInLoader.CreateLoader(this.viewBase.Host); this.viewBase.Host.RenderEngine.Initialized += EngineInitialized; } else { this.Content = requirements; } } } else { this.Content = requirements; } }
/// <summary> /// 创建并读取插件的配置信息,指定加载类实例 /// </summary> /// <param name="configFileName"></param> /// <param name="plugInLoader">加载类</param> /// <param name="assemblyInterfaceType"></param> /// <returns></returns> public static Collection <PlugInConfiguration> CreateAndReadPlugInConfiguration( string configFileName, PlugInLoader plugInLoader, string assemblyInterfaceType) { return(CreateAndReadPlugInConfiguration(configFileName, plugInLoader, assemblyInterfaceType, true)); }
static void Main(string[] args) { PlugInLoader loader = new PlugInLoader(); loader.PrintLoadedAssemblies("***Loaded assemblies."); Console.WriteLine("$$$Loading PlugIns..."); loader.LoadAllPlugIns(); Console.WriteLine("$$$Loaded PlugIns."); loader.PrintLoadedAssemblies("***Loaded assemblies"); Console.WriteLine("Enter to continue"); Console.ReadLine(); List <IPlugIn> plugIns = loader.PlugIns; plugIns.ForEach(plugin => plugin.PrintLoadedAssemblies("Loadded Assemblies ")); Console.WriteLine("$$$Calling PlugIn methods."); plugIns.ForEach(plugin => Console.WriteLine("The name is: " + plugin.Name)); plugIns.ForEach(plugin => plugin.Initialize()); plugIns.ForEach(plugin => plugin.Execute()); Console.WriteLine("Enter to continue"); Console.ReadLine(); Console.WriteLine("$$$Unloading PlugIns..."); loader.UnloadAllPlugins(); Console.WriteLine("$$$PlugIns unloaded."); loader.PrintLoadedAssemblies("***Loaded assemblies"); Console.WriteLine("!!!Calling PlugIn methods after have been unloaded."); foreach (var plugin in plugIns) { try { Console.WriteLine("!!!The name is: " + plugin.Name); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { plugin.Initialize(); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { plugin.Execute(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("Enter to continue"); Console.ReadLine(); }