public virtual object OnResponseApplyConverters(object value, HttpOperation operation, FieldInfo fi) { if (Converters != null) { Type[] converters = Converters; foreach (Type type in converters) { IValueConverter valueConverter = Activator.CreateInstance(type) as IValueConverter; if (valueConverter == null) { operation.Log("(HttpMappedValueAttribute)(OnResponseApplyConverters) Converter '" + type.FullName + "' must implement IValueConverter!", LogSeverity.ERROR); continue; } bool successful = false; value = valueConverter.Convert(value, fi, out successful, null); if (successful) { operation.Log("(HttpMappedValueAttribute)(OnResponseApplyConverters) Converter '" + type.FullName + "' applied. Output type is " + ((value != null) ? ("'" + value.GetType().FullName + "'") : "(unknown) because @value is null") + ".", LogSeverity.VERBOSE); } else { operation.Log("(HttpMappedValueAttribute)(OnResponseApplyConverters) Converter '" + type.FullName + "' failed!", LogSeverity.WARNING); } } } return(value); }
private void resolveArray(string name, object value, ref HttpRequestModel model, HttpOperation operation, FieldInfo fi) { if (!string.IsNullOrEmpty(name)) { IEnumerator enumerator = ((Array)value).GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; if (!string.IsNullOrEmpty(current.ToString()) || (string.IsNullOrEmpty(current.ToString()) && !IgnoreWhenValueIsEmpty)) { model.AddQueryString(name + "[]", (current != null) ? current.ToString() : ""); } else { operation.Log("(HttpQueryStringAttribute)(OnRequestResolveModel) Query string part failed to add because the value is empty!", LogSeverity.WARNING); } } } finally { IDisposable disposable; if ((disposable = enumerator as IDisposable) != null) { disposable.Dispose(); } } } else { operation.Log("(HttpQueryStringAttribute)(OnRequestResolveModel) Query string part failed to add because the name is empty!", LogSeverity.WARNING); } }
public override object OnResponseResolveValue(string name, HttpOperation operation, FieldInfo fi, HttpResponse response) { if (!string.IsNullOrEmpty(name)) { if (response.Headers.ContainsKey(name)) { return(response.Headers[name]); } operation.Log("(HttpHeaderAttribute)(OnResponseResolveValue) Key '" + name + "' is not found in response headers for '" + fi.Name + "'.", LogSeverity.WARNING); return(null); } operation.Log("(HttpHeaderAttribute)(OnResponseResolveValue) Header failed to fetch because the name is empty!", LogSeverity.WARNING); return(null); }
public override object OnResponseApplyConverters(object value, HttpOperation operation, FieldInfo fi) { if (operation.IsFaulted) { operation.Log("(HttpResponseBinaryValueAttribute)(OnResponseApplyConverters) Operation has faulted and converters will not be applied! Nullifying value to prevent further exceptions.", LogSeverity.WARNING); return(null); } return(base.OnResponseApplyConverters(value, operation, fi)); }
public override void OnRequestResolveModel(string name, object value, ref HttpRequestModel model, HttpOperation operation, FieldInfo fi) { if (!string.IsNullOrEmpty(name)) { model.AddBinaryFormField(name, FileName, MimeType, (value != null) ? ((byte[])value) : null); } else { operation.Log("(HttpBinaryFormFieldAttribute)(OnRequestResolveModel) Form binary field failed to add because the name is empty!", LogSeverity.WARNING); } }
public override void OnRequestResolveModel(string name, object value, ref HttpRequestModel model, HttpOperation operation, FieldInfo fi) { if (!string.IsNullOrEmpty(name)) { model.AddFormField(name, (value != null) ? value.ToString() : ""); } else { operation.Log("(HttpFormFieldAttribute)(OnRequestResolveModel) Form field failed to add because the name is empty!", LogSeverity.WARNING); } }
public override void OnRequestResolveModel(string name, object value, ref HttpRequestModel model, HttpOperation operation, FieldInfo fi) { if (!string.IsNullOrEmpty(name)) { model.AddUriTemplate("{" + ((!name.StartsWith("$")) ? ("$" + name) : name) + "}", (value != null) ? Uri.EscapeUriString(value.ToString()) : ""); } else { operation.Log("(HttpUriSegmentAttribute)(OnRequestResolveModel) URI template expression failed to add because the name is empty!", LogSeverity.WARNING); } }
private void resolve(string name, object value, ref HttpRequestModel model, HttpOperation operation, FieldInfo fi) { value = Convert.ChangeType(value, typeof(string)); if (!string.IsNullOrEmpty(name) && (!string.IsNullOrEmpty((string)value) || (string.IsNullOrEmpty((string)value) && !IgnoreWhenValueIsEmpty))) { model.AddQueryString(name, (value != null) ? value.ToString() : ""); } else { operation.Log("(HttpQueryStringAttribute)(OnRequestResolveModel) Query string part failed to add because the name is empty!", LogSeverity.WARNING); } }