/* * This file is part of the CatLib package. * * (c) CatLib * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Document: http://catlib.io/ */ using System; using System.Collections.Generic; namespace CatLib { /// /// 类型查询器引导 /// [ExcludeFromCodeCoverage] public sealed class BootstrapTypeFinder : IBootstrap { /// /// 程序集列表 /// private readonly IDictionary assemblies; /// /// 构建一个类型查询器引导 /// /// 需要添加的程序集 public BootstrapTypeFinder(IDictionary assembly = null) { assemblies = new Dictionary(); Dict.AddRange(assemblies, Assemblys.Assembly); Dict.AddRange(assemblies, assembly); } /// /// 引导程序接口 /// [Priority(10)] public void Bootstrap() { if (assemblies.Count <= 0) { return; } foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { int sort; if (!assemblies.TryGetValue(assembly.GetName().Name, out sort)) { continue; } var localAssembly = assembly; App.OnFindType((finder) => localAssembly.GetType(finder), sort); } } } }