public void EmitSetBodyParameter(ParameterModel parameter, BodySerializationMethod serializationMethod) { var typedMethod = MethodInfos.RequestInfo_SetBodyParameterInfo.MakeGenericMethod(parameter.ParameterInfo.ParameterType); this.ilGenerator.Emit(OpCodes.Ldloc, this.requestInfoLocal); this.ilGenerator.Emit(OpCodes.Ldc_I4, (int)serializationMethod); this.ilGenerator.Emit(OpCodes.Ldarg, (short)parameter.ParameterInfo.Position + 1); this.ilGenerator.Emit(OpCodes.Callvirt, typedMethod); }
public BodySerializationMethod ResolveBody(BodySerializationMethod parameterMethod) { if (parameterMethod != BodySerializationMethod.Default) return parameterMethod; if (this.MethodAttribute != null && this.MethodAttribute.Body != BodySerializationMethod.Default) return this.MethodAttribute.Body; if (this.ClassAttribute != null && this.ClassAttribute.Body != BodySerializationMethod.Default) return this.ClassAttribute.Body; return DefaultBodySerializationMethod; }
private void AddBody(ILGenerator methodIlGenerator, BodySerializationMethod serializationMethod, Type parameterType, short parameterIndex) { // Equivalent C#: // requestInfo.SetBodyParameterInfo(serializationMethod, value) var typedMethod = setBodyParameterInfoMethod.MakeGenericMethod(parameterType); // Stack: [..., requestInfo, requestInfo] methodIlGenerator.Emit(OpCodes.Dup); // Stack: [..., requestInfo, requestInfo, serializationMethod] methodIlGenerator.Emit(OpCodes.Ldc_I4, (int)serializationMethod); // Stack: [..., requestInfo, requestInfo, serializationMethod, parameter] methodIlGenerator.Emit(OpCodes.Ldarg, parameterIndex); // Stack: [..., requestInfo] methodIlGenerator.Emit(OpCodes.Callvirt, typedMethod); }
public BodySerializationMethod ResolveBody(BodySerializationMethod parameterMethod) { if (parameterMethod != BodySerializationMethod.Default) { return(parameterMethod); } if (this.MethodAttribute != null && this.MethodAttribute.Body != BodySerializationMethod.Default) { return(this.MethodAttribute.Body); } if (this.ClassAttribute != null && this.ClassAttribute.Body != BodySerializationMethod.Default) { return(this.ClassAttribute.Body); } return(DefaultBodySerializationMethod); }
/// <summary> /// Initialises a new instance of the <see cref="BodyParameterInfo{T}"/> class /// </summary> /// <param name="serializationMethod">Method to use the serialize the body</param> /// <param name="objectValue">Body to serialize, as an object</param> protected BodyParameterInfo(BodySerializationMethod serializationMethod, object?objectValue) { this.SerializationMethod = serializationMethod; this.ObjectValue = objectValue; }
/// <summary> /// Set the body specified by the optional [Body] method parameter /// </summary> /// <param name="serializationMethod">Method to use to serialize the body</param> /// <param name="value">Body to serialize</param> /// <typeparam name="T">Type of the body's value</typeparam> public void SetBodyParameterInfo <T>(BodySerializationMethod serializationMethod, T value) { this.BodyParameterInfo = new BodyParameterInfo <T>(serializationMethod, value); }
public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json) { SerializationMethod = serializationMethod; }
public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Default) { SerializationMethod = serializationMethod; }
public BodyAttribute(BodySerializationMethod serializationMethod, bool buffered) { SerializationMethod = serializationMethod; Buffered = buffered; }
public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json, bool buffered = false) { SerializationMethod = serializationMethod; Buffered = buffered; }
/// <summary> /// Initialises a new instance of the <see cref="BodyAttribute"/> class, using the given body serialization method /// </summary> /// <param name="serializationMethod">Serialization method to use when serializing the body object</param> public BodyAttribute(BodySerializationMethod serializationMethod) { this.SerializationMethod = serializationMethod; }
public void EmitSetBodyParameter(ParameterModel parameter, BodySerializationMethod serializationMethod) { this.writer.WriteLine(this.requestInfoLocalName + ".SetBodyParameterInfo(" + EnumValue(serializationMethod) + ", " + ReferenceTo(parameter) + ");"); }