Lucene.Net.Util.FieldCacheSanityChecker.GetAllDescendantReaderKeys C# (CSharp) Method

GetAllDescendantReaderKeys() private method

Checks if the seed is an IndexReader, and if so will walk the hierarchy of subReaders building up a list of the objects returned by {@code seed.getCoreCacheKey()}
private GetAllDescendantReaderKeys ( object seed ) : IList
seed object
return IList
        private IList<object> GetAllDescendantReaderKeys(object seed)
        {
            var all = new List<object>(17) {seed}; // will grow as we iter
            for (var i = 0; i < all.Count; i++)
            {
                var obj = all[i];
                // TODO: We don't check closed readers here (as getTopReaderContext
                // throws AlreadyClosedException), what should we do? Reflection?
                var reader = obj as IndexReader;
                if (reader != null)
                {
                    try
                    {
                        var childs = reader.Context.Children;
                        if (childs != null) // it is composite reader
                        {
                            foreach (var ctx in childs)
                            {
                                all.Add(ctx.Reader.CoreCacheKey);
                            }
                        }
                    }
                    catch (AlreadyClosedException)
                    {
                        // ignore this reader
                    }
                }
            }
            // need to skip the first, because it was the seed
            return all.GetRange(1, all.Count - 1);
        }