internal static void ValidateEndpointReference(string endpoint, string endpointConfiguration, ContextInformation evaluationContext, ConfigurationElement configurationElement)
{
if (evaluationContext == null)
{
DiagnosticUtility.FailFast("ValidateEndpointReference() should only called with valid ContextInformation");
}
if (!string.IsNullOrEmpty(endpoint))
{
EndpointCollectionElement element = null;
if (evaluationContext != null)
{
element = ConfigurationHelpers.UnsafeGetAssociatedEndpointCollectionElement(evaluationContext, endpoint);
}
else
{
element = ConfigurationHelpers.UnsafeGetEndpointCollectionElement(endpoint);
}
if (element == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidSection", new object[] { ConfigurationHelpers.GetEndpointsSectionPath(endpoint) }), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber));
}
if (!string.IsNullOrEmpty(endpointConfiguration) && !element.ContainsKey(endpointConfiguration))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidEndpointName", new object[] { endpointConfiguration, ConfigurationHelpers.GetEndpointsSectionPath(endpoint), "endpointConfiguration" }), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber));
}
}
}