/// <summary> /// This method is used to initialize the plug-in at the start of the build process /// </summary> /// <param name="buildProcess">A reference to the current build process</param> /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param> public void Initialize(BuildProcess buildProcess, XElement configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } builder = buildProcess ?? throw new ArgumentNullException(nameof(buildProcess)); var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes( typeof(HelpFileBuilderPlugInExportAttribute), false).First(); builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright); if (configuration.IsEmpty) { throw new BuilderException("WRP0001", "The Wildcard References plug-in has not been configured yet"); } // Load the reference path settings referencePaths = new List <WildcardReferenceSettings>(); foreach (var r in configuration.Descendants("reference")) { referencePaths.Add(WildcardReferenceSettings.FromXml(buildProcess.CurrentProject, r)); } if (referencePaths.Count == 0) { throw new BuilderException("WRP0002", "At least one reference path is required for the " + "Wildcard References plug-in."); } }
//===================================================================== /// <summary> /// Create a wildcard reference settings instance from an XElement /// containing the settings. /// </summary> /// <param name="pathProvider">The base path provider object</param> /// <param name="element">The XElement from which to obtain the settings.</param> /// <returns>A <see cref="WildcardReferenceSettings"/> object containing the /// settings from the XElement.</returns> /// <remarks>It should contain an element called <c>reference</c> /// with three attributes (<c>path</c>, <c>wildcard</c>, and <c>recurse</c>). /// </remarks> public static WildcardReferenceSettings FromXPathNavigator(IBasePathProvider pathProvider, XElement element) { WildcardReferenceSettings wr = new WildcardReferenceSettings(); if (element != null) { wr.ReferencePath = new FolderPath(element.Attribute("path").Value.Trim(), pathProvider); wr.Wildcard = element.Attribute("wildcard").Value; wr.Recursive = (bool)element.Attribute("recurse"); } return(wr); }
/// <summary> /// Update the property grid with the selected item /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void lbReferences_SelectedIndexChanged(object sender, EventArgs e) { if (lbReferences.SelectedItem != null) { WildcardReferenceSettings rl = (WildcardReferenceSettings)lbReferences.SelectedItem; pgProps.SelectedObject = rl; } else { pgProps.SelectedObject = null; } pgProps.Refresh(); }
/// <summary> /// Add a new folder to the wildcard reference settings. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnAddReferencePath_Click(object sender, EventArgs e) { WildcardReferenceSettings newItem; using (FolderBrowserDialog dlg = new FolderBrowserDialog()) { dlg.Description = "Select the folder for the new project"; dlg.SelectedPath = Directory.GetCurrentDirectory(); // If selected, add the file(s) if (dlg.ShowDialog() == DialogResult.OK) { newItem = new WildcardReferenceSettings(); newItem.ReferencePath = new FolderPath(dlg.SelectedPath, project); lbReferences.SelectedIndex = lbReferences.Items.Add(newItem); pgProps.Enabled = btnDelete.Enabled = true; } } }
//===================================================================== /// <summary> /// Create a wildcard reference settings instance from an XElement /// containing the settings. /// </summary> /// <param name="pathProvider">The base path provider object</param> /// <param name="element">The XElement from which to obtain the settings.</param> /// <returns>A <see cref="WildcardReferenceSettings"/> object containing the /// settings from the XElement.</returns> /// <remarks>It should contain an element called <c>reference</c> /// with three attributes (<c>path</c>, <c>wildcard</c>, and <c>recurse</c>). /// </remarks> public static WildcardReferenceSettings FromXPathNavigator(IBasePathProvider pathProvider, XElement element) { WildcardReferenceSettings wr = new WildcardReferenceSettings(); if(element != null) { wr.ReferencePath = new FolderPath(element.Attribute("path").Value.Trim(), pathProvider); wr.Wildcard = element.Attribute("wildcard").Value; wr.Recursive = (bool)element.Attribute("recurse"); } return wr; }
/// <summary> /// Add a new folder to the wildcard reference settings. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnAddReferencePath_Click(object sender, EventArgs e) { WildcardReferenceSettings newItem; using(FolderBrowserDialog dlg = new FolderBrowserDialog()) { dlg.Description = "Select the folder for the new project"; dlg.SelectedPath = Directory.GetCurrentDirectory(); // If selected, add the file(s) if(dlg.ShowDialog() == DialogResult.OK) { newItem = new WildcardReferenceSettings(); newItem.ReferencePath = new FolderPath(dlg.SelectedPath, project); lbReferences.SelectedIndex = lbReferences.Items.Add(newItem); pgProps.Enabled = btnDelete.Enabled = true; } } }