コード例 #1
0
        protected ICacheWalkerResult WalkIntern(IObjRef[] objRefs, IdentityHashSet <ICache> allCachesSet)
        {
            IdentityHashMap <ICache, List <ICache> > cacheToChildCaches = new IdentityHashMap <ICache, List <ICache> >();
            IdentityHashMap <ICache, ICache>         cacheToProxyCache  = new IdentityHashMap <ICache, ICache>();

            ICache currentCommittedRootCache = CommittedRootCache.CurrentCache;

            if (!CacheProvider.IsNewInstanceOnCall)
            {
                allCachesSet.Add(FirstLevelCache.CurrentCache);
            }

            ICache[] allChildCaches = allCachesSet.ToArray();

            allCachesSet.Add(currentCommittedRootCache);
            foreach (ICache childCache in allChildCaches)
            {
                ICache child  = childCache;
                ICache parent = ((ChildCache)child).Parent;
                while (parent != null)
                {
                    ICache currentParent = parent.CurrentCache;

                    if (!allCachesSet.Add(currentParent))
                    {
                        // skip this cache. we handled it already
                        break;
                    }
                    CheckParentCache(parent, currentParent, child, cacheToChildCaches, cacheToProxyCache);
                    parent = ((IRootCache)currentParent).Parent;
                    child  = currentParent;
                }
                CheckParentCache(CommittedRootCache, currentCommittedRootCache, child, cacheToChildCaches, cacheToProxyCache);
            }
            if (objRefs != allEntityRefs)
            {
                objRefs = new CHashSet <IObjRef>(objRefs).ToArray();
                Array.Sort(objRefs, ObjRef.comparator);
            }
            CacheWalkerResult rootEntry = BuildWalkedEntry(currentCommittedRootCache, objRefs, cacheToChildCaches, cacheToProxyCache);

            if (objRefs == allEntityRefs)
            {
                HashMap <IObjRef, int?> allObjRefs = new HashMap <IObjRef, int?>();
                CollectAllObjRefs(rootEntry, allObjRefs);
                objRefs = allObjRefs.Count > 0 ? ListUtil.ToArray(allObjRefs.KeyList()) : ObjRef.EMPTY_ARRAY;
                Array.Sort(objRefs, ObjRef.comparator);
                for (int a = objRefs.Length; a-- > 0;)
                {
                    allObjRefs.Put(objRefs[a], a);
                }
                ReallocateObjRefsAndCacheValues(rootEntry, objRefs, allObjRefs);
            }
            return(rootEntry);
        }