コード例 #1
0
        public void ResolveGenericDictionary()
        {
            MsdnResolver resolver = new MsdnResolver();
            Uri          uri      = resolver.ResolveAssetId(Naming.GetAssetId(typeof(System.Collections.Generic.Dictionary <,>)), null);

            Debug.WriteLine(uri.ToString());
            Assert.NotNull(uri);
        }
コード例 #2
0
        public void ResolveInheritedPropertyOnDeclaringType()
        {
            MsdnResolver resolver = new MsdnResolver();
            Uri          uri      = resolver.ResolveAssetId("P:System.Reflection.MethodBase.ContainsGenericParameters", null);

            Debug.WriteLine(uri.ToString());
            Assert.NotNull(uri);
        }
コード例 #3
0
        public void ResolveSystemString()
        {
            MsdnResolver resolver = new MsdnResolver();
            Uri          uri      = resolver.ResolveAssetId("T:System.String", null);

            Debug.WriteLine(uri.ToString());
            Assert.NotNull(uri);
        }
コード例 #4
0
        /// <summary>
        /// This is overridden to allow use of an SQL backed MSDN content ID cache
        /// </summary>
        /// <param name="configuration">The component configuration</param>
        /// <returns>An MSDN resolver instance</returns>
        protected override MsdnResolver CreateMsdnResolver(XPathNavigator configuration)
        {
            MsdnResolver resolver;
            IDictionary <string, string> cache = null;
            int localCacheSize;

            if (BuildComponentCore.Data.ContainsKey(SharedMsdnContentIdCacheId))
            {
                cache = BuildComponentCore.Data[SharedMsdnContentIdCacheId] as IDictionary <string, string>;
            }

            // If the shared cache already exists, return an instance that uses it.  It is assumed that all
            // subsequent instances will use the same cache.
            if (cache != null)
            {
                return(new MsdnResolver(cache, true));
            }

            XPathNavigator node = configuration.SelectSingleNode("msdnContentIdCache");

            // If a <cache> element is not specified, use the default resolver
            if (node == null)
            {
                resolver = base.CreateMsdnResolver(configuration);
            }
            else
            {
                node = configuration.SelectSingleNode("sqlCache");
                string connectionString = node.GetAttribute("connectionString", String.Empty);

                // If a connection string is not defined, use the default resolver
                if (String.IsNullOrWhiteSpace(connectionString))
                {
                    resolver = base.CreateMsdnResolver(configuration);
                }
                else
                {
                    string cacheSize = node.GetAttribute("msdnLocalCacheSize", String.Empty);

                    if (String.IsNullOrWhiteSpace(cacheSize) || !Int32.TryParse(cacheSize, out localCacheSize))
                    {
                        localCacheSize = 2500;
                    }

                    // Load or create the cache database and the resolver.  The resolver will dispose of the
                    // dictionary when it is disposed of since it implements IDisposable.
                    resolver = new MsdnResolver(new SqlDictionary <string>(connectionString, "ContentIds",
                                                                           "TargetKey", "ContentId")
                    {
                        LocalCacheSize = localCacheSize
                    }, false);

                    int cacheCount = resolver.MsdnContentIdCache.Count;

                    if (cacheCount == 0)
                    {
                        // Log a diagnostic message since looking up all IDs can significantly slow the build
                        base.WriteMessage(MessageLevel.Diagnostic, "The SQL MSDN content ID cache in '" +
                                          connectionString + "' does not exist yet.  All IDs will be looked up in this " +
                                          "build which will slow it down.");
                    }
                    else
                    {
                        base.WriteMessage(MessageLevel.Info, "{0} cached MSDN content ID entries exist", cacheCount);
                    }

                    BuildComponentCore.Data[SharedMsdnContentIdCacheId] = resolver.MsdnContentIdCache;
                }
            }

            return(resolver);
        }
コード例 #5
0
        /// <summary>
        /// This is overridden to allow use of an ESENT backed MSDN content ID cache
        /// </summary>
        /// <param name="configuration">The component configuration</param>
        /// <returns>An MSDN resolver instance</returns>
        protected override MsdnResolver CreateMsdnResolver(XPathNavigator configuration)
        {
            MsdnResolver resolver;
            IDictionary <string, string> cache = null;
            int localCacheSize;

            if (BuildComponentCore.Data.ContainsKey(SharedMsdnContentIdCacheId))
            {
                cache = BuildComponentCore.Data[SharedMsdnContentIdCacheId] as IDictionary <string, string>;
            }

            // If the shared cache already exists, return an instance that uses it.  It is assumed that all
            // subsequent instances will use the same cache.
            if (cache != null)
            {
                return(new MsdnResolver(cache, true));
            }

            XPathNavigator node = configuration.SelectSingleNode("msdnContentIdCache");

            // If an <msdnContentIdCache> element is not specified, use the default resolver
            if (node == null)
            {
                resolver = base.CreateMsdnResolver(configuration);
            }
            else
            {
                string msdnIdCachePath = node.GetAttribute("cachePath", String.Empty);

                // If a cache path is not defined, use the default resolver
                if (String.IsNullOrWhiteSpace(msdnIdCachePath))
                {
                    resolver = base.CreateMsdnResolver(configuration);
                }
                else
                {
                    msdnIdCachePath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(msdnIdCachePath));

                    string cacheSize = node.GetAttribute("localCacheSize", String.Empty);

                    if (String.IsNullOrWhiteSpace(cacheSize) || !Int32.TryParse(cacheSize, out localCacheSize))
                    {
                        localCacheSize = 2500;
                    }

                    // Load or create the cache database and the resolver.  The resolver will dispose of the
                    // dictionary when it is disposed of since it implements IDisposable.  We won't compress the
                    // columns as they're typically not that big and there aren't usually that many entries.
                    // This gives a slight performance increase.
                    resolver = new MsdnResolver(new PersistentDictionary <string, string>(msdnIdCachePath, false)
                    {
                        LocalCacheSize = localCacheSize
                    }, false);

                    // We own the cache and will report statistics when done
                    ownsResolverCache = true;

                    int cacheCount = resolver.MsdnContentIdCache.Count;

                    if (cacheCount == 0)
                    {
                        // Log a diagnostic message since looking up all IDs can significantly slow the build
                        this.WriteMessage(MessageLevel.Diagnostic, "The ESENT MSDN content ID cache in '" +
                                          msdnIdCachePath + "' does not exist yet.  All IDs will be looked up in this build " +
                                          "which will slow it down.");
                    }
                    else
                    {
                        this.WriteMessage(MessageLevel.Info, "{0} cached MSDN content ID entries exist", cacheCount);
                    }

                    BuildComponentCore.Data[SharedMsdnContentIdCacheId] = resolver.MsdnContentIdCache;
                }
            }

            return(resolver);
        }