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

            var result = default(BoxContext);

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

                contextCache.Add(root, result = new BoxContext(client));
            }
            return(result);
        }
Esempio n. 2
0
        private async Task <OneDriveContext> RequireContext(RootName root, string apiKey = null)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var result = default(OneDriveContext);

            if (!contextCache.TryGetValue(root, out result))
            {
                var connection = await OAuthAuthenticator.Login(root.UserName, apiKey);

                var drive = await connection.GetDrive();

                contextCache.Add(root, result = new OneDriveContext(connection, drive));
            }
            return(result);
        }