ReadContentAsBase64() public method

public ReadContentAsBase64 ( byte buffer, int index, int count ) : int
buffer byte
index int
count int
return int
Example #1
0
 [MonoTODO]         // FIXME: Check how expanded entity is handled here.
 public override int ReadContentAsBase64(byte [] buffer, int index, int count)
 {
     if (entity != null)
     {
         return(entity.ReadContentAsBase64(buffer, index, count));
     }
     else
     {
         return(source.ReadContentAsBase64(buffer, index, count));
     }
 }
 [MonoTODO] // FIXME: Check how expanded entity is handled here.
 public override int ReadContentAsBase64(byte [] buffer, int offset, int length)
 {
     if (entity != null)
     {
         return(entity.ReadContentAsBase64(buffer, offset, length));
     }
     else
     {
         return(source.ReadContentAsBase64(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);
        }