internal static MethodModel GetFavoriteModel(AllJoynService service) { List <Favorite> favorites = GetAll(); foreach (var favorite in favorites) { if (service.Service.AboutData.DeviceId == favorite.DeviceId) { var navigationObject = service.Service.Objects.FirstOrDefault(o => o.Path == favorite.ObjectPath); if (navigationObject?.Interfaces != null) { var navigationInterface = navigationObject.Interfaces.FirstOrDefault(i => i.Name == favorite.InterfaceName); if (navigationInterface != null) { if (favorite.MethodName != null) { var method = navigationInterface.GetMethod(favorite.MethodName); if (method != null) { var model = new MethodModel { Service = service.Service, Interface = navigationInterface, Method = method }; return(model); } } } } } } return(null); }
internal static async Task SetAvailableFavorite(IEnumerable <Favorite> favorites, AllJoynService availableService) { foreach (var favorite in favorites) { if (availableService.Service.AboutData.DeviceId == favorite.DeviceId) { var navigationObject = availableService?.Service?.Objects?.FirstOrDefault(o => o != null & o.Path == favorite.ObjectPath); if (navigationObject != null && navigationObject.Interfaces == null) { // favorite method is not available not owning IBusObject is. await Dispatcher.Dispatch(() => { favorite.IsAvailableOwnerOnly = true; }); } else if (navigationObject?.Interfaces != null) { var navigationInterface = navigationObject.Interfaces.FirstOrDefault(i => i.Name == favorite.InterfaceName); if (navigationInterface != null) { if (favorite.MethodName != null) { var method = navigationInterface.GetMethod(favorite.MethodName); if (method != null) { // favorite method is available! await Dispatcher.Dispatch(() => { favorite.IsAvailable = true; favorite.Service = availableService.Service; favorite.Interface = navigationInterface; favorite.Method = method; }); } } } } } } }