public CachedTypeCatalog(ComposablePartCatalogCache cache) { Requires.NotNull(cache, "cache"); ComposablePartCatalog cacheCatalog = cache.GetCacheCatalog(AttributedComposablePartCatalogSite.CreateForReading()); List <Type> notUpToDateTypes = new List <Type>(); List <ComposablePartDefinition> upToDateParts = new List <ComposablePartDefinition>(); foreach (ComposablePartDefinition partDefinition in cacheCatalog.Parts) { if (!partDefinition.IsPartDefinitionCacheUpToDate()) { notUpToDateTypes.Add(ReflectionModelServices.GetPartType(partDefinition).Value); } else { upToDateParts.Add(partDefinition); } } if (notUpToDateTypes.Count == 0) { // everything is up to date, we can use the cached catalog this._cacheCatalog = cacheCatalog; } else { // some parts are not up-to-date, we will not query the catalog, but rather a combination of the type catalog and up-to-date parts this._upToDateParts = upToDateParts; this._typeCatalog = new TypeCatalog(notUpToDateTypes); } }
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); }
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); }
public CachedAssemblyCatalog(ComposablePartCatalogCache cache) { Requires.NotNull(cache, "cache"); this._useAssemblyIdentity = cache.Metadata.IsAssemblyIdentityStored(); // if the assembly hasn't been changed since the caching, then load the cache if (cache.Metadata.IsAssemblyCacheUpToDate()) { this._cacheCatalogMetadata = cache.Metadata; this._innerCatalog = cache.GetCacheCatalog(AttributedComposablePartCatalogSite.CreateForReading(() => this.Assembly)); this._isCached = true; } else { // just load the assembly given the information we have this._innerCatalog = new AssemblyCatalog(cache.Metadata.ReadAssembly()); this._isCached = false; } }