Example #1
0
        public ReferenceLinkComponent(BuildAssembler assembler,
                                      XPathNavigator configuration)
            : base(assembler, configuration)
        {
            _hasMsdnStorage = false;
            _hasTopicLinks  = false;

            _linkTarget = "_blank";
            _hrefFormat = "{0}.htm";

            _baseLinkType = ConceptualLinkType.Null;

            _buildController = BuildComponentController.Controller;

            this.ParseReferenceConfiguration(configuration);
            this.ParseConceptualConfiguration(configuration);
        }
        public override void Apply(XmlDocument document, string key)
        {
            try
            {
                XPathNavigator docNavigator = document.CreateNavigator();

                base.Apply(document, docNavigator, key);

                // 1. Apply the math images...
                this.ApplyMath(docNavigator);

                // 2. Apply the media...
                this.ApplyMedia(docNavigator);

                // 3. Apply the codes...
                if (_codeApply)
                {
                    this.ApplyCode(docNavigator);
                }

                // 4. Apply the header for logo and others
                this.ApplyHeader(docNavigator);

                // 5. Apply conversion of roots to namespaces for namespace containers...
                if (_tocExcludedNamespaces != null && _tocExcludedNamespaces.Count != 0 &&
                    _tocExcludedNamespaces.ContainsKey(key))
                {
                    this.ApplyRootNamespaces(docNavigator, key);
                }
                else if (_tocExcludedDocuments != null && _tocExcludedDocuments.Count != 0 &&
                         _tocExcludedDocuments.ContainsKey(key))
                {
                    _tocExcludedDocuments[key] = (XmlDocument)document.Clone();
                }
                else if (key.Length > 2 && key[0] == 'R' && key[1] == ':') // change the root id...
                {
                    if (!String.IsNullOrEmpty(_rootId))
                    {
                        this.ApplyRootId(docNavigator, key);
                    }
                }

                // 6. Apply the version information...
                BuildComponentController controller = BuildComponentController.Controller;
                if (controller.HasVersions)
                {
                    if (_versionSelector == null)
                    {
                        _versionSelector = XPathExpression.Compile(
                            "//include[@item='assemblyNameAndModule']");
                    }

                    IList <VersionInfo> currentVersions = controller.CurrentVersions;
                    if (currentVersions != null && currentVersions.Count != 0)
                    {
                        this.ApplyVersionInformation(docNavigator,
                                                     currentVersions, key);
                    }
                }
            }
            catch (Exception ex)
            {
                this.WriteMessage(MessageLevel.Error, ex);
            }
        }