public PluginManager(string basePath) { try { var settings = PluginSettings.Default; if (settings.Enabled & settings.Plugins.Count > 0) { var pluginSettings = settings.Plugins[0]; if (Log.IsInfoEnabled) { Log.InfoFormat("Plugin configured: name={0}", pluginSettings.Name); if (pluginSettings.CustomAttributes.Count > 0) { foreach (var att in pluginSettings.CustomAttributes) { Log.InfoFormat("\tAttribute: {0}={1}", att.Key, att.Value); } } } var pluginInfo = new PluginInfo { Name = pluginSettings.Name, Version = pluginSettings.Version, AssemblyName = pluginSettings.AssemblyName, Type = pluginSettings.Type, ConfigParams = pluginSettings.CustomAttributes }; this.UpdateConfiguration(pluginInfo, string.IsNullOrEmpty(basePath) ? Environment.CurrentDirectory : basePath); } } catch (Exception e) { Log.Error(e); } }
private void UpdatePluginTraits() { var settings = PluginSettings.Default; if (settings.Enabled & settings.Plugins.Count > 0) { var pluginSettings = settings.Plugins[0]; if (log.IsInfoEnabled) { log.InfoFormat("Plugin configured: name={0}", pluginSettings.Name); if (pluginSettings.CustomAttributes.Count > 0) { foreach (var att in pluginSettings.CustomAttributes) { log.InfoFormat("\tAttribute: {0}={1}", att.Key, att.Value); } } } var pluginInfo = new PluginInfo { Name = pluginSettings.Name, Version = pluginSettings.Version, AssemblyName = pluginSettings.AssemblyName, Type = pluginSettings.Type, ConfigParams = pluginSettings.CustomAttributes }; this.PluginTraits = PluginTraits.Create(pluginInfo); return; } this.PluginTraits = PluginTraits.Create(new PluginInfo()); }
private static void ReadValue(PluginInfo pluginInfo, string name, ref bool result) { var value = FindValue(pluginInfo, name); if (string.IsNullOrEmpty(value)) { return; } bool parseResult; if (bool.TryParse(value, out parseResult)) { result = parseResult; } }
public PluginManager(PluginInfo pluginInfo, string basePath) { this.UpdateConfiguration(pluginInfo, basePath); }
private static string FindValue(PluginInfo pluginInfo, string name) { var result = string.Empty; if (pluginInfo.ConfigParams != null) { pluginInfo.ConfigParams.TryGetValue(name, out result); } return result; }
public static PluginTraits Create(PluginInfo pluginInfo) { var result = new PluginTraits(); ReadValue(pluginInfo, IsPersistentTag, ref result.isPersistent); ReadValue(pluginInfo, AsyncJoinTag, ref result.asyncJoin); return result; }
private void UpdatePluginTraits(PluginInfo pluginInfo) { this.pluginTraits = PluginTraits.Create(pluginInfo); }
public void UpdateConfiguration(PluginInfo pluginInfo, string basePath) { try { var path = Path.Combine(basePath, pluginInfo.Path); this.UpdatePluginTraits(pluginInfo); this.Initialized = this.SetupPluginManager(path, pluginInfo.Type, pluginInfo.ConfigParams); } catch (Exception e) { Log.Error(e); } }
protected PluginManagerBase(PluginInfo pluginInfo, string basePath) { this.currentPluginsVersion = typeof(IPlugin).Assembly.GetName().Version; this.UpdateConfiguration(pluginInfo, basePath); }