internal static void ReturnContentObject(BodyAttribute bodyAttr, Type returnType, bool isAsyncCall, StringBuilder classBuilder) { if (bodyAttr == null || returnType == null) { return; } var format = bodyAttr.Format; if (format == Format.Auto) { format = typeof(Stream).IsAssignableFrom(returnType) ? Format.Raw : Format.Json; } // The Format.Auto is handled above, since it will always be Raw or Json at this point // ReSharper disable once SwitchStatementMissingSomeCases switch (format) { case Format.Json: classBuilder.AppendLine(isAsyncCall ? $" return await ConvertToObjectAsync<{WebServiceClassGenerator.ToCompilableName(returnType)}>(response);" : $" return ConvertToObject<{WebServiceClassGenerator.ToCompilableName(returnType)}>(response);"); break; case Format.Raw: classBuilder.AppendLine(isAsyncCall ? " return await response.Content.ReadAsStreamAsync();" : " return response.Content.ReadAsStreamAsync().Result;"); break; default: return; } }
internal static void ReturnResponseHeader(ResponseHeaderAttribute responseHeaderAttribute, Type returnType, StringBuilder classBuilder) { classBuilder.AppendLine($" return GetHeaderValue<{WebServiceClassGenerator.ToCompilableName(returnType)}>(response, \"{responseHeaderAttribute.Header}\");"); }