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

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

                contextCache.Add(root, result = new OneDriveContext(client));
            }
            return(result);
        }
Exemplo n.º 2
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);
        }