public ResolvedService( string name, Method method, IEnumerable<FilterAction> afterActions, IEnumerable<FilterAction> beforeActions, IEnumerable<IEncoding> encodings, IEnumerable<FilterAction> errorActions, IEnumerable<IFormat> formats, Type requestType) { if (method == null) { throw new ArgumentNullException("method", "method cannot be null."); } if (afterActions == null) { throw new ArgumentNullException("afterActions", "afterActions cannot be null."); } if (beforeActions == null) { throw new ArgumentNullException("beforeActions", "beforeActions cannot be null."); } if (encodings == null) { throw new ArgumentNullException("encodings", "encodings cannot be null."); } if (errorActions == null) { throw new ArgumentNullException("errorActions", "errorActions cannot be null."); } if (formats == null) { throw new ArgumentNullException("formats", "formats cannot be null."); } this.Name = name ?? string.Empty; this.Method = method; this.AfterActions = afterActions; this.BeforeActions = beforeActions; this.Encodings = encodings; this.ErrorActions = errorActions; this.Formats = formats; this.RequestType = requestType; this.RouteValues = new Dictionary<string, object>(); }
private static Type ResolveRequestType(Method method, IEnumerable<FilterAction> beforeActions, IEnumerable<FilterAction> afterActions, IEnumerable<FilterAction> errorActions) { Type type = method.TypeArguments.FirstOrDefault(); if (type == null) { foreach (FilterAction filter in beforeActions) { type = filter.TypeArguments.FirstOrDefault(); if (type != null) { break; } } if (type == null) { foreach (FilterAction filter in afterActions) { type = filter.TypeArguments.FirstOrDefault(); if (type != null) { break; } } if (type == null) { foreach (FilterAction filter in errorActions) { type = filter.TypeArguments.FirstOrDefault(); if (type != null) { break; } } } } } return type; }