protected IEnumerable <IEntity> GetEntities( IRootDeviceInterface rootDeviceInterface, IMSearch mSearchReq) { IEnumerable <IEntity> entities; switch (mSearchReq.ST.StSearchType) { case STType.All: entities = GetAllEntities(rootDeviceInterface); break; case STType.RootDeviceSearch: entities = new List <IEntity> { rootDeviceInterface.RootDeviceConfiguration }; break; case STType.UIIDSearch: entities = GetAllDevices(rootDeviceInterface)? .Where(d => d.DeviceUUID == mSearchReq.ST.DeviceUUID); break; case STType.ServiceTypeSearch: case STType.DomainServiceSearch: entities = ServiceEntitiesMatchingSearch(rootDeviceInterface, mSearchReq); break; case STType.DeviceTypeSearch: case STType.DomainDeviceSearch: entities = DevicesEntitiesMatchingSearch(rootDeviceInterface, mSearchReq); break; default: throw new ArgumentOutOfRangeException(); } if (!entities?.Any() ?? false) { return(null); } return(entities); }
private IEnumerable <IEntity> ServiceEntitiesMatchingSearch(IRootDeviceInterface rootDeviceInterface, IMSearch mSearchReq) => GetAllServices(rootDeviceInterface)? .Where(s => { if (mSearchReq.ST.StSearchType == STType.ServiceTypeSearch || mSearchReq.ST.StSearchType == STType.All) { return(true); } if (mSearchReq.ST.StSearchType == STType.DomainServiceSearch) { return(s.Domain == mSearchReq.ST.Domain); } return(false); }) .Where(s => s.Version <= mSearchReq.ST.Version);