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; }
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); }
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); }