private MegaContext RequireContext(RootName root, string apiKey = null)
        {
            if (root == null)
                throw new ArgumentNullException(nameof(root));

            var result = default(MegaContext);
            if (!contextCache.TryGetValue(root, out result)) {
                var client = Authenticator.Login(root.UserName, apiKey);
                contextCache.Add(root, result = new MegaContext(client));
            }
            return result;
        }
Exemplo n.º 2
0
        private MegaContext RequireContext(RootName root, string apiKey = null)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var result = default(MegaContext);

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

            var result = default(MegaContext);

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

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