Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            TargetController controller = TargetController.Controller;

            if (controller != null)
            {
                controller.Uninitialize();
            }

            if (_msdnResolver != null)
            {
                _msdnResolver.Dispose();
                _msdnResolver = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        private void ParseReferenceConfiguration(XPathNavigator configuration)
        {
            TargetController controller = TargetController.Controller;

            Debug.Assert(controller != null);
            controller.Initialize(this);

            ReferenceLinkType localLink = ReferenceLinkType.None;
            ReferenceLinkType msdnLink  = ReferenceLinkType.None;

            _targets = controller.GetCollection(configuration, out localLink, out msdnLink);
            Debug.Assert(_targets != null);
            _linkResolver = new ReferenceLinkTextResolver(_targets);

            if (msdnLink == ReferenceLinkType.Msdn && _msdnResolver == null)
            {
                XPathNavigator linkResolverNode =
                    configuration.SelectSingleNode("linkResolver");

                if (linkResolverNode != null)
                {
                    WriteMessage(MessageLevel.Info, "Creating cached MSDN URL resolver.");

                    _msdnResolver = TargetMsdnController.GetController(linkResolverNode);
                }
                else
                {
                    WriteMessage(MessageLevel.Info, "Creating MSDN URL resolver.");

                    _msdnResolver = TargetMsdnController.GetController();
                }
            }

            XPathNavigator optionsNode =
                configuration.SelectSingleNode("options");

            if (optionsNode == null)
            {
                optionsNode = configuration;
            }

            // base-url is an xpath expression applied against the current document to pick up the save location of the
            // document. If specified, local links will be made relative to the base-url.
            string baseUrlValue = optionsNode.GetAttribute("base-url", String.Empty);

            if (!String.IsNullOrEmpty(baseUrlValue))
            {
                _baseUrl = XPathExpression.Compile(baseUrlValue);
            }

            // url-format is a string format that is used to format the value of local href attributes. The default is
            // "{0}.htm" for backwards compatibility.
            string hrefFormatValue = optionsNode.GetAttribute("href-format", String.Empty);

            if (!String.IsNullOrEmpty(hrefFormatValue))
            {
                _hrefFormat = hrefFormatValue;
            }

            // the container XPath can be replaced; this is useful
            string containerValue = optionsNode.GetAttribute("container", String.Empty);

            if (!String.IsNullOrEmpty(containerValue))
            {
                TargetCollectionXmlUtilities.ContainerExpression = containerValue;
            }

            string localeValue = optionsNode.GetAttribute("locale", String.Empty);

            if (!String.IsNullOrEmpty(localeValue) && _msdnResolver != null)
            {
                _msdnResolver.Locale = localeValue;
            }

            string versionValue = optionsNode.GetAttribute("version", String.Empty);

            if (!String.IsNullOrEmpty(versionValue) && _msdnResolver != null)
            {
                _msdnResolver.Version = versionValue;
            }

            string mvcVersionValue = optionsNode.GetAttribute("mvcVersion", String.Empty);

            if (!String.IsNullOrEmpty(mvcVersionValue) && _msdnResolver != null)
            {
                _msdnResolver.MvcVersion = mvcVersionValue;
            }

            string targetValue = optionsNode.GetAttribute("linkTarget", String.Empty);

            if (!String.IsNullOrEmpty(targetValue))
            {
                _linkTarget = targetValue;
            }

            this.WriteMessage(MessageLevel.Info, String.Format(
                                  "Loaded {0} reference targets.", _targets.Count));

            _writerSettings = new XmlWriterSettings();
            _writerSettings.ConformanceLevel = ConformanceLevel.Fragment;

            _hasMsdnStorage = controller.HasMsdnStorage;
        }