Exemple #1
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentProject">The current project</param>
        /// <param name="currentConfig">The current XML configuration
        /// XML fragment</param>
        public VersionBuilderConfigDlg(SandcastleProject currentProject, string currentConfig)
        {
            XPathNavigator navigator, root, node;
            string         ripOldApis;

            InitializeComponent();
            project = currentProject;

            lnkCodePlexSHFB.Links[0].LinkData = "http://SHFB.CodePlex.com";
            lbVersionInfo.DisplayMember       = lbVersionInfo.ValueMember = "ListDescription";

            items = new VersionSettingsCollection();

            // Load the current settings
            config = new XmlDocument();
            config.LoadXml(currentConfig);
            navigator = config.CreateNavigator();

            root = navigator.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                return;
            }

            node = root.SelectSingleNode("currentProject");
            if (node != null)
            {
                txtLabel.Text   = node.GetAttribute("label", String.Empty);
                txtVersion.Text = node.GetAttribute("version", String.Empty);
                ripOldApis      = node.GetAttribute("ripOldApis", String.Empty);

                // This wasn't in earlier versions
                if (!String.IsNullOrEmpty(ripOldApis))
                {
                    chkRipOldAPIs.Checked = Convert.ToBoolean(ripOldApis, CultureInfo.InvariantCulture);
                }
            }

            items.FromXml(currentProject, root);

            if (items.Count == 0)
            {
                pgProps.Enabled = btnDelete.Enabled = false;
            }
            else
            {
                // Binding the collection to the list box caused some
                // odd problems with the property grid so we'll add the
                // items to the list box directly.
                foreach (VersionSettings vs in items)
                {
                    lbVersionInfo.Items.Add(vs);
                }

                lbVersionInfo.SelectedIndex = 0;
            }
        }
        /// <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>
        /// <exception cref="BuilderException">This is thrown if the plug-in configuration is not valid</exception>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            XPathNavigator root, node;
            string         ripOld;

            builder      = buildProcess;
            allVersions  = new VersionSettingsCollection();
            uniqueLabels = new List <string>();

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("VBP0001", "The Version Builder plug-in has not been configured yet");
            }

            // Add an element for the current project.  This one won't have a project to build.
            currentVersion = new VersionSettings();
            allVersions.Add(currentVersion);

            node = root.SelectSingleNode("currentProject");
            if (node != null)
            {
                currentVersion.FrameworkLabel = node.GetAttribute("label", String.Empty).Trim();
                currentVersion.Version        = node.GetAttribute("version", String.Empty).Trim();

                ripOld = node.GetAttribute("ripOldApis", String.Empty);

                // This wasn't in older versions
                if (!String.IsNullOrEmpty(ripOld))
                {
                    ripOldApis = Convert.ToBoolean(ripOld, CultureInfo.InvariantCulture);
                }
            }

            allVersions.FromXml(builder.CurrentProject, root);

            // An empty label messes up the HTML so use a single space if it's blank
            if (String.IsNullOrEmpty(currentVersion.FrameworkLabel))
            {
                currentVersion.FrameworkLabel = " ";
            }

            if (node == null)
            {
                throw new BuilderException("VBP0002", "A version value is required for the Version Builder plug-in");
            }

            if (allVersions.Count == 1)
            {
                builder.ReportProgress("No other version information was supplied.  Only version information " +
                                       "for the documented assemblies will be included.");
            }

            foreach (VersionSettings vs in allVersions)
            {
                if (!uniqueLabels.Contains(vs.FrameworkLabel))
                {
                    uniqueLabels.Add(vs.FrameworkLabel);
                }
            }

            uniqueLabels.Sort();
        }
Exemple #3
0
        /// <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>
        /// <exception cref="BuilderException">This is thrown if the plug-in
        /// configuration is not valid.</exception>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            XPathNavigator root, node;
            string         ripOld;

            builder      = buildProcess;
            allVersions  = new VersionSettingsCollection();
            uniqueLabels = new List <string>();

            builder.ReportProgress("{0} Version {1}\r\n{2}", this.Name, this.Version, this.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("VBP0002", "The Version Builder plug-in has not been configured yet");
            }

            // Add an element for the current project.  This one won't have
            // a project to build.
            currentVersion = new VersionSettings();
            allVersions.Add(currentVersion);

            node = root.SelectSingleNode("currentProject");
            if (node != null)
            {
                currentVersion.FrameworkLabel = node.GetAttribute("label", String.Empty).Trim();
                currentVersion.Version        = node.GetAttribute("version", String.Empty).Trim();

                ripOld = node.GetAttribute("ripOldApis", String.Empty);

                // This wasn't in older versions
                if (!String.IsNullOrEmpty(ripOld))
                {
                    ripOldApis = Convert.ToBoolean(ripOld, CultureInfo.InvariantCulture);
                }
            }

            allVersions.FromXml(builder.CurrentProject, root);

            // An empty label messes up the HTML so use a single space
            // if it's blank.
            if (String.IsNullOrEmpty(currentVersion.FrameworkLabel))
            {
                currentVersion.FrameworkLabel = " ";
            }

            if (node == null || allVersions.Count == 1)
            {
                throw new BuilderException("VBP0003", "A version value and at least one prior version " +
                                           "are required for the Version Builder plug-in.");
            }

            foreach (VersionSettings vs in allVersions)
            {
                if (!uniqueLabels.Contains(vs.FrameworkLabel))
                {
                    uniqueLabels.Add(vs.FrameworkLabel);
                }
            }

            uniqueLabels.Sort();
        }