public IPrefetchHandle Build() { LinkedHashMap <Type, PrefetchPath[]> entityTypeToPrefetchSteps = LinkedHashMap <Type, PrefetchPath[]> .Create(entityTypeToPrefetchPaths.Count); foreach (Entry <Type, List <String> > entry in entityTypeToPrefetchPaths) { Type entityType = entry.Key; List <String> membersToInitialize = entry.Value; entityTypeToPrefetchSteps.Put(entityType, BuildCachePath(entityType, membersToInitialize)); } return(new PrefetchHandle(entityTypeToPrefetchSteps, CachePathHelper)); }
public IPrefetchHandle Union(IPrefetchHandle otherPrefetchHandle) { if (otherPrefetchHandle == null) { return(this); } LinkedHashMap <Type, CHashSet <AppendableCachePath> > newMap = LinkedHashMap <Type, CHashSet <AppendableCachePath> > .Create(entityTypeToPrefetchSteps.Count); foreach (Entry <Type, PrefetchPath[]> entry in entityTypeToPrefetchSteps) { CHashSet <AppendableCachePath> prefetchPaths = newMap.Get(entry.Key); if (prefetchPaths == null) { prefetchPaths = new CHashSet <AppendableCachePath>(); newMap.Put(entry.Key, prefetchPaths); } foreach (PrefetchPath cachePath in entry.Value) { prefetchPaths.Add(cachePathHelper.CopyCachePathToAppendable(cachePath)); } } foreach (Entry <Type, PrefetchPath[]> entry in ((PrefetchHandle)otherPrefetchHandle).entityTypeToPrefetchSteps) { CHashSet <AppendableCachePath> prefetchPaths = newMap.Get(entry.Key); if (prefetchPaths == null) { prefetchPaths = new CHashSet <AppendableCachePath>(); newMap.Put(entry.Key, prefetchPaths); } foreach (PrefetchPath cachePath in entry.Value) { AppendableCachePath clonedCachePath = cachePathHelper.CopyCachePathToAppendable(cachePath); if (prefetchPaths.Add(clonedCachePath)) { continue; } AppendableCachePath existingCachePath = prefetchPaths.Get(clonedCachePath); cachePathHelper.UnionCachePath(existingCachePath, clonedCachePath); } } LinkedHashMap <Type, PrefetchPath[]> targetMap = LinkedHashMap <Type, PrefetchPath[]> .Create(newMap.Count); foreach (Entry <Type, CHashSet <AppendableCachePath> > entry in newMap) { PrefetchPath[] cachePaths = cachePathHelper.CopyAppendableToCachePath(entry.Value); targetMap.Put(entry.Key, cachePaths); } return(new PrefetchHandle(targetMap, cachePathHelper)); }