本文整理匯總了C#中System.Xml.XmlTextReader.ReadElementContentAsBase64方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadElementContentAsBase64方法的具體用法?C# XmlTextReader.ReadElementContentAsBase64怎麽用?C# XmlTextReader.ReadElementContentAsBase64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementContentAsBase64方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: parseBLOB
public static int parseBLOB(byte[] blob, int uid)
{
int size = 0;
int curDid = -1;
int curCid = -1;
byte[] data = null;
Deck deck = null;
eObject curObj = null;
Card curCard = null;
MemoryStream stream = new MemoryStream(blob);
XmlTextReader reader = new XmlTextReader(stream);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == "Deck")
{
deck = new Deck(reader.GetAttribute("cat"), reader.GetAttribute("subcat"),
reader.GetAttribute("title"), reader.GetAttribute("type"),Convert.ToInt32(reader.GetAttribute("nuid")), uid);
try
{
//Insert to Decks table in local database
curDid = deck.saveToDB();
}
catch
{
throw new Exception("Error Writting Deck!!!");
}
}
else if (reader.Name == "Card")
{
curCard = new Card(reader.GetAttribute("tag"), uid);
try
{
//Insert to Cards table in local database
curCid = curCard.saveToDB(curDid);
}
catch
{
throw new Exception("Error Writting Card!!!");
}
}
else if (reader.Name == "Object")
{
//First create the array of bytes for the blob
size = Convert.ToInt32(reader.GetAttribute("size"));
data = new byte[size];
curObj = new eObject( curCid,
Convert.ToInt32(reader.GetAttribute("side")),
reader.GetAttribute("type"),
Convert.ToInt32(reader.GetAttribute("x1")),
Convert.ToInt32(reader.GetAttribute("x2")),
Convert.ToInt32(reader.GetAttribute("y1")),
Convert.ToInt32(reader.GetAttribute("y2"))
);
try
{
string qType = reader.GetAttribute("quizType");
if (qType == Constant.nonePrefix || qType == Constant.answerPrefix || qType == Constant.questionPrefix)
{
curObj.quizType = qType;
}
}
catch {}
try
{
reader.ReadElementContentAsBase64(data, 0, size);
curObj.efile = new eFile(data);
//save to file and update DB
curObj.save();
}
catch
{
throw new Exception("Error Saving Object !!!");
}
}
break;
}
}
return curDid;
}