public static void Set(HttpRequestMessage request, string operationName) { if (request == null) { throw new ArgumentNullException("request"); } request.GetProperties().Add(new SelectedOperation() { Name = operationName }); }
public static string Get(HttpRequestMessage request) { if (request == null) { throw new ArgumentNullException("request"); } object property = request.GetProperties().FirstOrDefault(o => o is SelectedOperation); if (property != null) { SelectedOperation selectedOperation = property as SelectedOperation; return selectedOperation.Name; } return null; }
protected virtual string OnMatchFound(UriTemplateMatch match, HttpRequestMessage message) { if (match == null) { throw new ArgumentNullException("match"); } if (message == null) { throw new ArgumentNullException("message"); } if (match.Data == null) { return string.Empty; } string operationName = match.Data as string; if (operationName == null) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, "The UriTemplateMatch data is expected to be of type '{0}' but is of type '{1}'.", match.Data.GetType().FullName, stringTypeFullName)); } message.GetProperties().Add(match); return operationName; }