[MonoTODO] // FIXME: Check how expanded entity is handled here. public override int ReadContentAsBinHex(byte [] buffer, int index, int count) { if (entity != null) { return(entity.ReadContentAsBinHex(buffer, index, count)); } else { return(source.ReadContentAsBinHex(buffer, index, count)); } }
[MonoTODO] // FIXME: Check how expanded entity is handled here. public override int ReadContentAsBinHex(byte [] buffer, int offset, int length) { if (entity != null) { return(entity.ReadContentAsBinHex(buffer, offset, length)); } else { return(source.ReadContentAsBinHex(buffer, offset, length)); } }
/// <summary> /// Parse binary chunk data according to encoding type from the xml doc indicated by reader. /// </summary> /// <param name="reader">Xml text reader.</param> /// <param name="chunkEncoding">Encoding of the chunk.</param> /// <param name="chunkData">Chunk data.</param> private static void ParseBinaryData(XmlTextReader reader, ScriptAcousticChunkEncoding chunkEncoding, Collection<float> chunkData) { Debug.Assert(reader != null); Debug.Assert(chunkEncoding == ScriptAcousticChunkEncoding.Base64Binary || chunkEncoding == ScriptAcousticChunkEncoding.HexBinary); Debug.Assert(reader.NodeType == XmlNodeType.Text); const int FloatCount = 200; int bufSize = sizeof(float) * FloatCount; byte[] bytes = new byte[bufSize]; while (reader.NodeType == XmlNodeType.Text) { int len = 0; switch (chunkEncoding) { case ScriptAcousticChunkEncoding.Base64Binary: len = reader.ReadContentAsBase64(bytes, 0, bufSize); break; case ScriptAcousticChunkEncoding.HexBinary: len = reader.ReadContentAsBinHex(bytes, 0, bufSize); break; } if ((len % sizeof(float)) != 0) { string message = string.Format(CultureInfo.InvariantCulture, "Size of binary chunk data isn't multiple of sizeof(float)."); throw new InvalidDataException(message); } for (int i = 0; i < len; i += sizeof(float)) { chunkData.Add(BitConverter.ToSingle(bytes, i)); } } Debug.Assert(reader.NodeType == XmlNodeType.EndElement); }