1
0
Форкнуть 0

shared: move more static values into instanced values.

In preparation for adding capture and replay proxies, more and more content cannot be static. In order to achieve this, as many static values are moved into instance values in the `Program` class.
This commit is contained in:
J Wyman ∞ 2018-07-16 15:56:41 -04:00
Родитель e5c0e5d9b6
Коммит 312e4c59a3
5 изменённых файлов: 44 добавлений и 12 удалений

Просмотреть файл

@ -94,7 +94,7 @@ namespace Microsoft.Alm.Cli
}
accessToken = buffer.ToString(0, (int)read);
accessToken = accessToken.Trim(Program.NewLineChars);
accessToken = accessToken.Trim(program.NewLineChars);
}
}
return accessToken != null;

Просмотреть файл

@ -86,9 +86,9 @@ namespace Microsoft.Alm.Cli
// Detect the authority.
authority = await Vsts.Authentication.GetAuthentication(program.Context,
operationArguments.TargetUri,
Program.VstsCredentialScope,
new SecretStore(program.Context, secretsNamespace, Vsts.Authentication.UriNameConversion))
operationArguments.TargetUri,
Program.VstsCredentialScope,
new SecretStore(program.Context, secretsNamespace, Vsts.Authentication.UriNameConversion))
?? Github.Authentication.GetAuthentication(program.Context,
operationArguments.TargetUri,
Program.GitHubCredentialScope,
@ -145,9 +145,9 @@ namespace Microsoft.Alm.Cli
// Create the authority object.
authority = new Vsts.AadAuthentication(program.Context,
tenantId,
operationArguments.VstsTokenScope,
new SecretStore(program.Context, secretsNamespace, Vsts.AadAuthentication.UriNameConversion));
tenantId,
operationArguments.VstsTokenScope,
new SecretStore(program.Context, secretsNamespace, Vsts.AadAuthentication.UriNameConversion));
}
// Return the allocated authority or a generic AAD backed VSTS authentication object.
@ -184,8 +184,8 @@ namespace Microsoft.Alm.Cli
// Return the allocated authority or a generic MSA backed VSTS authentication object.
return authority ?? new Vsts.MsaAuthentication(program.Context,
operationArguments.VstsTokenScope,
new SecretStore(program.Context, secretsNamespace, Vsts.MsaAuthentication.UriNameConversion));
operationArguments.VstsTokenScope,
new SecretStore(program.Context, secretsNamespace, Vsts.MsaAuthentication.UriNameConversion));
case AuthorityType.Ntlm:
// Enforce NTLM authentication only.

Просмотреть файл

@ -89,7 +89,7 @@ namespace Microsoft.Alm.Cli
}
authenticationCode = buffer.ToString(0, (int)read);
authenticationCode = authenticationCode.Trim(Program.NewLineChars);
authenticationCode = authenticationCode.Trim(program.NewLineChars);
}
return authenticationCode != null;

Просмотреть файл

@ -76,8 +76,6 @@ namespace Microsoft.Alm.Cli
internal const string ConfigPrefix = "credential";
internal const string SecretsNamespace = "git";
internal static readonly char[] NewLineChars = Environment.NewLine.ToCharArray();
internal static readonly Vsts.TokenScope VstsCredentialScope = Vsts.TokenScope.CodeWrite | Vsts.TokenScope.PackagingRead;
internal static readonly Github.TokenScope GitHubCredentialScope = Github.TokenScope.Gist | Github.TokenScope.Repo;
@ -162,6 +160,7 @@ namespace Microsoft.Alm.Cli
private readonly RuntimeContext _context;
private string _location;
private string _name;
private char[] _newlineChars;
private IntPtr _parentHwnd;
private Stream _stdErrStream;
private TextWriter _stdErrWriter;
@ -372,6 +371,22 @@ namespace Microsoft.Alm.Cli
internal INetwork Network
=> _context.Network;
internal char[] NewLineChars
{
get
{
lock (_syncpoint)
{
if (_newlineChars is null)
{
_newlineChars = Environment.NewLine.ToCharArray();
}
return _newlineChars;
}
}
}
internal TextWriter Out
{
get

Просмотреть файл

@ -280,6 +280,18 @@ namespace Microsoft.Alm.Win32
/// </summary>
NoToken = 1008,
/// <summary>
/// Element not found.
/// </summary>
NotFound = 1168,
/// <summary>
/// A specified logon session does not exist.
/// <para/>
/// It may already have been terminated.
/// </summary>
NoSuchLogonSession = 1312,
/// <summary>
/// A required privilege is not held by the client.
/// </summary>
@ -294,6 +306,11 @@ namespace Microsoft.Alm.Win32
/// Not enough quota is available to process this command.
/// </summary>
NotEnoughQuota = 1816,
/// <summary>
/// The specified username is invalid.
/// </summary>
BadUserName = 2202,
}
internal enum Hresult : uint