Ejemplo 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);
        }
Ejemplo 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);
 }
Ejemplo 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);
            }
        }
Ejemplo 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);
 }
Ejemplo 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);
            }
        }