Esempio n. 1
0
 public Task <bool> LoadAsync(ListAddCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
 {
     // This source will load provided server, but only once — call .ReloadAsync() and server will be nicely removed.
     callback(new[] { _information }.NonNull());
     _information = null;
     return(Task.FromResult(true));
 }
Esempio n. 2
0
            public Task <bool> LoadAsync(ListAddCallback <ServerInformation> callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
            {
                if (_entries != null)
                {
                    callback(_entries);
                }
                else
                {
                    callback(new ServerInformation[0]);
                }

                return(Task.FromResult(true));
            }
Esempio n. 3
0
        public async Task <bool> LoadAsync(ListAddCallback <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);
            }

            callback(data);
            return(true);
        }
Esempio n. 4
0
        public async Task <bool> LoadAsync(ListAddCallback <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("Applying list…"));
            callback(data);
            return(true);
        }