Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Created February 14, 2012 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/1827898 to your computer and use it in GitHub Desktop.
Save cromwellryan/1827898 to your computer and use it in GitHub Desktop.
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