Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(UnityExecutorResponseResult) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : UnityLicensor.cs
with MIT License
from RedpointGames
with MIT License
from RedpointGames
private async Task<UnityLicenseStatusCheck> RunUnityAndCaptureMachineKeys()
{
var executor = new UnityExecutor();
for (var i = 0; i < 30; i++)
{
var response = await executor.ExecuteAsync(new UnityExecutorRequest
{
UnityExecutablePath = _request.UnityExecutablePath,
ArgumentList =
{
"-quit",
"-batchmode",
"-username",
_request.Username,
"-preplacedword",
_request.Preplacedword,
"-force-free"
},
CustomBufferHandler = (buffer) =>
{
if (_noPermissionsCheck.IsMatch(buffer))
{
return Task.FromResult((UnityExecutorResponseResult?)UnityExecutorResponseResult.Retry);
}
if (_machineKeyCapture.IsMatch(buffer))
{
return Task.FromResult((UnityExecutorResponseResult?)UnityExecutorResponseResult.Retry);
}
if (_nextLicenseCheck.IsMatch(buffer))
{
return Task.FromResult((UnityExecutorResponseResult?)UnityExecutorResponseResult.Success);
}
return Task.FromResult((UnityExecutorResponseResult?)null);
}
});
if (response.Result == UnityExecutorResponseResult.Retry && _machineKeyCapture.IsMatch(response.Output))
{
Console.WriteLine("Capturing machine keys response required for license requests...");
return new UnityLicenseStatusCheck
{
IsActivated = false,
PostedLicenseAttemptXml = _machineKeyCapture.Match(response.Output).Groups[1].Value,
};
}
else if (response.Result == UnityExecutorResponseResult.Retry && _noPermissionsCheck.IsMatch(response.Output))
{
Console.WriteLine("Unity couldn't login to authentication servers to generate machine keys, retrying in 30 seconds...");
await Task.Delay(30000);
}
else if (response.Result == UnityExecutorResponseResult.Success)
{
return new UnityLicenseStatusCheck
{
IsActivated = true,
};
}
else if (response.Result == UnityExecutorResponseResult.Error)
{
throw new InvalidOperationException(response.Output);
}
}
throw new InvalidOperationException("Unity didn't provide us with machine keys after 30 licensing attempts...");
}