public async Task <bool> LoadAsync(ListAddAsyncCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
            {
                // This source will load provided server, but only once — call .ReloadAsync() and server will be nicely removed.
                await callback(new[] { _information }.NonNull());

                _information = null;
                return(true);
            }
Beispiel #2
0
 public async Task <bool> LoadAsync(ListAddAsyncCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
 {
     if (_entries != null)
     {
         await callback(_entries).ConfigureAwait(false);
     }
     else
     {
         await callback(new ServerInformation[0]).ConfigureAwait(false);
     }
     return(true);
 }
Beispiel #3
0
        public async Task <bool> LoadAsync(ListAddAsyncCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
        {
            var data = await Task.Run(() => KunosApiProvider.TryToGetMinoratingList(), cancellation);

            // if (cancellation.IsCancellationRequested) return false;

            if (data == null)
            {
                throw new InformativeException(ToolsStrings.Online_CannotLoadData, ToolsStrings.Common_MakeSureInternetWorks);
            }

            await callback(data).ConfigureAwait(false);

            return(true);
        }
Beispiel #4
0
        public async Task <bool> LoadAsync(ListAddAsyncCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
        {
            if (SteamIdHelper.Instance.Value == null)
            {
                throw new Exception(ToolsStrings.Common_SteamIdIsMissing);
            }

            var data = await Task.Run(
                () => KunosApiProvider.TryToGetList(progress == null ? null : new ProgressConverter(progress)), cancellation);

            // if (cancellation.IsCancellationRequested) return false;

            if (data == null)
            {
                throw new InformativeException(ToolsStrings.Online_CannotLoadData, ToolsStrings.Common_MakeSureInternetWorks);
            }

            progress?.Report(AsyncProgressEntry.FromStringIndetermitate(ToolsStrings.OnlineSource_Loading_FinalStep));
            await callback(data).ConfigureAwait(false);

            return(true);
        }