ReadElementContentAsBase64() публичный Метод

public ReadElementContentAsBase64 ( byte buffer, int index, int count ) : int
buffer byte
index int
count int
Результат int
Пример #1
0
 [MonoTODO]         // FIXME: Check how expanded entity is handled here.
 public override int ReadElementContentAsBase64(byte [] buffer, int index, int count)
 {
     if (entity != null)
     {
         return(entity.ReadElementContentAsBase64(buffer, index, count));
     }
     else
     {
         return(source.ReadElementContentAsBase64(buffer, index, count));
     }
 }
 [MonoTODO] // FIXME: Check how expanded entity is handled here.
 public override int ReadElementContentAsBase64(byte [] buffer, int offset, int length)
 {
     if (entity != null)
     {
         return(entity.ReadElementContentAsBase64(buffer, offset, length));
     }
     else
     {
         return(source.ReadElementContentAsBase64(buffer, offset, length));
     }
 }
Пример #3
0
        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;
        }