コード例 #1
0
        /// <summary>
        /// Create a proxy credentials instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <returns>A <see cref="ProxyCredentials"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <b>proxyCredentials</b>
        /// with two attributes (<b>useProxy</b> and <b>proxyServer</b>) and a
        /// nested <b>userCredentials</b> element.</remarks>
        public static ProxyCredentials FromXPathNavigator(
            XPathNavigator navigator)
        {
            ProxyCredentials credentials = new ProxyCredentials();
            UserCredentials  user;
            string           server;

            if (navigator != null)
            {
                navigator = navigator.SelectSingleNode("proxyCredentials");

                if (navigator != null)
                {
                    credentials.UseProxyServer = Convert.ToBoolean(
                        navigator.GetAttribute("useProxy", String.Empty),
                        CultureInfo.InvariantCulture);
                    server = navigator.GetAttribute("proxyServer",
                                                    String.Empty).Trim();

                    if (server.Length != 0)
                    {
                        credentials.ProxyServer = new Uri(server,
                                                          UriKind.RelativeOrAbsolute);
                    }

                    user = UserCredentials.FromXPathNavigator(navigator);
                    credentials.Credentials.UseDefaultCredentials =
                        user.UseDefaultCredentials;
                    credentials.Credentials.UserName = user.UserName;
                    credentials.Credentials.Password = user.Password;
                }
            }

            return(credentials);
        }
コード例 #2
0
        /// <summary>
        /// Create a deployment location instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <param name="id">The id of the element to load</param>
        /// <returns>A <see cref="DeploymentLocation"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <b>deploymentLocation</b>
        /// with two attributes (<b>id</b> with the specified ID value and
        /// <b>location</b>) and nested <b>userCredentials</b> and
        /// <b>proxyCredentials</b> elements.</remarks>
        public static DeploymentLocation FromXPathNavigator(
            XPathNavigator navigator, string id)
        {
            DeploymentLocation depLoc = new DeploymentLocation();
            UserCredentials    user;
            ProxyCredentials   proxy;
            string             location;

            if (navigator != null)
            {
                navigator = navigator.SelectSingleNode(
                    "deploymentLocation[@id='" + id + "']");

                if (navigator != null)
                {
                    location = navigator.GetAttribute("location",
                                                      String.Empty).Trim();

                    if (location.Length != 0)
                    {
                        depLoc.Location = new Uri(location,
                                                  UriKind.RelativeOrAbsolute);
                    }

                    user = UserCredentials.FromXPathNavigator(navigator);

                    depLoc.UserCredentials.UseDefaultCredentials =
                        user.UseDefaultCredentials;
                    depLoc.UserCredentials.UserName = user.UserName;
                    depLoc.UserCredentials.Password = user.Password;

                    proxy = ProxyCredentials.FromXPathNavigator(navigator);

                    depLoc.ProxyCredentials.UseProxyServer =
                        proxy.UseProxyServer;
                    depLoc.ProxyCredentials.ProxyServer = proxy.ProxyServer;
                    depLoc.ProxyCredentials.Credentials.UseDefaultCredentials =
                        proxy.Credentials.UseDefaultCredentials;
                    depLoc.ProxyCredentials.Credentials.UserName =
                        proxy.Credentials.UserName;
                    depLoc.ProxyCredentials.Credentials.Password =
                        proxy.Credentials.Password;
                }
            }

            return(depLoc);
        }
コード例 #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;

            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");
            }
        }
コード例 #4
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;
        }
コード例 #5
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         value;

            builder            = buildProcess;
            attachLogOnSuccess = false;
            attachLogOnFailure = true;
            smtpServer         = successEMailAddress = failureEMailAddress = xslTransformFile = String.Empty;
            credentials        = new UserCredentials();
            smtpPort           = 25;

            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("CNP0001", "The Completion Notification plug-in has not been " +
                                           "configured yet");
            }

            node = root.SelectSingleNode("smtpServer");

            if (node != null)
            {
                smtpServer = node.GetAttribute("host", String.Empty).Trim();
                value      = node.GetAttribute("port", String.Empty);

                if (!Int32.TryParse(value, out smtpPort))
                {
                    smtpPort = 25;
                }
            }

            credentials = UserCredentials.FromXPathNavigator(root);

            node = root.SelectSingleNode("fromEMail");

            if (node != null)
            {
                fromEMailAddress = node.GetAttribute("address", String.Empty).Trim();
            }

            node = root.SelectSingleNode("successEMail");

            if (node != null)
            {
                successEMailAddress = node.GetAttribute("address", String.Empty).Trim();
                attachLogOnSuccess  = Convert.ToBoolean(node.GetAttribute("attachLog", String.Empty),
                                                        CultureInfo.InvariantCulture);
            }

            node = root.SelectSingleNode("failureEMail");

            if (node != null)
            {
                failureEMailAddress = node.GetAttribute("address", String.Empty).Trim();
                attachLogOnFailure  = Convert.ToBoolean(node.GetAttribute("attachLog", String.Empty),
                                                        CultureInfo.InvariantCulture);
            }

            node = root.SelectSingleNode("xslTransform");

            if (node != null)
            {
                xslTransformFile = builder.TransformText(node.GetAttribute("filename", String.Empty).Trim());
            }

            if ((!credentials.UseDefaultCredentials && (credentials.UserName.Length == 0 ||
                                                        credentials.Password.Length == 0)) || failureEMailAddress.Length == 0)
            {
                throw new BuilderException("CNP0002", "The Completion Notification plug-in has an invalid " +
                                           "configuration");
            }
        }
コード例 #6
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentConfig">The current XML configuration XML fragment</param>
        public CompletionNotificationConfigDlg(string currentConfig)
        {
            XPathNavigator  navigator, root, node;
            UserCredentials credentials;
            string          attrValue;
            int             port;

            InitializeComponent();

            lnkProjectSite.Links[0].LinkData = "https://GitHub.com/EWSoftware/SHFB";

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

            root = navigator.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                return;
            }

            node = root.SelectSingleNode("smtpServer");

            if (node != null)
            {
                txtSmtpServer.Text = node.GetAttribute("host", String.Empty);

                attrValue = node.GetAttribute("port", String.Empty);

                if (attrValue.Length != 0 && Int32.TryParse(attrValue, out port))
                {
                    udcSmtpPort.Value = port;
                }
            }

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

            node = root.SelectSingleNode("fromEMail");

            if (node != null)
            {
                txtFromEMail.Text = node.GetAttribute("address", String.Empty);
            }

            node = root.SelectSingleNode("successEMail");

            if (node != null)
            {
                txtSuccessEMailAddress.Text = node.GetAttribute("address", String.Empty);

                attrValue = node.GetAttribute("attachLog", string.Empty);

                if (attrValue.Length != 0)
                {
                    chkAttachLogFileOnSuccess.Checked = Convert.ToBoolean(attrValue, CultureInfo.InvariantCulture);
                }
            }

            node = root.SelectSingleNode("failureEMail");

            if (node != null)
            {
                txtFailureEMailAddress.Text = node.GetAttribute("address", String.Empty);

                attrValue = node.GetAttribute("attachLog", String.Empty);

                if (attrValue.Length != 0)
                {
                    chkAttachLogFileOnFailure.Checked = Convert.ToBoolean(attrValue, CultureInfo.InvariantCulture);
                }
            }

            node = root.SelectSingleNode("xslTransform");

            if (node != null)
            {
                txtXSLTransform.Text = node.GetAttribute("filename", String.Empty);
            }
        }