/// <summary>
 /// 条件查询
 /// </summary>
 /// <param name="autoRegisterData">自动注册数据</param>
 /// <param name="predicate">查询条件</param>
 public static AutoRegisterData Where(this AutoRegisterData autoRegisterData, Func <Type, bool> predicate)
 {
     if (autoRegisterData == null)
     {
         throw new ArgumentNullException(nameof(autoRegisterData));
     }
     autoRegisterData.TypeFilter = predicate;
     return(new AutoRegisterData(autoRegisterData.Services, autoRegisterData.InjectionTypes.Where(predicate)));
 }
        /// <summary>
        /// 将类实现的任何公共接口(IDisposable除外)进行注册
        /// </summary>
        /// <param name="autoRegisterData">自动注册数据</param>
        /// <param name="lifetime">生命周期</param>
        public static IServiceCollection AsPublicImplementedInterfaces(this AutoRegisterData autoRegisterData,
                                                                       ServiceLifetime lifetime = ServiceLifetime.Transient)
        {
            if (autoRegisterData == null)
            {
                throw new ArgumentNullException(nameof(autoRegisterData));
            }
            foreach (var classType in (autoRegisterData.TypeFilter == null ? autoRegisterData.InjectionTypes : autoRegisterData.InjectionTypes.Where(autoRegisterData.TypeFilter)))
            {
                var interfaces = classType.GetTypeInfo().ImplementedInterfaces.Where(x => x != typeof(IDisposable) && x.IsPublic);
                foreach (var @interface in interfaces)
                {
                    autoRegisterData.Services.Add(new ServiceDescriptor(@interface, classType, lifetime));
                }
            }

            return(autoRegisterData.Services);
        }