// 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
{
///
/// Internal helper class to validate enum values.
///
internal static class HttpBindingSecurityModeHelper
{
///
/// Determines whether the specified is defined by the
/// enumeration.
///
/// The value to test.
/// true if is a valid value; otherwise false.
public static bool IsDefined(HttpBindingSecurityMode value)
{
return value == HttpBindingSecurityMode.None ||
value == HttpBindingSecurityMode.Transport ||
value == HttpBindingSecurityMode.TransportCredentialOnly;
}
///
/// Validates the specified and throws an
/// exception if not valid.
///
/// The value to validate.
/// Name of the parameter to use if throwing exception.
public static void Validate(HttpBindingSecurityMode value, string parameterName)
{
if (!IsDefined(value))
{
throw Error.InvalidEnumArgument(parameterName, (int)value, typeof(HttpBindingSecurityMode));
}
}
}
}