本文整理匯總了C#中System.Xml.XmlTextReader.ReadBinHex方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadBinHex方法的具體用法?C# XmlTextReader.ReadBinHex怎麽用?C# XmlTextReader.ReadBinHex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadBinHex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DeserializeIcon
public static System.Drawing.Icon DeserializeIcon(XmlElement xml)
{
System.Drawing.Icon img = null;
if (xml == null || xml.InnerText == "")
return null;
bool bDecodeBinHex = false;
if (xml.HasAttribute("encoding") && xml.GetAttribute("encoding") == "binhex")
bDecodeBinHex = true;
System.IO.StringReader sr = new System.IO.StringReader(xml.OuterXml);
System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
// Skip <image> to data
xr.Read();
byte[] base64 = new byte[1024];
int base64len = 0;
if (bDecodeBinHex)
{
do
{
base64len = xr.ReadBinHex(base64, 0, 1024);
if (base64len > 0)
mem.Write(base64, 0, base64len);
} while (base64len != 0);
}
else
{
do
{
base64len = xr.ReadBase64(base64, 0, 1024);
if (base64len > 0)
mem.Write(base64, 0, base64len);
} while (base64len != 0);
}
mem.Position = 0;
img = new System.Drawing.Icon(mem);
return img;
}