Esempio n. 1
0
        public IList ReadList <T>(ref T l)
        {
            int count = 0;

            Read(ref count);

            IList list = l as IList;            //BasicClassTypeUtil.CreateObject(l.GetType()) as IList;

            if (list == null)
            {
                TLog.TError("ReadList list == null");
                return(null);
            }

            list.Clear();


            for (int i = 0; i < count; i++)
            {
                object objItem = BasicClassTypeUtil.CreateListItem(list.GetType());
                Read(ref objItem);
                list.Add(objItem);
            }

            return(list);
        }
Esempio n. 2
0
 public bool Decode(TBufferReader reader)
 {
     if (reader != null)
     {
         try
         {
             BeforeDecode(reader);
             ReadFrom(reader);
             return(true);
         }
         catch (Exception ex)
         {
             TLog.TError(ex);
             return(false);
         }
     }
     return(false);
 }
Esempio n. 3
0
        public bool Encode(out byte[] buffer)
        {
            try
            {
                TBufferWriter writer = new TBufferWriter();
                BeforeEncode(writer);
                WriteTo(writer);

                buffer = writer.GetBufferData();
                return(true);
            }
            catch (Exception ex)
            {
                buffer = null;
                TLog.TError(ex);
                return(false);
            }
        }
Esempio n. 4
0
 public bool Decode(byte[] data)
 {
     if (data != null)
     {
         try
         {
             TBufferReader reader = new TBufferReader(data);
             BeforeDecode(reader);
             ReadFrom(reader);
             return(true);
         }
         catch (Exception ex)
         {
             TLog.TError(ex);
             return(false);
         }
     }
     return(false);
 }
Esempio n. 5
0
        public bool Encode(TBufferWriter writer)
        {
            if (writer == null)
            {
                return(false);
            }
            try
            {
                BeforeEncode(writer);
                WriteTo(writer);

                return(true);
            }
            catch (Exception ex)
            {
                TLog.TError(ex);
                return(false);
            }
        }