예제 #1
0
        public object CacheCatalog(ComposablePartCatalogCacheWriter writer)
        {
            ThrowIfDisposed();

            Requires.NotNull(writer, "writer");

            List<object> subordinateCacheTokens = new List<object>();
            foreach (ComposablePartCatalog catalog in this.Catalogs)
            {
                ICachedComposablePartCatalog cachedCatalog = catalog as ICachedComposablePartCatalog;
                if (cachedCatalog == null)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Strings.CatalogIsNotCacheable, catalog.GetType()));
                }
                object subordinateCacheToken = cachedCatalog.CacheCatalog(writer);
                subordinateCacheTokens.Add(subordinateCacheToken);
            }

            IDictionary<string, object> metadata = new Dictionary<string, object>();
            metadata.WriteEnumerable(AttributedCacheServices.CacheKeys.SubordinateTokens, subordinateCacheTokens);

            object cacheToken = writer.WriteCache(
                this.GetType(),
                null,
                metadata,
                null);

            writer.WriteRootCacheToken(cacheToken);
            return cacheToken;
        }
예제 #2
0
        public object CacheCatalog(ComposablePartCatalogCacheWriter writer)
        {
            this.ThrowIfDisposed();

            Requires.NotNull(writer, "writer");

            object cacheToken = writer.WriteCache(
                this.GetType(),
                this.Parts,
                null,
                AttributedComposablePartCatalogSite.CreateForWriting());

            writer.WriteRootCacheToken(cacheToken);
            return cacheToken;
        }
예제 #3
0
        public object CacheCatalog(ComposablePartCatalogCacheWriter writer)
        {
            this.ThrowIfDisposed();

            Requires.NotNull(writer, "writer");

            IDictionary<string, object> metadata;
            if (this._isCached)
            {
                Assumes.NotNull(this._cacheCatalogMetadata);
                metadata = this._cacheCatalogMetadata;
            }
            else
            {
                AssemblyCatalog assemblyCatalog = this._innerCatalog as AssemblyCatalog;
                Assumes.NotNull(assemblyCatalog);
                metadata = new Dictionary<string, object>();
                metadata.WriteAssembly(assemblyCatalog.Assembly, this._useAssemblyIdentity);
            }

            object cacheToken = writer.WriteCache(
                this.GetType(),
                this.Parts,
                metadata,
                AttributedComposablePartCatalogSite.CreateForWriting(false));

            writer.WriteRootCacheToken(cacheToken);
            return cacheToken;
        }