1
0

BasicAuthentication attribute and TimeSpan.ToShortString()

- BasicAuthenticationAttribute sets the HttpContext.User property when successfully validated.
- Moved BasicAuthenticationAttribute from ActionFilter to IAsyncAuthorizationFilter.
- TimeSpan.ToShortString() is now capable of negative values.
This commit is contained in:
2022-06-23 22:51:16 +02:00
parent 97c3c303ce
commit bfe500dfa1
4 changed files with 80 additions and 39 deletions

View File

@@ -91,19 +91,22 @@ namespace System
{
var sb = new StringBuilder();
if (timeSpan.TotalDays >= 1)
sb.Append(timeSpan.Days).Append("d ");
if (timeSpan < TimeSpan.Zero)
sb.Append("-");
if (timeSpan.TotalHours >= 1)
sb.Append(timeSpan.Hours).Append("h ");
if (timeSpan.TotalDays != 0)
sb.Append(Math.Abs(timeSpan.Days)).Append("d ");
if (timeSpan.TotalMinutes >= 1)
sb.Append(timeSpan.Minutes).Append("m ");
if (timeSpan.TotalHours != 0)
sb.Append(Math.Abs(timeSpan.Hours)).Append("h ");
sb.Append(timeSpan.Seconds).Append("s ");
if (timeSpan.TotalMinutes != 0)
sb.Append(Math.Abs(timeSpan.Minutes)).Append("m ");
sb.Append(Math.Abs(timeSpan.Seconds)).Append("s ");
if (withMilliseconds)
sb.Append(timeSpan.Milliseconds).Append("ms");
sb.Append(Math.Abs(timeSpan.Milliseconds)).Append("ms");
return sb.ToString().Trim();
}