예제 #1
0
 public override void Apply(Parameter parameter)
 {
     if (CanResolve(parameter))
     {
         parameter.Value = (((int)parameter.ParameterValue) * 10).ToString();
     }
 }
예제 #2
0
 public override void Apply(Parameter parameter)
 {
     if (CanResolve(parameter))
     {
         parameter.Value = parameter.Value.ToString().Reverse().Aggregate(string.Empty, (x, y) => x + y);
     }
 }
예제 #3
0
 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");
     }
 }
예제 #5
0
        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");
            }
        }
예제 #6
0
 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());
 }
예제 #8
0
 public bool CanResolve(Parameter parameter)
 {
     return parameter.ParameterValue is string;
 }
예제 #9
0
 public Parameters(IEnumerable<Parameter> routeParameters, IEnumerable<Parameter> queryParameters, Parameter content)
 {
     QueryParameters = queryParameters;
     Content = content;
     RouteParameters = routeParameters;
 }
예제 #10
0
 protected virtual string CreateRouteSegmentValue(Parameter parameter)
 {
     var value = parameter.Value != null
                    ? parameter.Value.ToString()
                    : parameter.ParameterValue.ToString();
     return WebUtility.UrlEncode(value);
 }
예제 #11
0
 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));
 }
예제 #12
0
 public override void Apply(Parameter parameter)
 {
     parameter.Name = _prefix + parameter.ParameterInfo.Name;
 }