private void InitializePluginSettings(string pluginKey) { var pluginSettingsInstance = _pluginResolver.GetSettings(pluginKey); //this plugin doesn't have a settings page. if (pluginSettingsInstance == null) { return; } var initializeMethod = pluginSettingsInstance.GetType().BaseType?.GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance); if (initializeMethod != null) { object?[]? dependencies = initializeMethod.GetParameters() .Select(parameter => { return(_serviceProvider.GetService(parameter.ParameterType)); }) .ToArray(); initializeMethod.Invoke(pluginSettingsInstance, dependencies); } pluginSettingsInstance.OnAfterLoad().Wait(); }
public void GetSettingsTest() { //Arrange PluginResolver pluginResolver = new PluginResolver(); pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey"); pluginResolver.LoadPluginSettings(typeof(TestPlugin.TestPlugin)); //Act var settings = pluginResolver.GetSettings("TestKey"); //Assert Assert.NotNull(settings); }