예제 #1
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;

            builder    = buildProcess;
            ajaxDocUrl = projectName = String.Empty;
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();

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

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in " +
                                           "has not been configured yet");
            }

            node = root.SelectSingleNode("ajaxDoc");
            if (node != null)
            {
                ajaxDocUrl      = node.GetAttribute("url", String.Empty).Trim();
                projectName     = node.GetAttribute("project", String.Empty).Trim();
                regenerateFiles = Convert.ToBoolean(node.GetAttribute(
                                                        "regenerate", String.Empty), CultureInfo.InvariantCulture);
            }

            userCreds  = UserCredentials.FromXPathNavigator(root);
            proxyCreds = ProxyCredentials.FromXPathNavigator(root);

            if (ajaxDocUrl.Length == 0 || projectName.Length == 0 ||
                (!userCreds.UseDefaultCredentials &&
                 (userCreds.UserName.Length == 0 ||
                  userCreds.Password.Length == 0)) ||
                (proxyCreds.UseProxyServer &&
                 (proxyCreds.ProxyServer == null ||
                  (!proxyCreds.Credentials.UseDefaultCredentials &&
                   (proxyCreds.Credentials.UserName.Length == 0 ||
                    proxyCreds.Credentials.Password.Length == 0)))))
            {
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in " +
                                           "has an invalid configuration");
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentConfig">The current XML configuration
        /// XML fragment</param>
        public AjaxDocConfigDlg(string currentConfig)
        {
            XPathNavigator   navigator, root, node;
            UserCredentials  userCreds;
            ProxyCredentials proxyCreds;

            InitializeComponent();

            lnkCodePlexSHFB.Links[0].LinkData    = "http://SHFB.CodePlex.com";
            lnkCodePlexAjaxDoc.Links[0].LinkData = "http://AjaxDoc.CodePlex.com";

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

            root = navigator.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                return;
            }

            node = root.SelectSingleNode("ajaxDoc");
            if (node != null)
            {
                txtAjaxDocUrl.Text         = node.GetAttribute("url", String.Empty);
                txtProjectName.Text        = node.GetAttribute("project", String.Empty);
                chkRegenerateFiles.Checked = Convert.ToBoolean(
                    node.GetAttribute("regenerate", String.Empty),
                    CultureInfo.InvariantCulture);
            }

            userCreds = UserCredentials.FromXPathNavigator(root);
            chkUseDefaultCredentials.Checked = userCreds.UseDefaultCredentials;
            txtUserName.Text = userCreds.UserName;
            txtPassword.Text = userCreds.Password;

            proxyCreds = ProxyCredentials.FromXPathNavigator(root);
            chkUseProxyServer.Checked = proxyCreds.UseProxyServer;
            txtProxyServer.Text       = (proxyCreds.ProxyServer == null) ? null :
                                        proxyCreds.ProxyServer.OriginalString;
            chkUseProxyDefCreds.Checked = proxyCreds.Credentials.UseDefaultCredentials;
            txtProxyUserName.Text       = proxyCreds.Credentials.UserName;
            txtProxyPassword.Text       = proxyCreds.Credentials.Password;
        }