Ejemplo n.º 1
0
        private async Task <YandexContext> RequireContextAsync(RootName root, string apiKey = null)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var result = default(YandexContext);

            if (!contextCache.TryGetValue(root, out result))
            {
                var client = await OAuthAuthenticator.LoginAsync(root.UserName, apiKey, settingsPassPhrase);

                contextCache.Add(root, result = new YandexContext(client));
            }
            return(result);
        }
Ejemplo n.º 2
0
        private async Task <bool> OperationProgressAsync(YandexContext context, Link link)
        {
            if (link.HttpStatusCode == System.Net.HttpStatusCode.Accepted)
            {
                var operation = default(Operation);
                do
                {
                    Thread.Sleep(100);
                    operation = await context.Client.Commands.GetOperationStatus(link, CancellationToken.None);

                    if (operation.Status == OperationStatus.Failure)
                    {
                        return(false);
                    }
                } while (operation.Status == OperationStatus.InProgress);
            }
            return(true);
        }