Xamarin Public Jenkins (auto-signing) e79aa3c0ed Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
2016-08-03 10:59:49 +00:00

48 lines
1.4 KiB
C#

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