Esempio n. 1
0
    public static byte[] Serialize(TAbstractBase s) {
      TMemoryBuffer t = new TMemoryBuffer();
      TBinaryProtocol p = new TBinaryProtocol(t);

      s.Write(p);

      return t.GetBuffer();
    }
Esempio n. 2
0
        public static byte[] Serialize(TAbstractBase s)
        {
            var t = new TMemoryBuffer();
            var p = new TCompactProtocol(t);

            s.Write(p);

            return(t.GetBuffer());
        }
Esempio n. 3
0
        public static T DeSerialize <T>(byte[] buf) where T : TBase, new()
        {
            var t     = new T();
            var trans = new TMemoryBuffer(buf);
            var p     = new TBinaryProtocol(trans);

            t.Read(p);
            return(t);
        }
Esempio n. 4
0
        public static byte[] Serialize(TBase s)
        {
            var t = new TMemoryBuffer();
            var p = new TBinaryProtocol(t);

            s.Write(p);

            return(t.GetBuffer());
        }
Esempio n. 5
0
        public static T DeSerialize <T>(byte[] buf) where T : TAbstractBase
        {
            var trans = new TMemoryBuffer(buf);
            var p     = new TCompactProtocol(trans);

            if (typeof(TBase).IsAssignableFrom(typeof(T)))
            {
                var method = typeof(T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
                var t      = Activator.CreateInstance <T>();
                method.Invoke(t, new object[] { p });
                return(t);
            }
            else
            {
                var method = typeof(T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
                return((T)method.Invoke(null, new object[] { p }));
            }
        }
Esempio n. 6
0
		public static byte[] Serialize(TAbstractBase s)
		{
			TMemoryBuffer tMemoryBuffer = new TMemoryBuffer();
			s.Write(new TBinaryProtocol(tMemoryBuffer));
			return tMemoryBuffer.GetBuffer();
		}