Exemplo n.º 1
0
        private ArrayList GetMatchingKeys(UniqueId contextId)
        {
            if (contextId == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contextId));
            }
            ArrayList matchingKeys = new ArrayList(2);

            bool lockHeld = false;
            try
            {
                try { }
                finally
                {
                    CacheLock.AcquireReaderLock(-1);
                    lockHeld = true;
                }
                foreach (object key in Entries.Keys)
                {
                    bool isMatch;
                    if (key is UniqueId)
                    {
                        isMatch = (((UniqueId)key) == contextId);
                    }
                    else
                    {
                        isMatch = (((ContextAndGenerationKey)key).ContextId == contextId);
                    }
                    if (isMatch)
                    {
                        matchingKeys.Add(key);
                    }
                }
            }
            finally
            {
                if (lockHeld)
                {
                    CacheLock.ReleaseReaderLock();
                }
            }
            return matchingKeys;
        }