//处理定义在类上的扩展器 public static void ExtenderInit <T, TA>(IObjectService objectService, T instance, IDictionary items = null) where TA : ServiceExtenderAttribute { var attributes = objectService.AsObjectServiceInternal().CoreAttributes; if (!attributes.TryGetValue(typeof(TA), out var list)) { return; } if (list == null || list.Count <= 0) { return; } items = items ?? new Hashtable(); var orderList = list.OrderByDescending(x => x.Priority); foreach (TA attribute in orderList) { var type = attribute?.OwnerType; if (type != null) { var extender = objectService.GetOrCreateObject(type) as IObjectExtender <T>; extender?.Init(instance, items); } } }
internal static void Init(IObjectService objectService, IHostBuilderInternal builder) { if (initialized) //保证只初始化一次 { return; } initialized = true; var coreAttributes = objectService.AsObjectServiceInternal().CoreAttributes; if (coreAttributes.TryGetValue(typeof(HostStartupAttribute), out var list)) { var startupTypes = list.OrderByDescending(x => x.Priority).Select(x => x.OwnerType).ToArray(); foreach (var type in startupTypes) { var startup = objectService.GetOrCreateObject(type) as IHostStartup; startup?.Init(builder); } } }