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; } }
public string RegisterInterface(TypeInfo type) { logger.LogDebug($"Registering the interface: {type.FullName}"); UpdateReferences(type.Assembly); var sourceCode = WebServiceClassGenerator.GenerateSource(type, out var fullyQualifiedClassName); syntaxTrees.Add(SyntaxFactory.ParseSyntaxTree(sourceCode)); logger.LogDebug($"Finished compiling the syntax tree for {fullyQualifiedClassName} generated from {type.FullName}"); return(fullyQualifiedClassName); }
internal static void ReturnResponseHeader(ResponseHeaderAttribute responseHeaderAttribute, Type returnType, StringBuilder classBuilder) { classBuilder.AppendLine($" return GetHeaderValue<{WebServiceClassGenerator.ToCompilableName(returnType)}>(仮response, \"{responseHeaderAttribute.Header}\");"); }