示例#1
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 /// <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;
 }
示例#6
0
 /// <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);
 }
示例#7
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json)
 {
     SerializationMethod = serializationMethod;
 }
示例#8
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Default)
 {
     SerializationMethod = serializationMethod;
 }
示例#9
0
 public BodyAttribute(BodySerializationMethod serializationMethod, bool buffered)
 {
     SerializationMethod = serializationMethod;
     Buffered            = buffered;
 }
示例#10
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json,
                      bool buffered = false)
 {
     SerializationMethod = serializationMethod;
     Buffered            = buffered;
 }
示例#11
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json)
 {
     SerializationMethod = serializationMethod;
 }
示例#12
0
 /// <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;
 }
示例#13
0
 /// <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;
 }
示例#14
0
 public void EmitSetBodyParameter(ParameterModel parameter, BodySerializationMethod serializationMethod)
 {
     this.writer.WriteLine(this.requestInfoLocalName + ".SetBodyParameterInfo(" + EnumValue(serializationMethod) + ", " +
                           ReferenceTo(parameter) + ");");
 }