-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpClientHintsInterpreter.cs
More file actions
36 lines (32 loc) · 1.18 KB
/
HttpClientHintsInterpreter.cs
File metadata and controls
36 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright © myCSharp.de - all rights reserved
namespace MyCSharp.HttpClientHints;
/// <summary>
/// Provides methods to interpret HTTP client hints.
/// </summary>
public static class HttpClientHintsInterpreter
{
/// <summary>
/// Determines if the provided hint indicates a mobile device.
/// </summary>
/// <param name="mobileHeaderValue">The client hint for mobile status, expected to be "?1" for mobile, "?0" for non-mobile, or null if unknown.</param>
/// <returns>
/// A nullable boolean value indicating the mobile status:
/// <list type="bullet">
/// <item><c>true</c> if the hint indicates a mobile device ("?1").</item>
/// <item><c>false</c> if the hint indicates a non-mobile device ("?0").</item>
/// <item><c>null</c> if the hint does not indicate a specific status.</item>
/// </list>
/// </returns>
public static bool? IsMobile(string? mobileHeaderValue)
{
if (string.Equals(mobileHeaderValue, "?1", StringComparison.Ordinal))
{
return true;
}
if (string.Equals(mobileHeaderValue, "?0", StringComparison.Ordinal))
{
return false;
}
return null;
}
}