Catel.Reflection.TypeCache.GetTypesPrefilteredByAssembly C# (CSharp) Method

GetTypesPrefilteredByAssembly() private static method

Gets the types prefiltered by assembly. If types must be retrieved from a single assembly only, this method is very fast.
private static GetTypesPrefilteredByAssembly ( string assemblyName, bool>.Func predicate ) : System.Type[]
assemblyName string Name of the assembly.
predicate bool>.Func The predicate.
return System.Type[]
        private static Type[] GetTypesPrefilteredByAssembly(string assemblyName, Func<Type, bool> predicate)
        {
            InitializeTypes();

            // IMPORTANT NOTE!!!! DON'T USE LOGGING IN THE CODE BELOW BECAUSE IT MIGHT CAUSE DEADLOCK (BatchLogListener will load
            // async stuff which can deadlock). Keep it simple without calls to other code. Do any type initialization *outside* 
            // the lock and make sure not to make calls to other methods

            lock (_lockObject)
            {
                Dictionary<string, Type> typeSource = null;
                if (!string.IsNullOrWhiteSpace(assemblyName))
                {
                    _typesByAssembly.TryGetValue(assemblyName, out typeSource);
                }
                else
                {
                    typeSource = _typesWithAssembly;
                }

                if (typeSource == null)
                {
                    return new Type[] { };
                }

                int retryCount = 3;
                while (retryCount > 0)
                {
                    retryCount--;

                    try
                    {
                        if (predicate != null)
                        {
                            return typeSource.Values.Where(predicate).ToArray();
                        }

                        return typeSource.Values.ToArray();
                    }
                    catch (Exception)
                    {
                    }
                }

                return new Type[] { };
            }

            // IMPORTANT NOTE: READ NOTE ABOVE BEFORE EDITING THIS METHOD!!!!
        }