public override void Apply(Parameter parameter) { if (CanResolve(parameter)) { parameter.Value = (((int)parameter.ParameterValue) * 10).ToString(); } }
public override void Apply(Parameter parameter) { if (CanResolve(parameter)) { parameter.Value = parameter.Value.ToString().Reverse().Aggregate(string.Empty, (x, y) => x + y); } }
public Parameter(Parameter parentParameter, object value) { ParentParameter = parentParameter; ParameterInfo = parentParameter.ParameterInfo; ParameterValue = value; Type = value.GetType(); ParameterType = parentParameter.ParameterType; }
public void Resolve(Parameter parameter) { if (parameter.ParameterType == ParameterType.Content) { ((IDictionary<string, object>)parameter.Value).Add("api_key", _apiKey); ((IDictionary<string, object>)parameter.Value).Remove("WidgetKey"); } }
public HttpContent Serialize(Parameter content) { if (content == null) { return null; } var value = content.Value; if (content.ParameterInfo.GetAttribute<ContentAttribute>().Type == ContentType.FormUrlEncoded) { var pairs = value as IEnumerable<KeyValuePair<string, string>> ?? value.GetType().GetProperties().ToDictionary(x => x.Name, x => (x.GetGetMethod().Invoke(value, null) == null ? string.Empty : x.GetGetMethod().Invoke(value, null).ToString())); return new FormUrlEncodedContent(pairs); } else { var json = new StringBuilder(); _jsonSerializer.Serialize(new JsonTextWriter(new StringWriter(json)), content.Value); return new StringContent(json.ToString(), Encoding.UTF8, "application/json"); } }
public bool CanResolve(Parameter parameter) { int dummy; return parameter.ParameterValue != null && int.TryParse(parameter.ParameterValue.ToString(), out dummy); }
public HttpContent Serialize(Parameter content) { return new StringContent(content.Value.ToString()); }
public bool CanResolve(Parameter parameter) { return parameter.ParameterValue is string; }
public Parameters(IEnumerable<Parameter> routeParameters, IEnumerable<Parameter> queryParameters, Parameter content) { QueryParameters = queryParameters; Content = content; RouteParameters = routeParameters; }
protected virtual string CreateRouteSegmentValue(Parameter parameter) { var value = parameter.Value != null ? parameter.Value.ToString() : parameter.ParameterValue.ToString(); return WebUtility.UrlEncode(value); }
protected virtual string CreateUrlParameter(Parameter parameter) { var value = parameter.Value != null ? parameter.Value.ToString() : parameter.ParameterValue.ToString(); return string.Format("{0}={1}", parameter.Name, WebUtility.UrlEncode(value)); }
public override void Apply(Parameter parameter) { parameter.Name = _prefix + parameter.ParameterInfo.Name; }