private async Task <XmlRpcResponse> ReadResponseAsync(HttpResponseMessage httpResponse) { var responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); var responseModelReader = new ResponseModelReader(new ValueReaders(XmlEncoding)); return(await responseModelReader.ReadAsync(new MemoryStream(XmlEncoding.GetBytes(responseContent)), false).ConfigureAwait(false)); }
private void ReadPositionalValue(FlatFileSchemaElement element, Stream stream, BinaryWriter outputWriter) { var readBytes = new byte[element.PosLength]; var readBytesCount = stream.Read(readBytes, 0, element.PosLength); if (readBytesCount != element.PosLength) { throw new Exception($"Unexpected end-of-file detected. Expected value for '{element.Name}'."); } var valueString = Encoding.GetString(readBytes); // If the value is justified, remove the padding characters: if (element.Justification == FlatFileElementJustification.Left) { valueString = valueString.TrimEnd(DefaultPadChar); } else if (element.Justification == FlatFileElementJustification.Right) { valueString = valueString.TrimStart(DefaultPadChar); } // Construct the attribute or element: outputWriter.Write(element.StartElement); if (element.ElementType == SchemaElementType.Attribute) { // Write the value: // Escape the XML characters: var escapedValue = SecurityElement.Escape(valueString); if (escapedValue != null) { outputWriter.Write(XmlEncoding.GetBytes(escapedValue)); } // Close the attribute (write '"'): outputWriter.Write(element.ElementCloser); } else { // Close the start element (write '>'): outputWriter.Write(element.ElementCloser); // Write the value: // Escape the XML characters: var escapedValue = SecurityElement.Escape(valueString); if (escapedValue != null) { outputWriter.Write(XmlEncoding.GetBytes(escapedValue)); } // Write the closing xml element to the output stream: outputWriter.Write(element.EndElement); } }