Created
February 14, 2012 16:24
-
-
Save cromwellryan/1827898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using EchelonTouchInc.Gister.Api; | |
using EchelonTouchInc.Gister.Api.Credentials; | |
namespace EchelonTouchInc.Gister | |
{ | |
public class RetrievesUserEnteredCredentials : RetrievesCredentials | |
{ | |
public RetrievesUserEnteredCredentials() | |
{ | |
CreatePrompt = () => new GitHubCredentialsPrompt(); | |
} | |
private GitHubCredentials GetCredentials() | |
{ | |
var prompt = CreatePrompt(); | |
prompt.Prompt(); | |
if (prompt.Result != true) | |
return GitHubCredentials.Anonymous; | |
return new GitHubUserCredentials(prompt.Username, prompt.Password); | |
} | |
public bool IsAvailable() | |
{ | |
return true; | |
} | |
public Func<CredentialsPrompt> CreatePrompt { get; set; } | |
public GitHubCredentials Retrieve() | |
{ | |
return GetCredentials(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment