private void FindLogTypes(Type type, LogTypeCollection logTypes) { foreach (LogType t in this.LogTypes) { if (type.IsInterface) { if (t.Type.GetInterface(type.Name) != null) { logTypes.Add(t); } } else { if (Function.IsInheritableBaseType(t.Type, type) || t.Type.Equals(type)) { logTypes.Add(t); } } } foreach (LogTypeSort s in this.Children) { s.FindLogTypes(type, logTypes); } }
/// <summary> /// 获取所有继承自指定类型声明的日志类型。 /// </summary> /// <param name="type">日志类型声明或接口声明。</param> /// <returns>继承自指定类型声明的日志类型集合。</returns> public LogTypeCollection GetLogTypes(Type type) { LogTypeCollection logTypes = new LogTypeCollection(); this.FindLogTypes(type, logTypes); return(logTypes); }