예제 #1
0
        /// <summary>
        /// Create a deployment location instance from an XML element containing the settings
        /// </summary>
        /// <param name="configuration">The XML element 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 FromXml(XElement configuration, string id)
        {
            DeploymentLocation depLoc = new DeploymentLocation();

            configuration = configuration?.XPathSelectElement("deploymentLocation[@id='" + id + "']");

            if (configuration != null)
            {
                string location = configuration.Attribute("location").Value;

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

                UserCredentials user = UserCredentials.FromXml(configuration);

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

                ProxyCredentials proxy = ProxyCredentials.FromXml(configuration);

                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);
        }
예제 #2
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, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

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

            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("ADP0001", "The AjaxDoc plug-in has not been configured yet");
            }

            var node = configuration.Element("ajaxDoc");

            if (node != null)
            {
                ajaxDocUrl      = node.Attribute("url").Value;
                projectName     = node.Attribute("project").Value;
                regenerateFiles = (bool)node.Attribute("regenerate");
            }

            userCreds  = UserCredentials.FromXml(configuration);
            proxyCreds = ProxyCredentials.FromXml(configuration);

            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");
            }

            if (ajaxDocUrl[ajaxDocUrl.Length - 1] != '/')
            {
                ajaxDocUrl += "/";
            }
        }
예제 #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, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            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);

            if (configuration.IsEmpty)
            {
                throw new BuilderException("CNP0001", "The Completion Notification plug-in has not been " +
                                           "configured yet");
            }

            var node = configuration.Element("smtpServer");

            if (node != null)
            {
                smtpServer = node.Attribute("host").Value;
                smtpPort   = (int)node.Attribute("port");
            }

            credentials = UserCredentials.FromXml(configuration);

            node = configuration.Element("fromEMail");

            if (node != null)
            {
                fromEMailAddress = node.Attribute("address").Value;
            }

            node = configuration.Element("successEMail");

            if (node != null)
            {
                successEMailAddress = node.Attribute("address").Value;
                attachLogOnSuccess  = (bool)node.Attribute("attachLog");
            }

            node = configuration.Element("failureEMail");

            if (node != null)
            {
                failureEMailAddress = node.Attribute("address").Value;
                attachLogOnFailure  = (bool)node.Attribute("attachLog");
            }

            node = configuration.Element("xslTransform");

            if (node != null)
            {
                xslTransformFile = builder.SubstitutionTags.TransformText(node.Attribute("filename").Value);
            }

            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");
            }
        }