private void FindDeviceTypes(Type type, DeviceTypeCollection deviceTypes) { foreach (DeviceType t in this.DeviceTypes) { if (type.IsInterface) { if (t.Type.GetInterface(type.Name) != null) { deviceTypes.Add(t); } } else { if (Function.IsInheritableBaseType(t.Type, type) || t.Type.Equals(type)) { deviceTypes.Add(t); } } } foreach (DeviceTypeSort s in this.Children) { s.FindDeviceTypes(type, deviceTypes); } }
/// <summary> /// 获取所有继承自指定类型声明的设备类型。 /// </summary> /// <param name="type">设备类型声明</param> /// <returns>继承自指定类型声明的设备类型集合。</returns> public DeviceTypeCollection GetDeviceTypes(Type type) { DeviceTypeCollection deviceTypes = new DeviceTypeCollection(); this.FindDeviceTypes(type, deviceTypes); return(deviceTypes); }