Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReferenceLinkSource"/> class
 /// with parameters copied from the specified instance of the
 /// <see cref="ReferenceLinkSource"/> class, a copy constructor.
 /// </summary>
 /// <param name="source">
 /// An instance of the <see cref="ReferenceLinkSource"/> 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 ReferenceLinkSource(ReferenceLinkSource source)
     : base(source)
 {
     _linkType      = source._linkType;
     _sourceId      = source._sourceId;
     _listItems     = source._listItems;
     _dependencies  = source._dependencies;
     _frameworkType = source._frameworkType;
 }
        public bool ContainsLinkSource(ReferenceLinkSource linkSource)
        {
            if (linkSource == null || _topicLinks == null ||
                _topicLinks.Count == 0)
            {
                return(false);
            }

            return(_topicLinks.Contains(linkSource));
        }
        public void InsertLinkSource(int index, ReferenceLinkSource linkSource)
        {
            BuildExceptions.NotNull(linkSource, "linkSource");
            if (_topicLinks == null)
            {
                _topicLinks = new BuildList <ReferenceLinkSource>();
            }

            _topicLinks.Insert(index, linkSource);
        }
        public bool RemoveLinkSource(ReferenceLinkSource linkSource)
        {
            BuildExceptions.NotNull(linkSource, "linkSource");

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

            return(_topicLinks.Remove(linkSource));
        }
        public void AddLinkSource(ReferenceLinkSource linkSource)
        {
            BuildExceptions.NotNull(linkSource, "linkSource");

            if (_topicLinks == null)
            {
                _topicLinks = new BuildList <ReferenceLinkSource>();
            }

            _topicLinks.Add(linkSource);
        }
Exemple #6
0
        public override ReferenceSource Clone()
        {
            ReferenceLinkSource source = new ReferenceLinkSource(this);

            this.Clone(source);

            if (_sourceId != null)
            {
                source._sourceId = String.Copy(_sourceId);
            }
            if (_listItems != null)
            {
                source._listItems = _listItems.Clone();
            }
            if (_dependencies != null)
            {
                source._dependencies = _dependencies.Clone();
            }

            return(source);
        }
        protected override void OnWriteXml(XmlWriter writer)
        {
            // Write the general properties
            writer.WriteStartElement("propertyGroup"); // start - propertyGroup;
            writer.WriteAttributeString("name", "General");
            writer.WritePropertyElement("Namer", _refNamer.ToString());
            writer.WritePropertyElement("Naming", _refNaming.ToString());
            writer.WritePropertyElement("RootNamespaceContainer", _rootContainer);
            writer.WritePropertyElement("EmbedScriptSharpFramework", _embedScriptSharp);
            writer.WritePropertyElement("WebMvcSdkType", _webMvcSdkType.ToString());
            writer.WriteEndElement();            // end - propertyGroup

            if (_topicLinks != null && _topicLinks.Count != 0)
            {
                writer.WriteComment(
                    " The link sources for this reference group. ");
                for (int i = 0; i < _topicLinks.Count; i++)
                {
                    ReferenceLinkSource linkSource = _topicLinks[i];
                    linkSource.WriteXml(writer);
                }
            }
        }
        /// <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);
        }
        /// <summary>
        /// Applies the processing operations defined by this visitor to the
        /// specified reference group.
        /// </summary>
        /// <param name="group">
        /// The <see cref="ReferenceGroup">reference group</see> to which the processing
        /// operations defined by this visitor will be applied.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="group"/> is <see langword="null"/>.
        /// </exception>
        protected override void OnVisit(ReferenceGroup group)
        {
            BuildExceptions.NotNull(group, "group");

            if (!this.IsInitialized)
            {
                throw new BuildException(
                          "ReferenceProjectVisitor: The reference dependency resolver is not initialized.");
            }

            BuildContext context = this.Context;
            BuildLogger  logger  = context.Logger;

            if (logger != null)
            {
                logger.WriteLine("Begin - Resolving reference dependencies.",
                                 BuildLoggerLevel.Info);
            }

            ReferenceGroupContext groupContext = context.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.");
            }

            ReferenceGroupContext sourceContext = groupContext;

            if (!String.IsNullOrEmpty(_sourceId))
            {
                sourceContext = groupContext.Contexts[_sourceId]
                                as ReferenceGroupContext;
            }

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

            _linkCommentFiles  = new List <string>();
            _bindingRedirects  = new List <DependencyItem>();
            _searchDirectories = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            sourceContext.LinkCommentFiles = _linkCommentFiles;
            sourceContext.BindingRedirects = _bindingRedirects;

            // We add the comment files from the link sources so that the
            // document can contain comments from these sources if needed...
            IList <ReferenceLinkSource> linkSources = context.GetValue("$ReferenceLinkSources")
                                                      as IList <ReferenceLinkSource>;

            if (linkSources != null && linkSources.Count != 0)
            {
                for (int i = 0; i < linkSources.Count; i++)
                {
                    ReferenceLinkSource         linkSource = linkSources[i];
                    IEnumerable <ReferenceItem> linkItems  = linkSource.Items;
                    foreach (ReferenceItem linkItem in linkItems)
                    {
                        // Set if the comment file exists and link it...
                        BuildFilePath linkCommentPath = linkItem.Comments;
                        if (linkCommentPath != null && linkCommentPath.Exists)
                        {
                            _linkCommentFiles.Add(linkCommentPath.Path);
                        }
                        else
                        {
                            string linkCommentFile = Path.ChangeExtension(
                                linkItem.Assembly, ".xml");
                            if (File.Exists(linkCommentFile))
                            {
                                _linkCommentFiles.Add(linkCommentFile);
                            }
                        }
                    }
                }
            }

            string dependencyDir = sourceContext.DependencyDir;

            string searchDir = String.Copy(dependencyDir);

            if (!searchDir.EndsWith("\\"))
            {
                searchDir += "\\";
            }

            _searchDirectories.Add(searchDir);

            ReferenceContent content = _content;

            if (content == null)
            {
                content = group.Content;
            }

            DependencyContent dependencies = content.Dependencies;

            _dependencyContent = dependencies;

            this.ResolveDependency(sourceContext, content);

            if (_dependencyContent != null && _dependencyContent.Count != 0)
            {
                this.CreateDependency(_dependencyContent, dependencyDir);
            }
            if (_resolveContent != null && _resolveContent.Count != 0)
            {
                this.CreateDependency(_resolveContent, dependencyDir);
            }

            //IList<string> bindingSources = sourceContext.BindingSources;
            //if (bindingSources == null)
            //{
            //    bindingSources = new BuildList<string>();
            //    sourceContext.BindingSources = bindingSources;
            //}
            //foreach (string dir in _searchDirectories)
            //{
            //    bindingSources.Add(dir);
            //}

            if (logger != null)
            {
                logger.WriteLine("Completed - Resolving reference dependencies.",
                                 BuildLoggerLevel.Info);
            }
        }
        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;
                        }
                    }
                }
            }
        }
Exemple #11
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);
                }
            }
        }