-
Notifications
You must be signed in to change notification settings - Fork 3
/
Int32Extensions.cs
71 lines (65 loc) · 3.44 KB
/
Int32Extensions.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using Cuemon.AspNetCore.Http;
namespace Cuemon.Extensions.AspNetCore.Http
{
/// <summary>
/// Extension methods for the <see cref="Int32"/> struct.
/// </summary>
public static class Int32Extensions
{
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> is within the informational range.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> was in the <b>Information</b> range (100-199); otherwise, <c>false</c>.</returns>
public static bool IsInformationStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsInformationStatusCode();
}
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> is within the successful range.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> was in the <b>Successful</b> range (200-299); otherwise, <c>false</c>.</returns>
public static bool IsSuccessStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsSuccessStatusCode();
}
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> is within the redirecting range.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> was in the <b>Redirection</b> range (300-399); otherwise, <c>false</c>.</returns>
public static bool IsRedirectionStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsRedirectionStatusCode();
}
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> equals a 304 Not Modified.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> is <b>NotModified</b> (304); otherwise, <c>false</c>.</returns>
public static bool IsNotModifiedStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsNotModifiedStatusCode();
}
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> is within the client error related range.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> was in the <b>Client Error</b> range (400-499); otherwise, <c>false</c>.</returns>
public static bool IsClientErrorStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsClientErrorStatusCode();
}
/// <summary>
/// Determines whether the specified <paramref name="statusCode"/> is within the server error related range.
/// </summary>
/// <param name="statusCode">The <see cref="int"/> to extend.</param>
/// <returns><c>true</c> if <paramref name="statusCode"/> was in the <b>Server Error</b> range (500-599); otherwise, <c>false</c>.</returns>
public static bool IsServerErrorStatusCode(this int statusCode)
{
return Decorator.Enclose(statusCode).IsServerErrorStatusCode();
}
}
}