public CORSWebHttpDispatchOperationSelector(ServiceEndpoint endpoint, WebHttpDispatchOperationSelector target) { this.target = target; this.endpoint = endpoint; foreach (var item in this.endpoint.Contract.Operations) { var webInvoke = item.Behaviors.OfType <WebInvokeAttribute>().FirstOrDefault(); if (webInvoke != null && webInvoke.Method.Equals("options", StringComparison.OrdinalIgnoreCase) && webInvoke.UriTemplate == "*") { optionOperationName = item.Name; break; } } }
public UriTemplate GetUriTemplate(string operationName) { if (String.IsNullOrEmpty(operationName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationName"); } WebHttpDispatchOperationSelector selector = OperationContext.Current.EndpointDispatcher.DispatchRuntime.OperationSelector as WebHttpDispatchOperationSelector; if (selector == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new InvalidOperationException(SR2.GetString(SR2.OperationSelectorNotWebSelector, typeof(WebHttpDispatchOperationSelector)))); } return(selector.GetUriTemplate(operationName)); }