当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextReader.ReadElementContentAsBase64方法代码示例

本文整理汇总了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;
        }
开发者ID:skaulana,项目名称:eflash,代码行数:94,代码来源:Util.cs


注:本文中的System.Xml.XmlTextReader.ReadElementContentAsBase64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。