private async Task<pCloudContext> RequireContext(RootName root, string apiKey = null)
        {
            if (root == null)
                throw new ArgumentNullException(nameof(root));

            var result = default(pCloudContext);
            if (!contextCache.TryGetValue(root, out result)) {
                var client = await Authenticator.Login(root.UserName, apiKey);
                contextCache.Add(root, result = new pCloudContext(client));
            }
            return result;
        }
Ejemplo n.º 2
0
        private async Task <pCloudContext> RequireContextAsync(RootName root, string apiKey = null)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var result = default(pCloudContext);

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

                contextCache.Add(root, result = new pCloudContext(client));
            }
            return(result);
        }