Golem.Core.RecipeCataloger.PreLoadAssembliesToPreventAssemblyNotFoundError C# (CSharp) Method

PreLoadAssembliesToPreventAssemblyNotFoundError() private method

private PreLoadAssembliesToPreventAssemblyNotFoundError ( FileInfo assemblyFiles ) : void
assemblyFiles System.IO.FileInfo
return void
        private void PreLoadAssembliesToPreventAssemblyNotFoundError(FileInfo[] assemblyFiles)
        {
            //TODO: Preloading all assemblies in the solution is BRUTE FORCE! Should separate discovery of recipes
            //      from invocation. Perhpas use LoadForReflection during discovery. We'd then need to have
            //      Assemblies loaded for real before invokation (see TaskRunner), along with satellite assemblies.

            foreach (var file in assemblyFiles)
                //loading the core twice is BAD because "if(blah is RecipeAttribute)" etc will always fail
                if( ! file.Name.StartsWith("Golem.Core") && ! LoadedAssemblies.Any(la=>la.File.Name == file.Name))
                {
                    try
                    {
                        var i =  new LoadedAssemblyInfo
                                {
                                    Assembly = Assembly.LoadFrom(file.FullName),
                                    File = file
                                };
                        _loadedAssemblies.Add(i);
                    }
                    catch (Exception e)
                    {
                        //Console.WriteLine("Ooops: " + e.Message);
                    }
                }
        }