public MethodAndUriTemplateOperationSelector(ServiceEndpoint endpoint) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } this.delegates = new Dictionary<string, UriTemplateOperationSelector>(); var operations = endpoint.Contract.Operations.Select(od => new HttpOperationDescription(od)); foreach (var methodGroup in operations.GroupBy(od => od.GetWebMethod())) { UriTemplateTable table = new UriTemplateTable(endpoint.ListenUri); foreach (var operation in methodGroup) { UriTemplate template = new UriTemplate(operation.GetUriTemplateString()); table.KeyValuePairs.Add( new KeyValuePair<UriTemplate, object>(template, operation.Name)); } table.MakeReadOnly(false); UriTemplateOperationSelector templateSelector = new UriTemplateOperationSelector(table); this.delegates.Add(methodGroup.Key, templateSelector); } }
public MethodAndUriTemplateOperationSelector(ServiceEndpoint endpoint) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } this.delegates = new Dictionary <string, UriTemplateOperationSelector>(); var operations = endpoint.Contract.Operations.Select(od => new HttpOperationDescription(od)); foreach (var methodGroup in operations.GroupBy(od => od.GetWebMethod())) { UriTemplateTable table = new UriTemplateTable(endpoint.ListenUri); foreach (var operation in methodGroup) { UriTemplate template = new UriTemplate(operation.GetUriTemplateString()); table.KeyValuePairs.Add( new KeyValuePair <UriTemplate, object>(template, operation.Name)); } table.MakeReadOnly(false); UriTemplateOperationSelector templateSelector = new UriTemplateOperationSelector(table); this.delegates.Add(methodGroup.Key, templateSelector); } }
public override HttpOperationSelector SelectDelegateOperationSelector( HttpRequestMessage message) { if (message == null) { throw new ArgumentNullException("message"); } string method = message.Method.Method; UriTemplateOperationSelector selector = null; if (method != null) { this.delegates.TryGetValue(method, out selector); } return(selector); }