Esempio n. 1
0
        /// <summary>
        /// Validate the configuration and save it
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            XmlNode      root, node, ignore;
            XmlAttribute attr;

            // Store the changes
            root = config.SelectSingleNode("configuration");

            attr = root.Attributes["useGAC"];

            if (attr == null)
            {
                attr = config.CreateAttribute("useGAC");
                root.Attributes.Append(attr);
            }

            attr.Value = chkUseGAC.Checked.ToString().ToLowerInvariant();

            items.Clear();

            foreach (BindingRedirectSettings brs in lbRedirects.Items)
            {
                items.Add(brs);
            }

            items.ToXml(config, root, true);

            node = root.SelectSingleNode("ignoreIfUnresolved");

            if (node == null)
            {
                node = config.CreateNode(XmlNodeType.Element, "ignoreIfUnresolved", null);
                root.AppendChild(node);
            }
            else
            {
                node.RemoveAll();
            }

            foreach (string item in lbIgnoreIfUnresolved.Items)
            {
                ignore = config.CreateNode(XmlNodeType.Element, "assemblyIdentity", null);
                root.AppendChild(node);

                attr       = config.CreateAttribute("name");
                attr.Value = item;
                ignore.Attributes.Append(attr);

                node.AppendChild(ignore);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// This method is used to execute the plug-in during the build process
        /// </summary>
        /// <param name="context">The current execution context</param>
        public void Execute(ExecutionContext context)
        {
            XmlDocument  config = new XmlDocument();
            XmlAttribute attr;
            XmlNode      resolver, ddue;

            config.Load(builder.WorkingFolder + "MRefBuilder.config");
            resolver = config.SelectSingleNode("configuration/dduetools/resolver");

            if (resolver == null)
            {
                ddue = config.SelectSingleNode("configuration/dduetools");

                if (ddue == null)
                {
                    throw new BuilderException("ABR0002", "Unable to locate " +
                                               "configuration/dduetools or its child resolver " +
                                               "element in MRefBuilder.config");
                }

                builder.ReportProgress("Default resolver element not found, " +
                                       "adding new element");
                resolver = config.CreateNode(XmlNodeType.Element, "resolver", null);
                ddue.AppendChild(resolver);

                attr = config.CreateAttribute("type");
                resolver.Attributes.Append(attr);
                attr = config.CreateAttribute("assembly");
                resolver.Attributes.Append(attr);
                attr       = config.CreateAttribute("use-gac");
                attr.Value = "false";
                resolver.Attributes.Append(attr);
            }

            resolver.Attributes["type"].Value =
                "SandcastleBuilder.Components.BindingRedirectResolver";
            resolver.Attributes["assembly"].Value = builder.TransformText(
                "{@SHFBFolder}SandcastleBuilder.MRefBuilder.dll");

            builder.ReportProgress("Default resolver replaced with '{0}' in '{1}'",
                                   resolver.Attributes["type"].Value,
                                   resolver.Attributes["assembly"].Value);

            builder.ReportProgress("Adding redirects:");

            foreach (BindingRedirectSettings brs in redirects)
            {
                builder.ReportProgress("    {0}", brs);
            }

            redirects.ToXml(config, resolver);

            config.Save(builder.WorkingFolder + "MRefBuilder.config");
        }
Esempio n. 3
0
        /// <summary>
        /// Validate the configuration and save it
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            XmlNode root;

            // Store the changes
            root = config.SelectSingleNode("configuration");

            items.Clear();

            foreach (BindingRedirectSettings brs in lbRedirects.Items)
            {
                items.Add(brs);
            }

            items.ToXml(config, root);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 4
0
        /// <summary>
        /// This method is used to execute the plug-in during the build process
        /// </summary>
        /// <param name="context">The current execution context</param>
        public void Execute(ExecutionContext context)
        {
            XmlDocument  config = new XmlDocument();
            XmlAttribute attr;
            XmlNode      resolver, ddue, ignoreNode, assemblyNode;

            config.Load(builder.WorkingFolder + "MRefBuilder.config");
            resolver = config.SelectSingleNode("configuration/dduetools/resolver");

            if (resolver == null)
            {
                ddue = config.SelectSingleNode("configuration/dduetools");

                if (ddue == null)
                {
                    throw new BuilderException("ABR0002", "Unable to locate configuration/dduetools or its " +
                                               "child resolver element in MRefBuilder.config");
                }

                builder.ReportProgress("Default resolver element not found, adding new element");
                resolver = config.CreateNode(XmlNodeType.Element, "resolver", null);
                ddue.AppendChild(resolver);

                attr       = config.CreateAttribute("type");
                attr.Value = "Microsoft.Ddue.Tools.Reflection.AssemblyResolver";
                resolver.Attributes.Append(attr);

                attr       = config.CreateAttribute("assembly");
                attr.Value = builder.SubstitutionTags.TransformText(@"{@SHFBFolder}MRefBuilder.exe");
                resolver.Attributes.Append(attr);

                attr       = config.CreateAttribute("use-gac");
                attr.Value = "false";
                resolver.Attributes.Append(attr);
            }

            // Allow turning GAC resolution on
            resolver.Attributes["use-gac"].Value = useGac.ToString().ToLowerInvariant();

            if (redirects.Count != 0)
            {
                builder.ReportProgress("Adding binding redirections to assembly resolver configuration:");

                foreach (BindingRedirectSettings brs in redirects)
                {
                    builder.ReportProgress("    {0}", brs);
                }

                redirects.ToXml(config, resolver, false);
            }

            if (ignoreIfUnresolved.Count != 0)
            {
                builder.ReportProgress("Adding ignored assembly names to assembly resolver configuration:");

                ignoreNode = resolver.SelectSingleNode("ignoreIfUnresolved");

                if (ignoreNode == null)
                {
                    ignoreNode = config.CreateNode(XmlNodeType.Element, "ignoreIfUnresolved", null);
                    resolver.AppendChild(ignoreNode);
                }
                else
                {
                    ignoreNode.RemoveAll();
                }

                foreach (string ignoreName in ignoreIfUnresolved)
                {
                    assemblyNode = config.CreateNode(XmlNodeType.Element, "assemblyIdentity", null);
                    ignoreNode.AppendChild(assemblyNode);

                    attr       = config.CreateAttribute("name");
                    attr.Value = ignoreName;
                    assemblyNode.Attributes.Append(attr);

                    builder.ReportProgress("    {0}", ignoreName);
                }
            }

            config.Save(builder.WorkingFolder + "MRefBuilder.config");
        }
Esempio n. 5
0
        /// <summary>
        /// This method is used to execute the plug-in during the build process
        /// </summary>
        /// <param name="context">The current execution context</param>
        public void Execute(ExecutionContext context)
        {
            XmlDocument  config = new XmlDocument();
            XmlAttribute attr;
            XmlNode      resolver, ddue, ignoreNode, assemblyNode;
            string       configFile = builder.WorkingFolder + "MRefBuilder.config";

            // If the project doesn't exist we have nothing to do.  However, it could be that some other plug-in
            // has bypassed it so only issue a warning.
            if (!File.Exists(configFile))
            {
                builder.ReportWarning("ABR0003", "The MRefBuilder configuration file '{0}' could not be " +
                                      "found.  The Assembly Binding Redirection plug-in did not run.", configFile);
                return;
            }

            config.Load(configFile);
            resolver = config.SelectSingleNode("configuration/dduetools/resolver");

            if (resolver == null)
            {
                ddue = config.SelectSingleNode("configuration/dduetools");

                if (ddue == null)
                {
                    throw new BuilderException("ABR0002", "Unable to locate configuration/dduetools or its " +
                                               "child resolver element in MRefBuilder.config");
                }

                builder.ReportProgress("Default resolver element not found, adding new element");
                resolver = config.CreateNode(XmlNodeType.Element, "resolver", null);
                ddue.AppendChild(resolver);

                attr       = config.CreateAttribute("type");
                attr.Value = "Microsoft.Ddue.Tools.Reflection.AssemblyResolver";
                resolver.Attributes.Append(attr);

                attr       = config.CreateAttribute("assembly");
                attr.Value = builder.SubstitutionTags.TransformText(@"{@SHFBFolder}MRefBuilder.exe");
                resolver.Attributes.Append(attr);

                attr       = config.CreateAttribute("use-gac");
                attr.Value = "false";
                resolver.Attributes.Append(attr);
            }

            // Allow turning GAC resolution on
            resolver.Attributes["use-gac"].Value = useGac.ToString().ToLowerInvariant();

            if (redirects.Count != 0)
            {
                builder.ReportProgress("Adding binding redirections to assembly resolver configuration:");

                foreach (BindingRedirectSettings brs in redirects)
                {
                    builder.ReportProgress("    {0}", brs);
                }

                redirects.ToXml(config, resolver, false);
            }

            if (ignoreIfUnresolved.Count != 0)
            {
                builder.ReportProgress("Adding ignored assembly names to assembly resolver configuration:");

                ignoreNode = resolver.SelectSingleNode("ignoreIfUnresolved");

                if (ignoreNode == null)
                {
                    ignoreNode = config.CreateNode(XmlNodeType.Element, "ignoreIfUnresolved", null);
                    resolver.AppendChild(ignoreNode);
                }
                else
                {
                    ignoreNode.RemoveAll();
                }

                foreach (string ignoreName in ignoreIfUnresolved)
                {
                    assemblyNode = config.CreateNode(XmlNodeType.Element, "assemblyIdentity", null);
                    ignoreNode.AppendChild(assemblyNode);

                    attr       = config.CreateAttribute("name");
                    attr.Value = ignoreName;
                    assemblyNode.Attributes.Append(attr);

                    builder.ReportProgress("    {0}", ignoreName);
                }
            }

            config.Save(configFile);
        }