/// <summary>
 /// Initializes a new instance of the <see cref="ReferenceEngineSettings"/> class
 /// with parameters copied from the specified instance of the
 /// <see cref="ReferenceEngineSettings"/> class, a copy constructor.
 /// </summary>
 /// <param name="source">
 /// An instance of the <see cref="ReferenceEngineSettings"/> class from which the
 /// initialization parameters or values will be copied.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// If the parameter <paramref name="source"/> is <see langword="null"/>.
 /// </exception>
 public ReferenceEngineSettings(ReferenceEngineSettings source)
     : base(source)
 {
     _topicLinks                     = source._topicLinks;
     _refNaming                      = source._refNaming;
     _webMvcSdkType                  = source._webMvcSdkType;
     _refNamer                       = source._refNamer;
     _rootContainer                  = source._rootContainer;
     _embedScriptSharp               = source._embedScriptSharp;
     _includeAllMembersTopic         = source._includeAllMembersTopic;
     _includeInheritedOverloadTopics = source._includeInheritedOverloadTopics;
 }
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            IBuildNamedList <BuildGroupContext> groupContexts = _context.GroupContexts;

            if (groupContexts == null || groupContexts.Count == 0)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            ReferenceGroupContext groupContext = groupContexts[group.Id]
                                                 as ReferenceGroupContext;

            if (groupContext == null)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            BuildFramework     framework = groupContext.Framework;
            BuildFrameworkKind kind      = framework.FrameworkType.Kind;

            ReferenceEngineSettings referenceSettings = _settings.EngineSettings[
                BuildEngineType.Reference] as ReferenceEngineSettings;
            BuildSpecialSdkType webSdkType = referenceSettings.WebMvcSdkType;

            writer.WriteStartElement("options");   // start - options
            writer.WriteAttributeString("locale",
                                        _settings.CultureInfo.Name.ToLower());
            if (kind == BuildFrameworkKind.Silverlight)
            {
                writer.WriteAttributeString("version", "VS.95");
            }
            else if (kind == BuildFrameworkKind.Compact)
            {
                // The framework 3.5 is the last version of Windows CE...
                writer.WriteAttributeString("version", "VS.90");
            }
            if (webSdkType != BuildSpecialSdkType.Null &&
                webSdkType != BuildSpecialSdkType.None)
            {
                switch (webSdkType.Value)
                {
                case 10:        // ASP.NET MVC 1.0: Supported in .NET 3.5
                    writer.WriteAttributeString("mvcVersion", "VS.90");
                    break;

                case 20:        // ASP.NET MVC 2.0: Supported in .NET 3.5 SP1
                    // This is currently the default documentation for
                    // the ASP.NET MVC Framework...
                    writer.WriteAttributeString("mvcVersion", "");
                    break;

                case 30:        // ASP.NET MVC 3.0: Supported in .NET 4.0
                    writer.WriteAttributeString("mvcVersion", "VS.98");
                    break;

                case 40:        // ASP.NET MVC 4.0: Supported in .NET 4.5
                    writer.WriteAttributeString("mvcVersion", "VS.108");
                    break;
                }
            }
            writer.WriteAttributeString("linkTarget",
                                        "_" + _format.ExternalLinkTarget.ToString().ToLower());
            writer.WriteEndElement();              // end - options

            bool   isEmbeddedGroup    = false;
            bool   frameworkAvailable = false;
            bool   isEmbeddedScript   = groupContext.IsEmbeddedGroup;
            string tempText           = _context["$EmbeddedScriptSharp"];

            if (!String.IsNullOrEmpty(tempText))
            {
                isEmbeddedScript = Convert.ToBoolean(tempText);
            }

            List <DataSource> dataSources = new List <DataSource>();

            if (kind == BuildFrameworkKind.Silverlight)
            {
                string silverlightDir = groupContext["$SilverlightDataDir"];

                if (!String.IsNullOrEmpty(silverlightDir) &&
                    Directory.Exists(silverlightDir))
                {
                    frameworkAvailable = true;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", silverlightDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    Version latestVersion = BuildFrameworks.LatestSilverlightVersion;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Silverlight,
                                         silverlightDir, latestVersion, true, true, dataSources);

                    writer.WriteEndElement();
                }
            }
            else if (kind == BuildFrameworkKind.Portable)
            {
                string portableDir = groupContext["$PortableDataDir"];

                if (!String.IsNullOrEmpty(portableDir) && Directory.Exists(portableDir))
                {
                    frameworkAvailable = true;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", portableDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    Version latestVersion = BuildFrameworks.LatestPortableVersion;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Portable,
                                         portableDir, latestVersion, true, false, dataSources);

                    writer.WriteEndElement();
                }
            }
            else if (kind == BuildFrameworkKind.ScriptSharp)
            {
                string scriptSharpDir = groupContext["$ScriptSharpDataDir"];

                if (!String.IsNullOrEmpty(scriptSharpDir) && Directory.Exists(scriptSharpDir))
                {
                    frameworkAvailable = true;

                    if (!isEmbeddedGroup)
                    {
                        writer.WriteStartElement("targets");
                        writer.WriteAttributeString("base", scriptSharpDir);
                        writer.WriteAttributeString("recurse", "false");
                        writer.WriteAttributeString("system", "true");
                        writer.WriteAttributeString("files", "*.xml");

                        if (isEmbeddedScript)
                        {
                            writer.WriteAttributeString("type",
                                                        BuildLinkType.Local.ToString().ToLower());
                        }
                        else
                        {
                            writer.WriteAttributeString("type",
                                                        BuildLinkType.None.ToString().ToLower());
                        }

                        // Write the data source...
                        Version latestVersion = BuildFrameworks.LatestScriptSharpVersion;
                        if (latestVersion == null)
                        {
                            latestVersion = framework.Version;
                        }
                        this.WriteDataSource(writer, DataSourceType.ScriptSharp,
                                             scriptSharpDir, latestVersion, true, false, dataSources);

                        writer.WriteEndElement();
                    }
                }
            }

            // If not specialized framework, then write the default...
            if (!frameworkAvailable || kind == BuildFrameworkKind.None ||
                kind == BuildFrameworkKind.DotNet || kind == BuildFrameworkKind.Compact)
            {
                string dotNetDataDir = Path.GetFullPath(
                    Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory));

                writer.WriteStartElement("targets");
                writer.WriteAttributeString("base", dotNetDataDir);
                writer.WriteAttributeString("recurse", "true");
                writer.WriteAttributeString("system", "true");
                writer.WriteAttributeString("files", "*.xml");
                writer.WriteAttributeString("type",
                                            _format.ExternalLinkType.ToString().ToLower());

                // Write the data source...
                this.WriteDataSource(writer, DataSourceType.Framework,
                                     dotNetDataDir, ReferenceEngine.ReflectionVersion, true,
                                     false, dataSources);

                writer.WriteEndElement();
            }

            // The Portable and ScriptSharp do not support Blend...
            if (kind != BuildFrameworkKind.Portable &&
                kind != BuildFrameworkKind.Compact &&
                kind != BuildFrameworkKind.ScriptSharp)
            {
                string blendDir = groupContext["$BlendDataDir"];

                if (!String.IsNullOrEmpty(blendDir) && Directory.Exists(blendDir))
                {
                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", blendDir);
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                _format.ExternalLinkType.ToString().ToLower());

                    // Write the data source...
                    BuildSpecialSdk latestBlendSdk = null;
                    if (kind == BuildFrameworkKind.Silverlight)
                    {
                        latestBlendSdk = BuildSpecialSdks.LatestBlendSilverlightSdk;
                    }
                    else
                    {
                        latestBlendSdk = BuildSpecialSdks.LatestBlendWpfSdk;
                    }
                    Version latestVersion = (latestBlendSdk == null) ?
                                            null : latestBlendSdk.Version;
                    if (latestVersion == null)
                    {
                        latestVersion = framework.Version;
                    }
                    this.WriteDataSource(writer, DataSourceType.Blend, blendDir,
                                         latestVersion, true, kind == BuildFrameworkKind.Silverlight,
                                         dataSources);

                    writer.WriteEndElement();
                }
            }

            IList <string> linkDirs = _context.GetValue(
                "$ReferenceLinkDirectories") as IList <string>;
            IList <ReferenceLinkSource> linkSources = _context.GetValue(
                "$ReferenceLinkSources") as IList <ReferenceLinkSource>;

            if ((linkDirs != null && linkDirs.Count != 0) &&
                (linkSources != null && linkSources.Count == linkDirs.Count))
            {
                for (int i = 0; i < linkDirs.Count; i++)
                {
                    ReferenceLinkSource linkSource     = linkSources[i];
                    BuildLinkType       sourceLinkType = linkSource.LinkType;

                    writer.WriteStartElement("targets");
                    writer.WriteAttributeString("base", linkDirs[i]);
                    writer.WriteAttributeString("recurse", "true");
                    writer.WriteAttributeString("system", "false");
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteAttributeString("type",
                                                sourceLinkType.ToString().ToLower());

                    writer.WriteEndElement();
                }
            }

            BuildLinkType linkType     = _format.LinkType;
            string        linkTypeText = linkType.ToString().ToLower();

            // For the embedded group, we will not link to the other groups...
            if (!isEmbeddedGroup)
            {
                for (int i = 0; i < groupContexts.Count; i++)
                {
                    ReferenceGroupContext aContext = groupContexts[i]
                                                     as ReferenceGroupContext;

                    if (aContext == null || aContext.IsLinkGroup)
                    {
                        continue;
                    }

                    if (aContext.GroupType != BuildGroupType.Reference ||
                        aContext == groupContext)
                    {
                        continue;
                    }

                    string linkFile = aContext["$ReflectionFile"];
                    if (!String.IsNullOrEmpty(linkFile))
                    {
                        writer.WriteStartElement("targets");

                        writer.WriteAttributeString("base", @".\");
                        writer.WriteAttributeString("recurse", "false");
                        writer.WriteAttributeString("system", "false");
                        writer.WriteAttributeString("files", @".\" + linkFile);
                        writer.WriteAttributeString("type", linkTypeText);
                        writer.WriteEndElement();
                    }
                }
            }

            //<targets base=".\" recurse="false"
            //   files=".\reflection.xml" type="local" />
            writer.WriteStartElement("targets");
            writer.WriteAttributeString("base", @".\");
            writer.WriteAttributeString("recurse", "false");
            writer.WriteAttributeString("system", "false");
            writer.WriteAttributeString("files", @".\" + groupContext["$ReflectionFile"]);

            if (isEmbeddedGroup)
            {
                writer.WriteAttributeString("type",
                                            BuildLinkType.Local.ToString().ToLower());
            }
            else
            {
                writer.WriteAttributeString("type", linkTypeText);
            }

            writer.WriteEndElement();

            // Provide the information for the MSDN link resolvers...
            writer.WriteStartElement("linkResolver"); // start - linkResolver
            writer.WriteAttributeString("storage", _linkStorage.ToString().ToLower());
            writer.WriteAttributeString("cache", _cacheLinks ? "true" : "false");
            if (dataSources != null && dataSources.Count != 0)
            {
                for (int i = 0; i < dataSources.Count; i++)
                {
                    DataSource dataSource = dataSources[i];

                    this.WriteDataSource(writer, dataSource.SourceType,
                                         dataSource.InputDir, dataSource.Version,
                                         dataSource.IsDatabase, dataSource.IsSilverlight, true);
                }
            }
            writer.WriteEndElement();                 // end - linkResolver

            // Finally, provide the information for the conceptual links
            // in reference documents, if any...
            bool hasConceptualContext = _settings.BuildConceptual;

            if (hasConceptualContext)
            {
                hasConceptualContext = false;

                for (int i = 0; i < groupContexts.Count; i++)
                {
                    BuildGroupContext aContext = groupContexts[i];
                    if (aContext.GroupType == BuildGroupType.Conceptual)
                    {
                        hasConceptualContext = true;
                        break;
                    }
                }
            }

            if (hasConceptualContext)
            {
                ConceptualEngineSettings conceptualSettings = _settings.EngineSettings[
                    BuildEngineType.Conceptual] as ConceptualEngineSettings;
                Debug.Assert(conceptualSettings != null,
                             "The settings does not include the reference engine settings.");
                if (conceptualSettings == null)
                {
                    return(false);
                }
                ConceptualLinkConfiguration linkConfig =
                    conceptualSettings.ConceptualLinks;
                Debug.Assert(linkConfig != null,
                             "There is no conceptual link configuration available.");
                if (linkConfig == null)
                {
                    return(false);
                }

                writer.WriteStartElement("conceptualLinks");  //start: conceptualLinks
                writer.WriteAttributeString("enabled", "true");
                writer.WriteAttributeString("showText",
                                            linkConfig.ShowLinkText.ToString());
                writer.WriteAttributeString("showBrokenLinkText",
                                            linkConfig.ShowBrokenLinkText.ToString());
                writer.WriteAttributeString("type", linkTypeText);

                for (int i = 0; i < groupContexts.Count; i++)
                {
                    BuildGroupContext aContext = groupContexts[i];
                    if (aContext.GroupType == BuildGroupType.Conceptual)
                    {
                        writer.WriteStartElement("conceptualTargets");  // start - conceptualTargets
                        writer.WriteAttributeString("base", String.Format(
                                                        @".\{0}", aContext["$DdueXmlCompDir"]));
                        writer.WriteAttributeString("type", linkTypeText);
                        writer.WriteEndElement();                       // end - conceptualTargets
                    }
                }
                writer.WriteEndElement();                     //end: conceptualLinks
            }

            return(true);
        }
        protected override void OnReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            string startElement = reader.Name;

            if (String.Equals(startElement, ReferenceSource.TagName,
                              StringComparison.OrdinalIgnoreCase))
            {
                string sourceName = reader.GetAttribute("name");

                // For the link source...
                if (String.Equals(sourceName, ReferenceLinkSource.SourceName,
                                  StringComparison.OrdinalIgnoreCase))
                {
                    if (_topicLinks == null)
                    {
                        _topicLinks = new BuildList <ReferenceLinkSource>();
                    }
                    ReferenceLinkSource linkSource = new ReferenceLinkSource();
                    linkSource.ReadXml(reader);

                    _topicLinks.Add(linkSource);
                }
            }
            else if (String.Equals(startElement, "propertyGroup",
                                   StringComparison.OrdinalIgnoreCase))
            {
                Debug.Assert(String.Equals(reader.GetAttribute("name"), "General"));

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (String.Equals(reader.Name, "property", StringComparison.OrdinalIgnoreCase))
                        {
                            string tempText = null;
                            switch (reader.GetAttribute("name").ToLower())
                            {
                            case "namer":
                                tempText = reader.ReadString();
                                if (!String.IsNullOrEmpty(tempText))
                                {
                                    _refNamer = (ReferenceNamer)Enum.Parse(
                                        typeof(ReferenceNamer), tempText, true);
                                }
                                break;

                            case "naming":
                                tempText = reader.ReadString();
                                if (!String.IsNullOrEmpty(tempText))
                                {
                                    _refNaming = (ReferenceNamingMethod)Enum.Parse(
                                        typeof(ReferenceNamingMethod), tempText, true);
                                }
                                break;

                            case "rootnamespacecontainer":
                                tempText = reader.ReadString();
                                if (!String.IsNullOrEmpty(tempText))
                                {
                                    _rootContainer = Convert.ToBoolean(tempText);
                                }
                                break;

                            case "embedscriptsharpframework":
                                tempText = reader.ReadString();
                                if (!String.IsNullOrEmpty(tempText))
                                {
                                    _embedScriptSharp = Convert.ToBoolean(tempText);
                                }
                                break;

                            case "webmvcsdktype":
                                tempText = reader.ReadString();
                                if (!String.IsNullOrEmpty(tempText))
                                {
                                    _webMvcSdkType = BuildSpecialSdkType.Parse(tempText);
                                }
                                break;

                            default:
                                // Should normally not reach here...
                                throw new NotImplementedException(reader.GetAttribute("name"));
                            }
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (String.Equals(reader.Name, startElement,
                                          StringComparison.OrdinalIgnoreCase))
                        {
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReferenceEngineSettings"/> class
        /// with the default parameters.
        /// </summary>
        public ReferenceEngineSettings()
            : base("Sandcastle.References.ReferenceEngineSettings", BuildEngineType.Reference)
        {
            _webMvcSdkType                  = BuildSpecialSdkType.Null;
            _rootContainer                  = false;
            _embedScriptSharp               = true;
            _includeAllMembersTopic         = true;
            _includeInheritedOverloadTopics = true;
            _refNamer  = ReferenceNamer.Orcas;
            _refNaming = ReferenceNamingMethod.Guid;

            IBuildNamedList <BuildConfiguration> configurations = this.Configurations;

            if (configurations != null)
            {
                // For the ReferenceVisitors...
                ReferenceCommentConfiguration comments =
                    new ReferenceCommentConfiguration();

                ReferenceSpellCheckConfiguration spellCheck =
                    new ReferenceSpellCheckConfiguration();

                ReferenceVisibilityConfiguration documentVisibility =
                    new ReferenceVisibilityConfiguration();

                ReferenceXPathConfiguration pathDocumentVisibility =
                    new ReferenceXPathConfiguration();
                pathDocumentVisibility.Enabled = false;

                // For the ReferenceTocVistors...
                ReferenceTocExcludeConfiguration excludeToc =
                    new ReferenceTocExcludeConfiguration();
                ReferenceTocLayoutConfiguration layoutToc =
                    new ReferenceTocLayoutConfiguration();

                configurations.Add(comments);
                configurations.Add(documentVisibility);
                configurations.Add(pathDocumentVisibility);
                configurations.Add(spellCheck);

                configurations.Add(excludeToc);
                configurations.Add(layoutToc);
            }

            IBuildNamedList <BuildComponentConfiguration> componentConfigurations
                = this.ComponentConfigurations;

            if (componentConfigurations != null)
            {
                ReferencePreTransConfiguration preTrans =
                    new ReferencePreTransConfiguration();

                ReferenceMissingTagsConfiguration missingTags =
                    new ReferenceMissingTagsConfiguration();

                ReferenceAutoDocConfiguration autoDocument =
                    new ReferenceAutoDocConfiguration();

                ReferenceIntelliSenseConfiguration intelliSense =
                    new ReferenceIntelliSenseConfiguration();

                ReferencePlatformsConfiguration platforms =
                    new ReferencePlatformsConfiguration();

                ReferenceCloneConfiguration cloneDocument =
                    new ReferenceCloneConfiguration();

                ReferencePostTransConfiguration postTrans =
                    new ReferencePostTransConfiguration();

                ReferenceCodeConfiguration codeComponent =
                    new ReferenceCodeConfiguration();

                ReferenceMathConfiguration mathComponent =
                    new ReferenceMathConfiguration();

                ReferenceMediaConfiguration mediaComponent =
                    new ReferenceMediaConfiguration();

                ReferenceLinkConfiguration linkComponent =
                    new ReferenceLinkConfiguration();

                ReferenceSharedConfiguration sharedComponent =
                    new ReferenceSharedConfiguration();

                componentConfigurations.Add(preTrans);
                componentConfigurations.Add(autoDocument);
                componentConfigurations.Add(missingTags);
                componentConfigurations.Add(intelliSense);
                componentConfigurations.Add(platforms);
                componentConfigurations.Add(cloneDocument);
                componentConfigurations.Add(postTrans);
                componentConfigurations.Add(codeComponent);
                componentConfigurations.Add(mathComponent);
                componentConfigurations.Add(mediaComponent);
                componentConfigurations.Add(linkComponent);
                componentConfigurations.Add(sharedComponent);
            }
        }
Example #5
0
        private void CreateLinkGroups(BuildContext context)
        {
            context["$EmbeddedScriptSharp"] = Boolean.FalseString;

            if (_listGroups == null || _listGroups.Count == 0)
            {
                return;
            }

            BuildLogger logger = context.Logger;

            List <ReferenceGroup>     buildGroups   = new List <ReferenceGroup>();
            IList <BuildGroupContext> groupContexts = context.GroupContexts;

            bool hasScriptSharp = false;
            BuildFrameworkType latestScriptSharp = BuildFrameworkType.None;

            int itemCount = _listGroups.Count;
            int index     = 0;

            for (int i = 0; i < itemCount; i++)
            {
                ReferenceGroup group = _listGroups[i];

                ReferenceContent content = group.Content;
                if (content != null)
                {
                    BuildFrameworkType frameworkType = content.FrameworkType;

                    if (frameworkType.Kind == BuildFrameworkKind.ScriptSharp)
                    {
                        hasScriptSharp = true;

                        if (frameworkType > latestScriptSharp)
                        {
                            latestScriptSharp = frameworkType;
                        }
                    }
                }
            }

            // Include contents from the Script# framework for correct
            // linking, since there is MSDN links for the Script#...
            if (hasScriptSharp && _engineSettings.EmbedScriptSharpFramework &&
                latestScriptSharp.Kind == BuildFrameworkKind.ScriptSharp)
            {
                BuildFramework framework = BuildFrameworks.GetFramework(latestScriptSharp);
                if (framework == null)
                {
                    framework = BuildFrameworks.LatestScriptSharp;
                }

                if (framework != null)
                {
                    ReferenceGroup buildGroup = new ReferenceGroup(
                        "Embedded ScriptSharp - " + ReferenceGroup.NextGroupName(),
                        Guid.NewGuid().ToString());

                    ReferenceContent content = buildGroup.Content;

                    string[] assemblies = Directory.GetFiles(framework.AssemblyDir,
                                                             "*.dll", SearchOption.AllDirectories);

                    for (int i = 0; i < assemblies.Length; i++)
                    {
                        string assembly = assemblies[i];
                        string comments = Path.ChangeExtension(assembly, ".xml");

                        if (File.Exists(comments))
                        {
                            content.AddItem(comments, assembly);
                        }
                    }

                    buildGroup.ExcludeToc = true;
                    buildGroup.SyntaxType = BuildSyntaxType.CSharp | BuildSyntaxType.JavaScript;

                    buildGroups.Add(buildGroup);

                    // Create the group context...
                    ReferenceGroupContext buildGroupContext =
                        new ReferenceGroupContext(buildGroup);
                    buildGroupContext.IsEmbeddedGroup = true;
                    groupContexts.Add(buildGroupContext);

                    string indexText = (itemCount + index + 1).ToString();

                    // Create the build dynamic properties...
                    buildGroupContext.CreateProperties(indexText);

                    // This has no effect, since the newly created group will
                    // not have any content source.
                    buildGroup.BeginSources(context);

                    context["$EmbeddedScriptSharp"] = Boolean.TrueString;
                }
            }

            if (buildGroups.Count != 0)
            {
                _listGroups.Add(buildGroups);
            }

            // Process the user-provided link sources...
            List <ReferenceLinkSource>  linkSources = null;
            IList <ReferenceLinkSource> listSources = _engineSettings.LinkSources as IList <ReferenceLinkSource>;

            if (listSources != null && listSources.Count != 0)
            {
                for (int i = 0; i < listSources.Count; i++)
                {
                    ReferenceLinkSource linkSource = listSources[i];

                    if (linkSource == null || !linkSource.IsValid)
                    {
                        if (logger != null)
                        {
                            string title = linkSource.Title;
                            if (title == null)
                            {
                                title = String.Empty;
                            }
                            logger.WriteLine(String.Format(
                                                 "A provided reference link source titled = '{0}', at index = '{1}' is invalid.",
                                                 title, i), BuildLoggerLevel.Warn);
                        }

                        continue;
                    }

                    if (linkSources == null)
                    {
                        linkSources = new List <ReferenceLinkSource>();
                    }

                    linkSources.Add(linkSource);
                }
            }

            // Process the automatic link sources...
            BuildSpecialSdkType webMvcSdkType = _engineSettings.WebMvcSdkType;

            if (webMvcSdkType != BuildSpecialSdkType.None &&
                webMvcSdkType != BuildSpecialSdkType.Null)
            {
                BuildSpecialSdk webSdk = BuildSpecialSdks.GetSdk(webMvcSdkType,
                                                                 BuildFrameworkKind.DotNet);

                if (webSdk != null)
                {
                    ReferenceLinkSource linkSource = new ReferenceLinkSource();
                    linkSource.LinkType      = BuildLinkType.Msdn;
                    linkSource.Title         = webMvcSdkType.Label;
                    linkSource.FrameworkType =
                        BuildFrameworks.LatestFramework.FrameworkType;

                    string aspMVCDir = webSdk.AssemblyDir;

                    string[] assemblyFiles = Directory.GetFiles(
                        webSdk.AssemblyDir, "*.dll", SearchOption.TopDirectoryOnly);

                    for (int i = 0; i < assemblyFiles.Length; i++)
                    {
                        string assemblyFile = assemblyFiles[i];
                        string commentFile  = Path.ChangeExtension(assemblyFile,
                                                                   ".xml");
                        if (File.Exists(commentFile))
                        {
                            ReferenceItem refItem = new ReferenceItem(
                                commentFile, assemblyFile);
                            refItem.XamlSyntax = false;
                            linkSource.Add(refItem);
                        }
                    }

                    if (linkSource.IsValid)
                    {
                        if (linkSources == null)
                        {
                            linkSources = new List <ReferenceLinkSource>();
                        }

                        linkSources.Add(linkSource);
                    }
                }
            }

            if (linkSources != null && linkSources.Count != 0)
            {
                context.SetValue("$ReferenceLinkSources", linkSources);

                itemCount = linkSources.Count;
                if (_linkGroups == null)
                {
                    _linkGroups = new BuildList <ReferenceGroup>();
                }

                for (int i = 0; i < itemCount; i++)
                {
                    ReferenceLinkSource linkSource = linkSources[i];

                    ReferenceGroup linkGroup = new ReferenceGroup(
                        "Reference Links - " + ReferenceGroup.NextGroupName(),
                        linkSource.SourceId, linkSource);

                    linkGroup.ExcludeToc = true;

                    _linkGroups.Add(linkGroup);

                    // Create the group context...
                    ReferenceGroupContext linkGroupContext =
                        new ReferenceGroupContext(linkGroup);
                    linkGroupContext.IsLinkGroup = true;
                    groupContexts.Add(linkGroupContext);

                    string indexText = String.Empty;
                    if (itemCount > 1)
                    {
                        indexText = (i + 1).ToString();
                    }

                    // Create the build dynamic properties...
                    linkGroupContext.CreateProperties(indexText);

                    // This has no effect, since the newly created group will
                    // not have any content source.
                    linkGroup.BeginSources(context);
                }
            }
        }