Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json)
 {
     SerializationMethod = serializationMethod;
 }
Ejemplo n.º 8
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Default)
 {
     SerializationMethod = serializationMethod;
 }
Ejemplo n.º 9
0
 public BodyAttribute(BodySerializationMethod serializationMethod, bool buffered)
 {
     SerializationMethod = serializationMethod;
     Buffered            = buffered;
 }
Ejemplo n.º 10
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json,
                      bool buffered = false)
 {
     SerializationMethod = serializationMethod;
     Buffered            = buffered;
 }
Ejemplo n.º 11
0
 public BodyAttribute(BodySerializationMethod serializationMethod = BodySerializationMethod.Json)
 {
     SerializationMethod = serializationMethod;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 14
0
 public void EmitSetBodyParameter(ParameterModel parameter, BodySerializationMethod serializationMethod)
 {
     this.writer.WriteLine(this.requestInfoLocalName + ".SetBodyParameterInfo(" + EnumValue(serializationMethod) + ", " +
                           ReferenceTo(parameter) + ");");
 }