//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
internal static class EndpointSettings
{
internal const string ValidateOptionalClientCertificates = "wcf:HttpTransport:ValidateOptionalClientCertificates";
internal static T GetValue(BindingContext context, string name, T defaultValue)
{
if (context == null ||
context.BindingParameters == null ||
context.BindingParameters.Count == 0)
{
return defaultValue;
}
return GetValue(context.BindingParameters, name, defaultValue);
}
internal static T GetValue(BindingParameterCollection bindingParameters, string name, T defaultValue)
{
if (bindingParameters == null ||
bindingParameters.Count == 0)
{
return defaultValue;
}
IDictionary endpointSettings = bindingParameters.Find>();
object setting;
if (endpointSettings == null ||
!endpointSettings.TryGetValue(name, out setting) ||
!(setting is T))
{
return defaultValue;
}
return (T)setting;
}
}
}