public static byte[] Serialize(TAbstractBase s) { TMemoryBuffer t = new TMemoryBuffer(); TBinaryProtocol p = new TBinaryProtocol(t); s.Write(p); return t.GetBuffer(); }
public static byte[] Serialize(TAbstractBase s) { var t = new TMemoryBuffer(); var p = new TCompactProtocol(t); s.Write(p); return(t.GetBuffer()); }
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); }
public static byte[] Serialize(TBase s) { var t = new TMemoryBuffer(); var p = new TBinaryProtocol(t); s.Write(p); return(t.GetBuffer()); }
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 })); } }
public static byte[] Serialize(TAbstractBase s) { TMemoryBuffer tMemoryBuffer = new TMemoryBuffer(); s.Write(new TBinaryProtocol(tMemoryBuffer)); return tMemoryBuffer.GetBuffer(); }