本文整理匯總了C#中System.Xml.XmlTextReader.ReadContentAsBase64方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadContentAsBase64方法的具體用法?C# XmlTextReader.ReadContentAsBase64怎麽用?C# XmlTextReader.ReadContentAsBase64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadContentAsBase64方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ParseBinaryData
/// <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);
}