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

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

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

            var result = default(hubiCContext);

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

                contextCache.Add(root, result = new hubiCContext(client, container));
            }
            return(result);
        }
Esempio n. 3
0
        private async Task <OneDriveContext> RequireContextAsync(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.LoginAsync(root.UserName, apiKey, settingsPassPhrase);

                var drive = await connection.GetDrive();

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