forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpBindingSecurityModeHelper.cs
More file actions
40 lines (37 loc) · 1.75 KB
/
HttpBindingSecurityModeHelper.cs
File metadata and controls
40 lines (37 loc) · 1.75 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
37
38
39
40
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel;
namespace System.Web.Http.SelfHost.Channels
{
/// <summary>
/// Internal helper class to validate <see cref="HttpBindingSecurityMode"/> enum values.
/// </summary>
internal static class HttpBindingSecurityModeHelper
{
/// <summary>
/// Determines whether the specified <paramref name="value"/> is defined by the <see cref="HttpBindingSecurityMode"/>
/// enumeration.
/// </summary>
/// <param name="value">The value to test.</param>
/// <returns><c>true</c> if <paramref name="value"/> is a valid <see cref="HttpBindingSecurityMode"/> value; otherwise<c> false</c>.</returns>
public static bool IsDefined(HttpBindingSecurityMode value)
{
return value == HttpBindingSecurityMode.None ||
value == HttpBindingSecurityMode.Transport ||
value == HttpBindingSecurityMode.TransportCredentialOnly;
}
/// <summary>
/// Validates the specified <paramref name="value"/> and throws an <see cref="InvalidEnumArgumentException"/>
/// exception if not valid.
/// </summary>
/// <param name="value">The value to validate.</param>
/// <param name="parameterName">Name of the parameter to use if throwing exception.</param>
public static void Validate(HttpBindingSecurityMode value, string parameterName)
{
if (!IsDefined(value))
{
throw Error.InvalidEnumArgument(parameterName, (int)value, typeof(HttpBindingSecurityMode));
}
}
}
}