internal IObservable <T> InvokePreLoaderWithObservable <T>(string preloaderName, PreLoadParameters parameters) { var instance = GetPreLoaderInstance <T>(preloaderName); string preloadedCacheKey = GetPreLoaderKey(preloaderName, instance, parameters); var expiration = instance.GetDataExpiration(); if (parameters == null) { parameters = new PreLoadParameters(); } //var observable = instance.GetData(parameters); var observable = Observable.Start(() => instance.GetData(parameters), Scheduler.Default) .Merge() .SubscribeOn(new NewThreadScheduler()); observable.Subscribe(f => { var result = new PreLoadResult(expiration, f); SetPreLoadedResult(preloadedCacheKey, result); }); return(observable); }
internal Task InvokePreLoader <T>(string preloaderName, PreLoadParameters parameters) { var key = GetKey(preloaderName); var instance = GetPreLoaderInstance <T>(preloaderName); string preloadedCacheKey = GetPreLoaderKey(preloaderName, instance, parameters); if (parameters == null) { parameters = new PreLoadParameters(); } var observable = (IObservable <T>)instance.GetData(parameters); var expiration = instance.GetDataExpiration(); observable.Subscribe(f => { var result = new PreLoadResult(expiration, f); SetPreLoadedResult(preloadedCacheKey, result); }); //await observable.ForEachAsync(x => Debug.WriteLine(x)); return(Task.CompletedTask); }
public bool TryGetPreLoadedData <T>(string name, out T value, PreLoadParameters parameters = null) { T valueInternal; var result = PreLoaderServiceCore.Instance.TryGetPreLoadedData <T>(name, parameters, out valueInternal); value = valueInternal; return(result); }
internal T GetCachedPreLoadedData <T>(string preloaderName, PreLoadParameters parameters) { var instance = GetPreLoaderInstance <T>(preloaderName); string preloadedCacheKey = GetPreLoaderKey(preloaderName, instance, parameters); var cachedData = MemoryCache.Get <T>(preloadedCacheKey); return(cachedData); }
internal bool TryGetPreLoadedData <T>(string name, PreLoadParameters parameters, out T value) { value = default(T); var cachedData = GetCachedPreLoadedData <T>(name, parameters); if (cachedData != null) { value = cachedData; return(true); } return(false); }
private string GetPreLoaderKey <T>(string preloaderName, IPreLoader <T> instance, PreLoadParameters parameters) { if (parameters == null) { parameters = new PreLoadParameters(); } string preloadedCacheKey = preloaderName; if (instance is IPreLoaderKey instanceKey) { preloadedCacheKey = $"{preloaderName}:{instanceKey.GetKey(parameters)}"; } return(preloadedCacheKey); }
public void InvokePreLoader <T>(string preloaderName, PreLoadParameters parameters = null) { var observable = PreLoaderServiceCore.Instance.InvokePreLoaderWithObservable <T>(preloaderName, parameters); }
public T GetPreLoadedData <T>(string name, PreLoadParameters parameters = null) { return(PreLoaderServiceCore.Instance.GetCachedPreLoadedData <T>(name, parameters)); }