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)); } } }
internal static void ValidateEndpointReference(string endpoint, string endpointConfiguration, ContextInformation evaluationContext, ConfigurationElement configurationElement) { // ValidateEndpointReference built on assumption that evaluationContext is valid. // This should be protected at the callers site. If assumption is invalid, then // configuration system is in an indeterminate state. Need to stop in a manner that // user code can not capture. if (null == evaluationContext) { Fx.Assert("ValidateEndpointReference() should only called with valid ContextInformation"); DiagnosticUtility.FailFast("ValidateEndpointReference() should only called with valid ContextInformation"); } if (!String.IsNullOrEmpty(endpoint)) { EndpointCollectionElement endpointCollectionElement = null; if (null != evaluationContext) { endpointCollectionElement = ConfigurationHelpers.UnsafeGetAssociatedEndpointCollectionElement(evaluationContext, endpoint); } else { endpointCollectionElement = ConfigurationHelpers.UnsafeGetEndpointCollectionElement(endpoint); } if (endpointCollectionElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidSection, ConfigurationHelpers.GetEndpointsSectionPath(endpoint)), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber)); } if (!String.IsNullOrEmpty(endpointConfiguration)) { if (!endpointCollectionElement.ContainsKey(endpointConfiguration)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidEndpointName, endpointConfiguration, ConfigurationHelpers.GetEndpointsSectionPath(endpoint), ConfigurationStrings.EndpointConfiguration), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber)); } } } }