/// <summary> /// Initializes a new <c>VssCredentials</c> instance with the specified windows and issued token /// credential. /// </summary> /// <param name="federatedCredential">The federated credential to use for authentication</param> /// <param name="promptType">CredentialPromptType.PromptIfNeeded if interactive prompts are allowed; otherwise, CredentialProptType.DoNotPrompt</param> /// <param name="scheduler">An optional <c>TaskScheduler</c> to ensure credentials prompting occurs on the UI thread</param> public VssCredentials( FederatedCredential federatedCredential, CredentialPromptType promptType, TaskScheduler scheduler) : this(federatedCredential, promptType, scheduler, null) { }
/// <summary> /// Initializes a new <c>VssCredentials</c> instance with the specified windows and issued token /// credential. /// </summary> /// <param name="federatedCredential">The federated credential to use for authentication</param> /// <param name="promptType">CredentialPromptType.PromptIfNeeded if interactive prompts are allowed; otherwise, CredentialProptType.DoNotPrompt</param> /// <param name="scheduler">An optional <c>TaskScheduler</c> to ensure credentials prompting occurs on the UI thread</param> /// <param name="credentialPrompt">An optional <c>IVssCredentialPrompt</c> to perform prompting for credentials</param> public VssCredentials( FederatedCredential federatedCredential, CredentialPromptType promptType, TaskScheduler scheduler, IVssCredentialPrompt credentialPrompt) { this.PromptType = promptType; if (promptType == CredentialPromptType.PromptIfNeeded && scheduler == null) { // If we use TaskScheduler.FromCurrentSynchronizationContext() here and this is executing under the UI // thread, for example from an event handler in a WinForms applications, this TaskScheduler will capture // the UI SyncrhonizationContext whose MaximumConcurrencyLevel is 1 and only has a single thread to // execute queued work. Then, if the UI thread invokes one of our synchronous methods that are just // wrappers that block until the asynchronous overload returns, and if the async Task queues work to // this TaskScheduler, like GitHub.Services.CommonGetTokenOperation.GetTokenAsync does, // this will produce an immediate deadlock. It is a much safer choice to use TaskScheduler.Default here // as it uses the .NET Framework ThreadPool to execute queued work. scheduler = TaskScheduler.Default; } if (federatedCredential != null) { m_federatedCredential = federatedCredential; m_federatedCredential.Scheduler = scheduler; m_federatedCredential.Prompt = credentialPrompt; } m_thisLock = new object(); }
/// <summary> /// Initializes a new <c>VssCredentials</c> instance with the specified windows and issued token /// credential. /// </summary> /// <param name="federatedCredential">The federated credential to use for authentication</param> /// <param name="promptType">CredentialPromptType.PromptIfNeeded if interactive prompts are allowed, otherwise CredentialProptType.DoNotPrompt</param> public VssCredentials( FederatedCredential federatedCredential, CredentialPromptType promptType) : this(federatedCredential, promptType, null) { }
/// <summary> /// Initializes a new <c>VssCredentials</c> instance with the specified windows and issued token /// credential. /// </summary> /// <param name="federatedCredential">The federated credential to use for authentication</param> public VssCredentials(FederatedCredential federatedCredential) : this(federatedCredential, EnvironmentUserInteractive ? CredentialPromptType.PromptIfNeeded : CredentialPromptType.DoNotPrompt) { }