public BaseViewModel( INavigation <Domain.Interfaces.NavigationModes> navigationService , IStorage storageService , ISettings settingsService , IUxService uxService , IPeerConnector peerConnector) { _navigationService = navigationService; _storageService = storageService; _settingsService = settingsService; _uxService = uxService; _peerConnector = peerConnector; Broker = new ServicesEngine.ServiceBroker(_settingsService.AppKey(), _settingsService.AppVersion()); _peerConnector.ConnectionStatusChanged += _peerConnector_ConnectionStatusChanged; _peerConnector.GuideReceived += _peerConnector_GuideReceived; }
public static async Task DoLogOut(Interfaces.IStorage storageService, Interfaces.IUxService uxService, ServicesEngine.ServiceBroker broker) { await broker.DoLogout(AppBase.Current.User); AppBase.Current.User = null; await storageService.Delete(Constants.AUTHORIZATION); }
public static async Task <RESTModels.Category.RootObject> GetCategoryContent(string idCategory, Interfaces.IStorage storageService, ServicesEngine.ServiceBroker broker) { Debug.WriteLine($"going for :{idCategory}"); var isCategoryCached = await storageService.Exists(Constants.CATEGORIES + idCategory, new TimeSpan(0, 12, 0, 0)); RESTModels.Category.RootObject category; if (isCategoryCached) { var rd = await storageService.ReadData(Constants.CATEGORIES + idCategory); category = rd.LoadFromJson <RESTModels.Category.RootObject>(); Debug.WriteLine($"loaded from cache :{idCategory}"); } else { Debug.WriteLine($"getting from service :{idCategory}"); category = await broker.GetCategory(idCategory); await storageService.WriteData(Constants.CATEGORIES + idCategory, category.SaveAsJson()); Debug.WriteLine($"caching from service :{idCategory}"); } // Process(category.contents_raw); return(category); }