/// <summary> /// Constructor for extracting the settings from a given a4t.xml document. /// </summary> /// <param name="pluginConfiguration">The doc that represents the a4t.xml file.</param> public PluginSettings(XDocument pluginConfiguration, IAlchemyPlugin plugin = null) { Plugin = plugin; this.pluginConfiguration = pluginConfiguration; this.settings = new Dictionary <string, PluginSetting>(); var settingsElement = this.rootElement = this.pluginConfiguration.Root.Element(this.ns + "settings"); if (settingsElement != null) { DeserializeSettings(settingsElement); // read all settings from the <client> element and apply client=true as default attribute DeserializeSettings( settingsElement.Element(this.ns + "client"), new DeserializeDefaultOptions { IsClientSetting = true }); DeserializeSettings( settingsElement.Element(this.ns + "encrypt"), new DeserializeDefaultOptions { IsEncryptedValue = true }); } }
/// <summary> /// Gets all of the Alchemy service webapi controller types stored in the plugin. /// </summary> /// <param name="plugin">The plugin to get the types for.</param> /// <returns>A collection of web api types.</returns> public static IEnumerable <Type> GetApiControllerTypes(this IAlchemyPlugin plugin) { return(plugin.GetType() .Assembly .ExportedTypes .Where(type => typeof(IAlchemyApiController) .IsAssignableFrom(type))); }
/// <summary> /// Private constructor for nested dictionaries. /// </summary> /// <param name="pluginConfiguration"></param> /// <param name="element"></param> private PluginSettings(XDocument pluginConfiguration, XElement element, PluginSettings parentSettings) { Plugin = parentSettings.Plugin; this.pluginConfiguration = pluginConfiguration; this.rootElement = element; this.settings = new Dictionary <string, PluginSetting>(); DeserializeSettings(element); if (parentSettings.DecryptValues) { this.decryptValues = true; this.encryptionKey = parentSettings.encryptionKey; } }
/// <summary> /// Constructor for extracting th esettings from a given a4t.xml document. /// </summary> /// <param name="fullPathToXml">The full path to a plugin's a4t.xml file.</param> /// <param name="plugin">Reference to the plugin that contains these settings.</param> public PluginSettings(string fullPathToXml, IAlchemyPlugin plugin = null) : this(XDocument.Load(fullPathToXml), plugin) { }
/// <summary> /// Constructor for extracting the settings from a a4t.xml file within a plugin's plugin path. /// </summary> /// <param name="plugin">The plugin to get the a4t file from.</param> public PluginSettings(IAlchemyPlugin plugin) : this(Path.Combine(plugin.PluginPath, "a4t.xml"), plugin) { }